-
-
Notifications
You must be signed in to change notification settings - Fork 30.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
sys._base_executable may not exist on posix venvs made with --copies
#99204
Labels
type-bug
An unexpected behavior, bug, or error
Comments
vfazio
added a commit
to vfazio/cpython
that referenced
this issue
Nov 7, 2022
… venvs Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
vfazio
added a commit
to vfazio/cpython
that referenced
this issue
Nov 9, 2022
… venvs Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
vfazio
added a commit
to vfazio/cpython
that referenced
this issue
Nov 9, 2022
… venvs Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
vfazio
added a commit
to vfazio/cpython
that referenced
this issue
Nov 9, 2022
… venvs Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com>
zooba
pushed a commit
that referenced
this issue
Nov 10, 2022
…GH-99206) Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com> Signed-off-by: Vincent Fazio <vfazio@gmail.com>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Nov 10, 2022
… venvs (pythonGH-99206) Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com> (cherry picked from commit c41b13d) Co-authored-by: Vincent Fazio <vfazio@gmail.com> Signed-off-by: Vincent Fazio <vfazio@gmail.com>
miss-islington
added a commit
that referenced
this issue
Nov 10, 2022
…GH-99206) Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com> (cherry picked from commit c41b13d) Co-authored-by: Vincent Fazio <vfazio@gmail.com> Signed-off-by: Vincent Fazio <vfazio@gmail.com>
gvanrossum
pushed a commit
to gvanrossum/cpython
that referenced
this issue
Nov 10, 2022
… venvs (pythonGH-99206) Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com> Signed-off-by: Vincent Fazio <vfazio@gmail.com>
ethanfurman
pushed a commit
to ethanfurman/cpython
that referenced
this issue
Nov 12, 2022
… venvs (pythonGH-99206) Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com> Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
Python
venv
on POSIX environments creates a bin directory with:python
python{VERSION_MAJOR}
python(VERSION_MAJOR}.{VERSION_MINOR}
When executing
python
out of a venv made with the--copies
argument specified (that is, it doesn't use symlinks), the calculation ofbase_executable
will blindly append the basename of the executable to the value from thehome
key frompyvenv.cfg
, meaning base_executable = $home_dir/basename(executable)With recent changes made in 3.11, on Linux, the
home
key is determined by thebase_executable
of the initial python that created the venv. Even if the venv is "nested",home
will still point to the topmost non-venv python bin path.However, this can be problematic because source installations via
make install
only provide:python{VERSION_MAJOR}
python(VERSION_MAJOR}.{VERSION_MINOR}
This means if "python" is invoked from a venv, the resultant
base_executable
may be an invalid file that applications may be relying upon viasys._base_executable
(bothvenv
andvirtualenv
use this value)Most distributions do not distribute a version-less "python" as part of the divorce of python2 and python3 via guidance from PEP 394 (though some offer a convenience package to symlink it)
A suggested fix in previous discussions was to include a field in pyvenv.cfg specifying the base executable, but that may require updates to PEP 405 since there's only two documented keys for this file and other implementations such as
virtualenv
would want to conform to new specifications (virtualenv already stores a base-executable key so there could be a conflict)In lieu of that, a simple
stat
to check for alternatives seems reasonable without impacting startup performance overly much.Since this affects 3.11+, it'd be nice to see a fix backported to that branch.
Example:
Your environment
related discussion and MRs:
https://bugs.python.org/issue46028
#29041
#30144
related issues:
pypa/virtualenv#2440
python-poetry/poetry#6940
The text was updated successfully, but these errors were encountered: