Bugzilla – Bug 1225660
python311-pip package installs in /usr/lib by default
Last modified: 2024-07-10 09:20:05 UTC
In tumbleweed installing a package with pip3 as root installs in the system path /usr/lib. It should install in /usr/local/lib instead. Possibly related to this patch: https://build.opensuse.org/projects/devel:languages:python:Factory/packages/python311/files/F00251-change-user-install-location.patch?expand=1
I've been working in an initial implementation of this with two patches, one for the python interpreter and another one for the python-pip: * python311: https://build.opensuse.org/projects/home:dgarcia:usr-local/packages/python311/files/bsc1225660-add-local-posix-path-scheme.patch?expand=1 * python-pip: https://build.opensuse.org/projects/home:dgarcia:usr-local/packages/python-pip/files/install-usr-local.patch?expand=1 With this patch, pip installs by default in "/usr/local/", and the usage to create rpm packages works as expected installing in "/usr/". In any case, the usage of pip with installed system packages will lead to override or remove installed files by packages, because when removing, pip looks for the python module in any installation path. But that's how pip works, and if the user mess around with the system as root, we can't prevent system breakage.
(In reply to Daniel Garcia from comment #1) > I've been working in an initial implementation of this with two patches, one > for the python interpreter and another one for the python-pip > Maybe it's easier to do it just in the pip code, using the "prefix" argument: # pip installations by default to local if prefix is None and scheme_name == "posix_prefix" and "RPM_BUILD_ROOT" not in os.environ: prefix = "/usr/local" https://build.opensuse.org/projects/home:dgarcia:usr-local/packages/python-pip/files/install-usr-local.patch?expand=1
(In reply to Daniel Garcia from comment #1) > I've been working in an initial implementation of this with two patches, one > for the python interpreter and another one for the python-pip: > > * python311: > https://build.opensuse.org/projects/home:dgarcia:usr-local/packages/ > python311/files/bsc1225660-add-local-posix-path-scheme.patch?expand=1 Is this supposed to replace https://build.opensuse.org/projects/home:dgarcia:usr-local/packages/python311/files/F00251-change-user-install-location.patch?expand=1 or is it building on the top of it?
(In reply to Matej Cepl from comment #3) > (In reply to Daniel Garcia from comment #1) > > I've been working in an initial implementation of this with two patches, one > > for the python interpreter and another one for the python-pip: > > > > * python311: > > https://build.opensuse.org/projects/home:dgarcia:usr-local/packages/ > > python311/files/bsc1225660-add-local-posix-path-scheme.patch?expand=1 > > Is this supposed to replace > https://build.opensuse.org/projects/home:dgarcia:usr-local/packages/ > python311/files/F00251-change-user-install-location.patch?expand=1 or is it > building on the top of it? It's on top of it. This is just for the "pip" installation. The F00251 is for packages installed using distutils directly. We don't have this patch in python312 because distutils was removed from cpython now, and now the way to install packages is using pip, so I think that patching pip could be enough. Maybe it could be also good to patch _distutils in the python-setuptools package.
Fedora does all the changes in cpython with a patch. I'm testing this patch with our python311 [1] package and it requires also a change in python-rpm-macros [2]. [1] https://build.opensuse.org/projects/home:dgarcia:usr-local-cpython/packages/python311/files/F00251-change-user-install-location.patch?expand=1 [2] https://github.com/openSUSE/python-rpm-macros/commit/6a2a3e37ecbd86c53662408a3448c56c86de8662
Update of python-rpm-macros to support the patch on cpython on its way to factory: * https://build.opensuse.org/request/show/1181251
I've been testing and this is not needed for python38 and python39. For the rest of python interpreters I've just updated the patch (get it back for python312) and, with this, it's working as expected, installing in /usr/local when using pip outside of rpm build environment. * https://build.opensuse.org/request/show/1184844 * https://build.opensuse.org/request/show/1184845 * https://build.opensuse.org/request/show/1184846
This is an autogenerated message for OBS integration: This bug (1225660) was mentioned in https://build.opensuse.org/request/show/1186495 Factory / python312