Skip to content

Commit 7fcd3c2

Browse files
committed
PythonKit: Better support for sys.executable in macOS
1 parent 41dd1e7 commit 7fcd3c2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

PythonKit/Python.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,14 +683,15 @@ public struct PythonInterface {
683683
import sys
684684
import os
685685
686-
# Some Python modules expect to have at least one argument in `sys.argv`.
686+
# Some Python modules expect to have at least one argument in `sys.argv`:
687687
sys.argv = [""]
688688
689689
# Some Python modules require `sys.executable` to return the path
690690
# to the Python interpreter executable. In Darwin, Python 3 returns the
691-
# main process executable path instead.
691+
# main process executable path instead:
692692
if sys.version_info.major == 3 and sys.platform == "darwin":
693-
sys.executable = os.path.join(sys.exec_prefix, "bin", "python3")
693+
executable_name = "python{}.{}".format(sys.version_info.major, sys.version_info.minor)
694+
sys.executable = os.path.join(sys.exec_prefix, "bin", executable_name)
694695
""")
695696
}
696697

0 commit comments

Comments
 (0)