]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Specify Python exec path with minor version if available (#3508)
authorIlia Lazarev <kephircheek@gmail.com>
Tue, 28 Mar 2023 04:12:24 +0000 (07:12 +0300)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 04:12:24 +0000 (21:12 -0700)
Fixes #3507

CHANGES.md
autoload/black.vim

index 47c04a7bc769a5ffb180b8eb2f51e01a003d2592..25710b1b2b0b59c2cd38e200d28611c101408e04 100644 (file)
@@ -196,6 +196,7 @@ versions separately.
 - 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
   release on docker images (#3465)
+- Fixed missing python binary path in autoload script for vim (#3508)
 
 ### Documentation
 
index c682d51e2b0af908aeb002a938e37be5863c320d..4eb9b25db28f9fe3308738fe42a19883b5373d52 100644 (file)
@@ -34,7 +34,7 @@ FLAGS = [
 ]
 
 
-def _get_python_binary(exec_prefix):
+def _get_python_binary(exec_prefix, pyver):
   try:
     default = vim.eval("g:pymode_python").strip()
   except vim.error:
@@ -43,7 +43,15 @@ def _get_python_binary(exec_prefix):
     return default
   if sys.platform[:3] == "win":
     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):
   if sys.platform[:3] == "win":
@@ -82,7 +90,7 @@ def _initialize_black_env(upgrade=False):
     _executable = sys.executable
     _base_executable = getattr(sys, "_base_executable", _executable)
     try:
-      executable = str(_get_python_binary(Path(sys.exec_prefix)))
+      executable = str(_get_python_binary(Path(sys.exec_prefix), pyver))
       sys.executable = executable
       sys._base_executable = executable
       print(f'Creating a virtualenv in {virtualenv_path}...')