Add new site management commands for running pip and python.
Review Request #12998 — Created April 30, 2023 and submitted
This introduces two new special commands for
rb-site manage:pip
andpython. These are used to executepipandpython,
respectively, using the correct version of the site.If the site is installed with an embedded
venvdirectory, the
executable will be run from there, ensuring the command is executing
within that virtual environment.If the site is a traditional globally-installed site, the versioned
pythonX.Ybinary for the current version of Python runningrb-site
will be used.pipalways usespythonX.Y -m pip.The
pythoncommand is conceptually distinct fromshell, as it's
meant to be a raw pass-through to Python, rather than an interactive
shell (Django has additional logic going into their shell and can
executeipythonorbpython).These are intentionally not implemented as management commands, in
order to minimize any Django-related code that needs to execute in
order to work with packages or the Python interpreter.This will be the preferred way going forward for documenting any
pip
orpythonusage within a site. Documentation will be updated
separately to show this usage.
Tested using the
pipcommand for installing, uninstalling, and listing
packages. Tested this with both a virtualenv install and a traditional
global install.Tested using the
pythoncommand as a shell, command runner (using-c),
and piping a script to it.
| Summary | ID |
|---|---|
| 9db18c49e0cafeece6cb544aca3d7bcf60ff8212 |
- Change Summary:
-
run_pipnow runs viapythonX.Y -m pip.- Added useful arguments and result checks for
run_python.
- Description:
-
This introduces two new special commands for
rb-site manage:pipand python. These are used to executepipandpython,respectively, using the correct version of the site. If the site is installed with an embedded
venvdirectory, theexecutable will be run from there, ensuring the command is executing within that virtual environment. If the site is a traditional globally-installed site, the versioned
~ pipX.YorpythonX.Ybinary for the current version of Python running~ rb-sitewill be used.~ pythonX.Ybinary for the current version of Python runningrb-site~ will be used. pipalways usespythonX.Y -m pip.The
pythoncommand is conceptually distinct fromshell, as it'smeant to be a raw pass-through to Python, rather than an interactive shell (Django has additional logic going into their shell and can execute ipythonorbpython).These are intentionally not implemented as management commands, in
order to minimize any Django-related code that needs to execute in order to work with packages or the Python interpreter. This will be the preferred way going forward for documenting any
pipor pythonusage within a site. Documentation will be updatedseparately to show this usage. - Commits:
-
Summary ID 52aab54f2a486ea2e91d4bdb66b6a2c8f4df6388 862b50a6f27756476ecff9ae396e1b8600f75d27 - Diff:
-
Revision 2 (+180 -8)
Checks run (2 succeeded)
- Change Summary:
-
Updated docs for
run_pipto discuss new behavior. - Commits:
-
Summary ID 862b50a6f27756476ecff9ae396e1b8600f75d27 9db18c49e0cafeece6cb544aca3d7bcf60ff8212 - Diff:
-
Revision 3 (+182 -8)