Move __pip-runner__ script into a module #11262
Merged
Conversation
pfmoore
approved these changes
Jul 15, 2022
a2d22a9 to
fbf4bbb
Compare
This makes it possible to eliminate the need for writing a copy of this script in a temporary directory for each isolated build environment.
fbf4bbb to
5f2a858
Compare
sbidoul
approved these changes
Jul 15, 2022
This makes it possible to only "replace" `pip` and have the submodules get correctly located by the regular importlib machinery. This also asserts that it was able to locate the module, ensuring that failure to locate the module results in an exception.
Member
Author
|
Moving this out into a module helped me identify that we weren't correctly replacing the I've changed the implementation, in this PR, to ensure that we replace that module correctly. One nice property of moving this into a module, is that I can run it for testing things manually (and automatically)! Before: ❯ python -m pip --version
/Users/pradyunsg/Developer/github/pip/.venv/bin/python: No module named pip
❯ python src/pip/__pip-runner__.py install .
Traceback (most recent call last):
File "/Users/pradyunsg/Developer/github/pip/src/pip/__pip-runner__.py", line 37, in <module>
runpy.run_module("pip", run_name="__main__")
File "/Users/pradyunsg/.asdf/installs/python/3.10.1/lib/python3.10/runpy.py", line 205, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/Users/pradyunsg/.asdf/installs/python/3.10.1/lib/python3.10/runpy.py", line 140, in _get_module_details
raise error("No module named %s" % mod_name)
ImportError: No module named pipAfter: ❯ python -m pip --version
/Users/pradyunsg/Developer/github/pip/.venv/bin/python: No module named pip
❯ python src/pip/__pip-runner__.py install .
Processing /Users/pradyunsg/Developer/github/pip
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pip
Building wheel for pip (pyproject.toml) ... done
Created wheel for pip: filename=pip-22.2.dev0-py3-none-any.whl size=2145280 sha256=9c06ef8f4a063b041160ed4e843e570c4564549754441d2502ff4c9cb348092f
Stored in directory: /private/var/folders/y1/j465wvf92vs938kmgqh63bj80000gn/T/pip-ephem-wheel-cache-4ofpbybe/wheels/54/9f/74/29320177d01b5bd98b902e57e24b770257a633ca58c02b60f1
Successfully built pip
Installing collected packages: pip
Successfully installed pip-22.2.dev0
❯ python -m pip --version
pip 22.2.dev0 from /Users/pradyunsg/Developer/github/pip/.venv/lib/python3.10/site-packages/pip (python 3.10) |
This ensures that the runner script can be used in environments where pip is not installed.
sbidoul
reviewed
Jul 16, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up to #11257