-
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
install --root=... tries to remove previously globally installed version #3063
Comments
pip has a bug that may break the build: pypa/pip#3063
hi, I think I still have this problem :-(
|
Hey @yan12125! Thanks for filing this issue and sorry for the lack of response. As I understand, you want --root to be treated as a simple change of directory where installation is done, with same behaviour for dealing with already installed packages. Is that correct? |
General advice: pip should not be run with sudo permissions since essentially there's remote code execution taking place. |
Yes. I need it for
Not sure about how installed packages are handled, though. |
@yan12125 Does --prefix provide the needed behavior? |
Seems the result is similar for
pip shouldn't look for installed packages in default paths (e.g., ~/.local/lib/python3.6/site-packages) at all. |
I agree with @asfaltboy in #3029, --root should cause it to not consider things in sys.path locations outside of the specified root (or prefix). But, #3029 got closed shortly after that point in discussion as a dup of this one. Now, I hit this myself 3 years later, ref #6355. Any chance this can get fixed/changed eventually? |
Experiencing the same issue. |
Now, 4 years after my original issue, I actually feel the behaviour as consistent. If you consider pip to be consistent with python, a package can be found by python, pip should also find it. The workaround for "isolating packages to root" for both python and pip, would not be alter the behaviour of pip, but rather modify That said, regarding the I will speak for myself: if I look back at my the original use case, for which I opened a number of bugs under pypa projects, I was mostly trying to abuse packaging features to deploy applications (their dependencies) in some sort of isolation. I have since left that company, but the last thing I remember before we left, we got to a fully working deployment by installing wheels (from devpi) into a venv, and using |
hi, |
Related to #4575, since defining an explicit scheme means we would use that same scheme for determining whether a package is installed in the first place. |
I found this bug from https://bugs.python.org/issue31916 which is filed in the context of DESTDIR. When installing Python 3.7.6 and using "make install DESTDIR=...", pip gets installed as well. The problem is that it uses (in my case) /usr/local/bin/python3.7 as the interpreter, not something prefixed with the DESTDIR. Interestingly, with Python 2.7.17, pip installed using ensurepip employs the correct interpreter. Perhaps this came about because the interpreter was already installed and the correct path identified. In my case, I am inclined to think this is a Python 3 bug since the top-level Python Makefile uses the build Python to run ensurepip. This is a consequence of it appearing in the install rule. It can, however, be omitted by configuring with --with-ensurepip=no. (In Python 2, the default is not to run ensurepip.) Once Python has been installed, the installed interpreter can then be run with "-m ensurepip" and either --default-pip or --altinstall to make the tool available. It will have the correct interpreter line in the script. Sorry if this is not relevant to this particular bug, but I write this here for those following the link from the Python bug. I aim to re-open the Python bug in question. |
Any updates on this issue? I am also hitting this issue with |
I ran into a similar issue. My setup was
So in my case this method got |
I encounter the same issue as many others users. |
As I understand the way the python build/install world, times are shifting: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html Because of this pip issue, this leaves users to choose between potentially broken 'setup.py install --prefix' issues ("broken" due to various alleged problems with setuptools) and using 'pip install' plus hacky flags. Are there some thoughts to a way forward to fix this? I'm not against the idea of poking around to come up with a candidate to fix this, but what has been investigated so far for this issue? |
This is also my use case. Currently I use I have also tried to create a venv inside the image/chroot, however as python is running from outside the targets filesystem all the shebangs are messed up. Is there any way to customize the path of the interpreter where the shebangs point to? |
The modules are installed in the .egg directory, and therefore cannot be imported after that. Additionally PIP tries to remove the global gpiod module if it's not invoked with the --ignore-installed option. Specify correct --root and fix the --prefix switch. Link: pypa/pip#3063 Suggested-by: Maxim Devaev <[email protected]> Reported-by: Maxim Devaev <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
The modules are installed in the .egg directory, and therefore cannot be imported after that. Specify correct --root and fix the --prefix switch. Link: pypa/pip#3063 Suggested-by: Maxim Devaev <[email protected]> Reported-by: Maxim Devaev <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
This previously broke distro package builds when they happened with the `cockpit-bridge` package installed: ``` Processing ./tmp/wheel/cockpit-0-py3-none-any.whl Installing collected packages: cockpit Attempting uninstall: cockpit Found existing installation: cockpit 311 ERROR: Cannot uninstall cockpit 311, RECORD file not found. Hint: The package was installed by debian. ``` This is a `pip` bug (pypa/pip#3063), work around it with `--ignore-installed`.
This previously broke distro package builds when they happened with the `cockpit-bridge` package installed: ``` Processing ./tmp/wheel/cockpit-0-py3-none-any.whl Installing collected packages: cockpit Attempting uninstall: cockpit Found existing installation: cockpit 311 ERROR: Cannot uninstall cockpit 311, RECORD file not found. Hint: The package was installed by debian. ``` This is a `pip` bug (pypa/pip#3063), work around it with `--ignore-installed`.
The "python setup.py install" method is deprecated [1] and replaced by "pip install ." However there's a bug[2] in pip since ~9 years which necessitates a hack so it does not try to uninstall the globally installed version. This bug triggers only when building on a system with this package previously installed with the _same_ pkgver (i.e. when rebuilding, or when the pkgrel is increased). [1] https://packaging.python.org/en/latest/discussions/setup-py-deprecated/ [2] pypa/pip#3063 "install --root=... tries to remove previously globally installed version"
This previously broke distro package builds when they happened with the `cockpit-bridge` package installed: ``` Processing ./tmp/wheel/cockpit-0-py3-none-any.whl Installing collected packages: cockpit Attempting uninstall: cockpit Found existing installation: cockpit 311 ERROR: Cannot uninstall cockpit 311, RECORD file not found. Hint: The package was installed by debian. ``` This is a `pip` bug (pypa/pip#3063), work around it with `--ignore-installed`.
I tried to do
pip install --root=... some-wheel-file.whl
, which failed with a permission error because it tried to uninstall a globally installed version(!) and I luckily didn’t run with root permissions.If i had, pip would have fucked up my package-manager-controlled global install.
What should happen is the same as with
--user
: install all dependencies to--root
, then check if the package itself is installed in--root
, remove it if so, and (re)install it to there. Leave it alone if it’s installed elsewhere.Related to #3029
I can circumvent it by doing
--root=... --ignore-installed --no-deps
, but that is a hack:What it does is ignoring installed packages to make it not try to remove previously installed versions (which it shouldn’t do in the first place if those versions don’t live in the specified
--root
!), and then I make it not install dependencies so that i end up with only that package installed in my--root
.The text was updated successfully, but these errors were encountered: