Specify Python exec path with minor version if available (#3508)
Fixes #3507
This commit is contained in:
parent
b542f589a5
commit
bf5abdb0b6
@ -196,6 +196,7 @@ versions separately.
|
|||||||
- Move 3.11 CI to normal flow now that all dependencies support 3.11 (#3446)
|
- Move 3.11 CI to normal flow now that all dependencies support 3.11 (#3446)
|
||||||
- Docker: Add new `latest_prerelease` tag automation to follow latest black alpha
|
- Docker: Add new `latest_prerelease` tag automation to follow latest black alpha
|
||||||
release on docker images (#3465)
|
release on docker images (#3465)
|
||||||
|
- Fixed missing python binary path in autoload script for vim (#3508)
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ FLAGS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def _get_python_binary(exec_prefix):
|
def _get_python_binary(exec_prefix, pyver):
|
||||||
try:
|
try:
|
||||||
default = vim.eval("g:pymode_python").strip()
|
default = vim.eval("g:pymode_python").strip()
|
||||||
except vim.error:
|
except vim.error:
|
||||||
@ -43,7 +43,15 @@ def _get_python_binary(exec_prefix):
|
|||||||
return default
|
return default
|
||||||
if sys.platform[:3] == "win":
|
if sys.platform[:3] == "win":
|
||||||
return exec_prefix / 'python.exe'
|
return exec_prefix / 'python.exe'
|
||||||
return exec_prefix / 'bin' / 'python3'
|
bin_path = exec_prefix / "bin"
|
||||||
|
exec_path = (bin_path / f"python{pyver[0]}.{pyver[1]}").resolve()
|
||||||
|
if exec_path.exists():
|
||||||
|
return exec_path
|
||||||
|
# It is possible that some environments may only have python3
|
||||||
|
exec_path = (bin_path / f"python3").resolve()
|
||||||
|
if exec_path.exists():
|
||||||
|
return exec_path
|
||||||
|
raise ValueError("python executable not found")
|
||||||
|
|
||||||
def _get_pip(venv_path):
|
def _get_pip(venv_path):
|
||||||
if sys.platform[:3] == "win":
|
if sys.platform[:3] == "win":
|
||||||
@ -82,7 +90,7 @@ def _initialize_black_env(upgrade=False):
|
|||||||
_executable = sys.executable
|
_executable = sys.executable
|
||||||
_base_executable = getattr(sys, "_base_executable", _executable)
|
_base_executable = getattr(sys, "_base_executable", _executable)
|
||||||
try:
|
try:
|
||||||
executable = str(_get_python_binary(Path(sys.exec_prefix)))
|
executable = str(_get_python_binary(Path(sys.exec_prefix), pyver))
|
||||||
sys.executable = executable
|
sys.executable = executable
|
||||||
sys._base_executable = executable
|
sys._base_executable = executable
|
||||||
print(f'Creating a virtualenv in {virtualenv_path}...')
|
print(f'Creating a virtualenv in {virtualenv_path}...')
|
||||||
|
Loading…
Reference in New Issue
Block a user