Skip to content

Commit 2b29eb1

Browse files
committed
find windows binary path in python virtual environment
1 parent 387284e commit 2b29eb1

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

castervoice/lib/settings.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,22 @@ def _get_platform_information():
5050
import sysconfig
5151
system_information = {"platform": sysconfig.get_platform()}
5252
system_information.update({"python version": sys.version_info})
53+
binary_path = str(Path(sys.exec_prefix).joinpath(sys.exec_prefix).joinpath("bin"))
54+
hidden_console_binary = str(Path(sys.executable))
55+
main_binary = str(Path(sys.executable))
5356
if sys.platform == "win32":
54-
system_information.update({"binary path": sys.exec_prefix})
55-
system_information.update(
56-
{"main binary": str(Path(sys.exec_prefix).joinpath("python.exe"))})
57-
system_information.update(
58-
{"hidden console binary": str(Path(sys.exec_prefix).joinpath("pythonw.exe"))})
59-
else:
60-
system_information.update({"binary path": str(Path(sys.exec_prefix).joinpath(sys.exec_prefix).joinpath("bin"))})
61-
system_information.update(
62-
{"main binary": sys.executable})
63-
system_information.update(
64-
{"hidden console binary": sys.executable})
57+
if sys.prefix == sys.base_prefix:
58+
main_binary = str(Path(sys.exec_prefix).joinpath("python.exe"))
59+
hidden_console_binary = str(Path(sys.exec_prefix).joinpath("pythonw.exe"))
60+
else:
61+
# Virtual environment detected
62+
# TODO: MacOS and Linux?
63+
main_binary = str(Path(sys.prefix) / "Scripts" / "python.exe")
64+
hidden_console_binary = str(Path(sys.prefix) / "Scripts" / "pythonw.exe")
65+
system_information.update({"binary path": binary_path})
66+
system_information.update({"main binary": main_binary})
67+
system_information.update({"hidden console binary": hidden_console_binary})
68+
6569
return system_information
6670

6771

0 commit comments

Comments
 (0)