-
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
fix installation using --target #3450
Conversation
We encountered a problem on CentOS 7 machines when using the `--target` option to install packages that are equipped with c-extensions. Observe: ``` me@box ~ $ uname -a Linux box.d.rz.is 3.10.0-327.4.4.el7.x86_64 #1 SMP Tue Jan 5 16:07:00 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux me@box ~ $ python --version Python 2.7.5 me@box ~ $ virtualenv --version 1.10.1 me@box ~ $ virtualenv venv New python executable in venv/bin/python Installing Setuptools.......................................................................................................................................................done. Installing Pip............................................................................................................................................................................................................................................................................done. me@box ~ $ source venv/bin/activate (venv)me@box ~ $ mkdir target (venv)me@box ~ $ ls target venv (venv)me@box ~ $ pip install --index-url https://my_proxy:5000/dev/dev -U pip Collecting pip Downloading https://my_proxy:5000/root/pypi/+f/205/6f553d5b593d3/pip-8.0.2-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 14.3MB/s Installing collected packages: pip Found existing installation: pip 1.4.1 Uninstalling pip-1.4.1: Successfully uninstalled pip-1.4.1 Successfully installed pip-8.0.2 (venv)me@box ~ $ pip install --index-url https://my_proxy:5000/dev/dev --target target pyyaml Collecting pyyaml Downloading https://my_proxy:5000/root/pypi/+f/89c/bc92cda979042/PyYAML-3.11.zip (371kB) 100% |████████████████████████████████| 372kB 18.6MB/s Installing collected packages: pyyaml Running setup.py install for pyyaml ... done Successfully installed pyyaml Exception: Traceback (most recent call last): File "/data/home/me/venv/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main status = self.run(options, args) File "/data/home/me/venv/lib/python2.7/site-packages/pip/commands/install.py", line 357, in run for item in os.listdir(lib_dir): OSError: [Errno 2] No such file or directory: '/tmp/tmpz2LoDs/lib/python' (venv)me@box ~ $ pip install --index-url https://my_proxy:5000/dev/dev --target target simplejson Collecting simplejson Downloading https://my_proxy:5000/root/pypi/+f/b84/41f1053edd9dc/simplejson-3.8.1.tar.gz (76kB) 100% |████████████████████████████████| 77kB 19.0MB/s Installing collected packages: simplejson Running setup.py install for simplejson ... done Successfully installed simplejson Exception: Traceback (most recent call last): File "/data/home/me/venv/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main status = self.run(options, args) File "/data/home/me/venv/lib/python2.7/site-packages/pip/commands/install.py", line 357, in run for item in os.listdir(lib_dir): OSError: [Errno 2] No such file or directory: '/tmp/tmpEFNOZq/lib/python' (venv)me@box ~ $ pip install --index-url https://my_proxy:5000/dev/dev --target target markupsafe Collecting markupsafe Downloading https://my_proxy:5000/root/pypi/+f/f5a/b3deee4c37cd6/MarkupSafe-0.23.tar.gz Installing collected packages: markupsafe Running setup.py install for markupsafe ... done Successfully installed markupsafe Exception: Traceback (most recent call last): File "/data/home/me/venv/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main status = self.run(options, args) File "/data/home/me/venv/lib/python2.7/site-packages/pip/commands/install.py", line 357, in run for item in os.listdir(lib_dir): OSError: [Errno 2] No such file or directory: '/tmp/tmp4UuvDJ/lib/python' (venv)me@box ~ $ ls /tmp/tmp4UuvDJ/ lib64 ``` As you can see using `--target` first installs into a temporary directory and then installes into the desired `target`. Well, at least it tries to: for any packages that have c-extensions (in this case pyyaml, simplejson and markupsafe) it incorrectly looks for a `lib` directory whereas it should be looking for a `lib64` directory. This patch fixes that for us by looking in a fallback location. We can confirm that this fixes the issue for us. Please advise.
cc @snordhausen |
I can spice this up with tests, cleaner code and better error messages if you would principally accept the patch. |
currently failing because pypi is down |
This is green, would appreciate some feedback from the developers, our project is currently blocking on this. |
I think this will break if things are installed into both purelib and platlib. We shouldn't presume its either-or. |
@rbtcollins that is correct, but this patch would already fix if it were either or, which fixes issues we are having today. If any package installs into purelib and platlib it would be currently broken and would continue to be broken after this PR is merged. Do you know of any package that installs into purelib and platlib? |
I rewrote the code to copy both purelub and platlib, though I have no idea if it will work or not, an example package would come in handy. |
Thanks. So - we're about to deprecate the --target option unless we can put together a sensible use case for it - this bug report reminded us how broken it is. Could you perhaps explain the use case you have that leads you to use it? |
Yes, this is quite important when it comes to making AWS Lambda-Functions in Python. In fact https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html Not having this would cause some serious breakage in our builds and deployments since we rely heavily on it via: https://github.com/ImmobilienScout24/pybuilder_aws_plugin Granted, the way AWS expects us to package so-called lambda-zips isn't exactly standard, but we would request to keep |
I'll fix the PR tomorrow, currently not on the correct device. |
What about the virtualenv style documented lower on that same page?
|
Hmm, that get's a bit messy, since we already have a virtualenv for development and running the build tool, I suppose one could make it work. The nice thing about |
Please do not deprecate the --target option! Our use case is a command line upgrade command for a package (MiModD) we are maintaining, which uses pip install --target under the hood to grab the correct distribution from pypi and install it into a temporary directory. We then modify the "installed" files before copying them over to the actual location of the currently installed version. |
Accidentally closed this, reopening. Sorry! |
You can close this in favour of #3684 |
Hello! As part of an effort to ease the contribution process and adopt a more standard workflow pip has switched to doing development on the If you do nothing, this Pull Request will be automatically migrated by @BrownTruck for you. If you would like to retain control over this pull request then you should resubmit it against the If you choose to migrate this Pull Request yourself, here is an example message that you can copy and paste:
If this pull request is no longer needed, please feel free to close it. |
This Pull Request has been automatically migrated to #3730 to reparent it to the |
-- fix using pip with --target option (pypa/pip#3056 and pypa/pip#3450)
We encountered a problem on CentOS 7 machines when using the
--target
optionto install packages that are equipped with c-extensions.
Observe:
As you can see using
--target
first installs into a temporary directory andthen installes into the desired
target
. Well, at least it tries to: for anypackages that have c-extensions (in this case pyyaml, simplejson and
markupsafe) it incorrectly looks for a
lib
directory whereas it should belooking for a
lib64
directory. This patch fixes that for us by looking in afallback location. We can confirm that this fixes the issue for us.
Please advise.