-
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
Move __pip-runner__
script into a module
#11262
Move __pip-runner__
script into a module
#11262
Conversation
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
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.
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 pip After: ❯ 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.
Follow up to #11257