-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipenv unexpectedly installs from requirements.txt (even from parent directories) #2222
Comments
I can reproduce on macOS. This is actually kind of cool, but we still need to fix it. |
I changed the title a little to reflect the situation better. |
I think I know what’s going on here. The requirements.txt finder looks in parent directories (not sure how many levels it would look) for requirements.txt. I’m not sure if this is the intended behaviour, but at least this seems unrelated to Git. Modifying the title again to reflect this. |
We may want to split this out into an additional bug I also noted that when I pipenv install I don't want it to find requirements.txt and install everything. The reason I found this issue to begin with was I wanted to not install all the things in my requirements.txt because I wanted to install things manually so I could manage what was in Pipfile vs. the dependencies and wanted to move other things to --dev. I probably should have put that in the bug description to begin with. |
Pipenv recurses up to find pipfiles and requirements files. You can set |
Hi @techalchemy, that's a nice explanation of how things work now. I've tried pipenv several times over the past year and kept switching back to pip and virtualenvwrapper-win because of these behaviors I didn't understand. I think it would be improved, especially for new Python developers if the tool was more deterministic and if the actions it performed were explicit rather than implied. Some ideas:
Thanks again for pipenv! |
I feel the “have a requirements.txt but not install everything” feature is an edge case. You can create the Pipfile manually in this case ( Regarding to the auto detection, however, I do find the current “search in parent directories” behaviour counter-intuitive. The auto-import only happens when you first initialise the environment (i.e. don’t have a Pipfile yet), and in almost all situations you would do it in the project root, because that just makes sense. How Pipenv converts requirements.txt in a parent directory is also not very consistent with itself. Say I have this file structure:
When I run So there are two ways to fix this inconsistency (that I can think of):
|
I agree that we can reevaluate most of this. It definitely causes confusion
|
I spent a little time messing around and wanted to add some notes... I see now that when you Coming from the pip & virtualenv world that wasn't obvious to me. Based on a deeper understanding, I sorta get why if there was no Pipfile and pipenv finds a requirements.txt it wants to treat it like a Pipfile and process it. Based on an earlier comment, I thought maybe I could workaround by using a blank file. I created a blank Pipfile with a requirements.txt in the same folder and the libraries in requirements.txt where installed when I pipenv installed a new library. I go back to my original use case and I think I'm at the same opinion:
Originally, I moved the requirements.txt up a folder and we see that didn't work. As-is I guess you have to rename requirements.txt or delete it. Instead, I think pipenv should never automatically process a requirements.txt and instead an --import-requirements (or something) should be added to be used in the migration process. However, maybe there is another use case I'm not considering, like trying to co-exist both Pipfiles and Requirements.txt? Thanks for the good discussion! |
While I understand it can be technically cleaner to have an explicit |
We have an internal toggle to ignore requirements files. We probably should ignore them when a user passes in something to install |
That sounds reasonable. |
- Also don't search for requirements.txt if taking in a package name - Fixes #2222 Signed-off-by: Dan Ryan <[email protected]>
This behavior is extremely error-prone. I was chasing ghosts for hours until I realized that a
Unfortunately, this was not fixed by #2309 . Calling |
Feel free to submit a PEEP about this and suggest an alternative. |
I have to voice my support for @carlosdanielcsantos opinion here. Pipenv looking for In my opinion it would be reasonable to treat the current working directory as the project root when running |
Feel free to submit a PEEP about this and suggest an alternative. |
@carlosdanielcsantos are you working on a PEEP for this already? |
Not yet @martinraag, please go ahead! |
I was also hit by this. I understand that changing pipenv behaviour requires some considerations and effort but I feel it would help a lot if pipenv at least print the absolute path to the found requirements.txt The message requirements.txt found, instead of Pipfile! Converting… is extremely confusing when there is no requirements.txt in current folder. |
That’s likely a good idea. Care to submit a PR? I imagine it’d be appropriate to output something like:
|
This was a weird one and it was so odd that I thought I was losing my mind for a bit. ;-) Thanks for pipenv though, I'm very excited about this new direction!
Pipenv installs requirements.txt when you don't ask it to, and when it try to keep it from installing them, it still does. This is on Windows 10. Not sure if reproduces on Linux\OSx
$ python -m pipenv.help
$ python -m pipenv.help output
Pipenv version:
'2018.05.18'
Pipenv location:
'C:\\Users\\patri\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\pipenv'
Python location:
'C:\\Users\\patri\\AppData\\Local\\Programs\\Python\\Python36\\python.exe'
Other Python installations in
PATH
:3.6
:C:\Users\patri\AppData\Local\Programs\Python\Python36\python.exe
3.6.5
:C:\Users\patri\AppData\Local\Programs\Python\Python36\python.exe
3.6.5
:C:\Windows\py.exe
PEP 508 Information:
System environment variables:
ALLUSERSPROFILE
APPDATA
COMMONPROGRAMFILES
COMMONPROGRAMFILES(X86)
COMMONPROGRAMW6432
COMPUTERNAME
COMSPEC
DRIVERDATA
GDAL_DATA
HOMEDRIVE
HOMEPATH
LOCALAPPDATA
LOGONSERVER
NUMBER_OF_PROCESSORS
ONEDRIVE
OS
OSGEO4W_ROOT
PATH
PATHEXT
POSTGIS_ENABLE_OUTDB_RASTERS
POSTGIS_GDAL_ENABLED_DRIVERS
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
PROGRAMDATA
PROGRAMFILES
PROGRAMFILES(X86)
PROGRAMW6432
PROJ_LIB
PROMPT
PSMODULEPATH
PUBLIC
SESSIONNAME
SYSTEMDRIVE
SYSTEMROOT
TEMP
TMP
USERDOMAIN
USERDOMAIN_ROAMINGPROFILE
USERNAME
USERPROFILE
VS140COMNTOOLS
WINDIR
PYTHONDONTWRITEBYTECODE
PIP_PYTHON_PATH
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH
:C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Dell\DW WLAN Card;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\patri\Tools\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\Amazon\AWSCLI;C:\Users\patri\AppData\Local\GitHub\PortableGit_d76a6a98c9315931ec4927243517bc09e9b731a0\cmd;C:\Users\patri\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;C:\Users\patri\AppData\Roaming\npm;C:\Program Files\Heroku\bin;C:\OSGeo4W64\bin;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Amazon\AWSCLI\bin\;C:\WINDOWS\System32\OpenSSH\;c:\users\patri\appdata\local\programs\python\python36\Scripts;C:\Users\patri\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\patri\AppData\Local\Programs\Python\Python36\;C:\Program Files\Amazon\AWSCLI;C:\Users\patri\AppData\Local\GitHub\PortableGit_d76a6a98c9315931ec4927243517bc09e9b731a0\cmd;C:\Users\patri\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;C:\Program Files\Heroku\bin;C:\Users\patri\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\patri\AppData\Local\Pandoc\;
Contents of
Pipfile
('C:\Users\patri\code\local\piptest\Pipfile'):Contents of
Pipfile.lock
('C:\Users\patri\code\local\piptest\Pipfile.lock'):Expected result
pipenv install should NOT install anything else other than library & dependencies.
pipenv install should not install requirements.txt when requirements.txt has been moved (from the repro and not commited)
Actual result
pipenv installs requirements.txt when it exists and its not asked to.
pipenv installs requirement.txt when it is deleted and the change is not commited to the repro
When possible, provide the verbose output (
--verbose
), especially for locking and dependencies resolving issues.Steps to replicate
4.. Add and Commit requirements.txt to the repro
.6 pipenv install some other library (
pipenv install requests
)The library in the requirements.txt is installed
The text was updated successfully, but these errors were encountered: