Skip to content
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

#10560 Broke python.exe pip.whl/pip install #11146

Closed
indygreg opened this issue May 26, 2022 · 4 comments
Closed

#10560 Broke python.exe pip.whl/pip install #11146

indygreg opened this issue May 26, 2022 · 4 comments
Labels
resolution: no action When the resolution is to not do anything type: bug A confirmed bug or unintended behavior

Comments

@indygreg
Copy link

Description

#10560 broke python.exe /path/to/pip.whl/pip install on Windows.

I believe this is a side-effect of using os.path.basename(sys.argv[0]) == "pip" to attempt to check for direct pip invocations. Unfortunately, the new logic fails to handle the special case where python <wheel>/<module> can execute a module in a wheel file.

The python <wheel>/<module> syntax and behavior inside the interpreter with respect to sys.argv is a bit wonky. And using this syntax is probably an edge case. While I think the new behavior is incorrect, I'm unsure whether it is worth anyone's time to fix.

Expected behavior

python.exe /path/to/pip.whl/pip should work.

pip version

22.1.1

Python version

3.8-3.10

OS

Windows

How to Reproduce

python pip.whl/pip install

Output

executing C:\Users\RUNNER~1\AppData\Local\Temp\python-build-9rosg__z\out\python\install\python.exe D:\a\python-build-standalone\python-build-standalone\build\pip-22.1.1-py3-none-any.whl\pip install --no-cache-dir --no-index D:\a\python-build-standalone\python-build-standalone\build\pip-22.1.1-py3-none-any.whl
Processing d:\a\python-build-standalone\python-build-standalone\build\pip-22.1.1-py3-none-any.whl
ERROR: To modify pip, please run the following command:
C:\Users\RUNNER~1\AppData\Local\Temp\python-build-9rosg__z\out\python\install\python.exe -m pip install --no-cache-dir --no-index D:\a\python-build-standalone\python-build-standalone\build\pip-22.1.1-py3-none-any.whl


### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).
@indygreg indygreg added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels May 26, 2022
@uranusjr
Copy link
Member

uranusjr commented May 26, 2022

If I recall correctly, this was mentioned in the initial fix (not that PR which fixed the fix) and decided to be an unfortunate compromise. Running pip directly from wheel was never an officially supported operation.

@uranusjr uranusjr closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2022
@uranusjr uranusjr added the resolution: no action When the resolution is to not do anything label May 26, 2022
@indygreg
Copy link
Author

Yeah, this is an esoteric execution mode: I understand not wanting to support it.

FWIW this broke python-build-standalone, which used this method because it was robust in the face of cross-compiling. See indygreg/python-build-standalone@cd2a0ff. According to my commit message, I borrowed the idea from ensurepip. So presumably ensurepip was modified upstream to account for this change in behavior. So I guess I'll change to whatever ensurepip is doing now.

Thanks for your feedback.

@uranusjr
Copy link
Member

Actually ensurepip has not upgraded to 22.1, so we’ll see 😛 Maybe we’ll need to somehow add a special case for this eventually.

In the meantime, an alternative is to use get-pip.py’s approach—use zipfile to write the pip directory inside the wheel to a temporary file, and run that instead.

@indygreg
Copy link
Author

FWIW it appears PYTHONPATH=pip.whl python.exe -m pip install works. This is just doing what I was doing before, just without the new/fixed Windows self-update prevention logic interfering. But since this is unsupported, I may transition to the wheel/zip extract approach.

indygreg added a commit to indygreg/python-build-standalone that referenced this issue May 26, 2022
pip 22.1.1 broke the old `python.exe pip.wheel/pip install` invocation.
See pypa/pip#11146.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2022
@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: no action When the resolution is to not do anything type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants