-
Notifications
You must be signed in to change notification settings - Fork 3k
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
pip -r double installs if called also from within setup.py #2745
Comments
a instead of calling pip, |
Perhaps we should consider this a defect (that its possible) and arrange to detect it? |
maybe, we could re-check before every install? but as it is, the |
It took a long time and studying to arrive at this solution. Some reasons are documented in this commit message. It notes why [I just noticed that the Also, I have studied the post-install hook approach with Calling Any package that uses It also works unchanged for Ideally, A minor tweak to avoid race conditions was to detect Somewhat more generally, it would be good if there was some way of communicating to The approach of calling |
Correction to comment: there is (implicit) communication from the calling This simple behavior was one of the original reasons that I chose to go with calling |
So I think I've found the cause. It is not as conjectured above. What happens is:
So |
My opinion is that pip should keep a lock file in the target site-packages and disallow using multiple |
With sufficient work we could error if the installed packages have changed during collection. Any changed to the package database during collection invalidates all of collection: new additional packages may be conflicting requirements (#2687) or if they satisfy a desired package may have different dependencies of their own (#988) and so we'd at minimum have to perform the entire collection again. Dealing with other installing tools implies that the locking mechanism should be a distutils PEP and standardised. |
Thanks for the ideas. I think that (global) locking is the appropriate way to prevent concurrent installations from messing up Revisiting the nested Any installation using Also, detecting that install = False
for option in sys.argv:
for s in ('install', 'develop', 'dist', 'build'):
if s in option:
install = True
if install and missing_dependencies:
raise ImportError('Required build dependencies not found.') This way, they allow Fortunately, things can be simplified for packages that are only caching things: print a warning instead of distinguishing between "egg_info" and installation runs. This will lead to the desired result when using |
Build dependencies should be declared in setup_requires. I realise that that has some poor behaviours today, but it is the defined interface - and I'm working up the stack to be able to make that declarative soon I hope. |
These are the requirements listed in `setup.py`. Extras have been included, except for those that require fragile compilation / linking (`cvxopt` and dependents). Versions pinned (good practice for requirement files) to same numbers as those in `setup.py`. These are outdated versions, and should be changed explicitly, in separate commits, so that the changes don't go unnoticed. Note that this provides a common reference. The introduction of `requirements.txt` was motivated by (among other reasons) the failure of `python setup.py install` when `setuptools` attempts to install `scipy` before `numpy`. This failure can be avoided with a sufficiently updated `pip`, because `pip` collects all dependencies, sorts them topologically, and installs them in that order. Therefore, without a `requirements.txt`, it is more cumbersome to install `tulip` with `python setup.py install`. Another reason is the need to run `python setup.py install` twice, in case `ply` is absent. The message printed at the end of an installation can go unnoticed. Note that topological sorting by `pip` avoids this issue to, by installing `ply` before `tulip`. Also, cf: pypa/pip#2745
In a clean
virtualenv
, with:python
2.7.9pip
v6.1.1the
requirements.txt
:leaves a
site-packages
containing:with directory
ply
containing files from both v3.4 and v3.6.I think that this is caused by a nested call to
pip
from thesetup.py
of packagedd
:Apparently,
pip
collects all requirements, decides to installply
v3.4, starts building packages.While building packages, the nested call to
pip
should see no installedply
, if all packages are going to be copied at the end tosite-packages
(not sure if this is the behavior ofpip
).So the nested call installs
ply
v3.6, satisfyingply >= 3.4
, because it is oblivious of the requirementply==3.4
in the requirements file. In addition, the outer call topip
that handles therequirements.txt
doesn't know that a nested call occurred, so apparently it is going to build and copyply
v3.4 on top of the nested install ofply
v3.6. This leaves a corruptedply
insite-packages
.The text was updated successfully, but these errors were encountered: