gh-75229: make ensurepip honour value of --prefix option#135488
Conversation
7b297a2 to
4b24401
Compare
|
Has this PR addressed the various concerns raised in #17634 or is it simply a copy of that PR, reopened by a new author? I'm concerned by the comment in the OP here:
I'm not sure who is expected to take responsibility for the correctness of this PR in the light of this statement? |
4b24401 to
5c4b65b
Compare
|
On Fri Jun 13, 2025 at 11:29 PM CEST, Paul Moore wrote:
Has this PR addressed the various concerns raised in #17634 or is it simply a copy of that PR, reopened by a new author?
I believe I have addressed those concerns in the second commit (the first comments is this PR squashed).
|
4331577 to
90694b0
Compare
|
I don't understand that |
03d9ad8 to
8e928a6
Compare
|
This PR is stale because it has been open for 30 days with no activity. |
|
@mcepl The comments about default values for The "Cross build Linux" test failing is a blocking issue. It relies on |
Agreed on this. @mcepl if you fix the merge conflict the tests will run and you can see what the issue is |
|
What do you think now? Should I rebase on the top of |
Documentation build overview
8 files changed ·
|
Per the devguide, we prefer to not have force pushes, so I would not rebase and merge main and resolve conflicts. |
56d6efb to
461fc78
Compare
When cross-compiling, the local Python interpreter that is used
to run `ensurepip` may not have the same value of `sys.prefix` as
the value of the 'prefix' variable that is set in the Makefile.
With the following values used to install Python locally for
a later copy to the files hierarchy owned by the 'termux'
application on an Android device:
DESTDIR=/tmp/android
prefix=/data/data/com.termux/files/usr/local
'make install' causes ensurepip to install pip in
$(DESTDIR)/usr/local instead of the expected $(DESTDIR)/$(prefix)
where is installed the standard library.
The attached patch fixes the problem. The patch was implemented
assuming that pip uses distutils for the installation (note that
setup.py also uses the --prefix option in the Makefile), but I
know nothing about pip so forgive me if the patch is wrong and
please just assume it is just a way to demonstrate the problem.
Fixes: python#75229
Fixes: https://bugs.python.org/issue31046
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
References: python#17634
Signed-off-by: Matěj Cepl <mcepl@cepl.eu>
When using `python -m ensurepip` with the `--root` option for staged installations, the generated pip script contained an incorrect shebang that pointed into the staging directory. This made the installation unusable once the staging directory was removed. This commit fixes the issue by using the internal pip `--executable` option to force the shebang to point to the correct, final interpreter path. It also corrects related pathing issues: - Removes the check that incorrectly disallowed using --root and --prefix together. - Defaults the installation prefix to `/` when --root is used alone, ensuring installation occurs at the base of the staging directory. References: python#17634 (comment) Signed-off-by: Matěj Cepl <mcepl@cepl.eu>
Don't break the default installation on the current system with good `sys.prefix`.
It is made incorrect by the previous commit.
Update test expectations in test_ensurepip.py to account for the new --executable argument that gets added when using --prefix or --root options. The implementation now correctly sets the executable path when installing with a custom prefix, but the tests weren't updated to expect this additional argument. - test_bootstrapping_with_root: expect --prefix "/" and --executable - test_bootstrapping_with_prefix: expect --executable argument
Keep root-only installs using the interpreter's default prefix while preserving the cross-build fix for Makefile-driven installs that pass an explicit prefix.
461fc78 to
60417f3
Compare
|
Oh drat! I misread your last comment as a request to rebase, resolve conflicts, but not to squash. I am sorry. |
When cross-compiling, the local Python interpreter that is used to run
ensurepipmay not have the same value ofsys.prefixas the value of the 'prefix' variable that is set in the Makefile.With the following values used to install Python locally for a later copy to the files hierarchy owned by the 'termux' application on an Android device:
'make install' causes ensurepip to install pip in
$(DESTDIR)/usr/localinstead of the expected$(DESTDIR)/$(prefix)where is installed the standard library.The attached patch fixes the problem. The patch was implemented assuming that pip uses
distutilsfor the installation (note that setup.py also uses the --prefix option in the Makefile), but I know nothing about pip so forgive me if the patch is wrong and please just assume it is just a way to demonstrate the problem.Fixes: #75229
Co-authored-by: Pradyun Gedam pradyunsg@gmail.com
Co-authored-by: Erlend E. Aasland erlend.aasland@protonmail.com
Co-authored-by: Zackery Spytz zspytz@gmail.com
References: #17634
Signed-off-by: Matěj Cepl mcepl@cepl.eu