Skip to content

Commit

Permalink
find windows binary path in python virtual environment
Browse files Browse the repository at this point in the history
  • Loading branch information
LexiconCode committed Jul 14, 2024
1 parent 0901806 commit e89cbaf
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions castervoice/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,22 @@ def _get_platform_information():
import sysconfig
system_information = {"platform": sysconfig.get_platform()}
system_information.update({"python version": sys.version_info})
binary_path = str(Path(sys.exec_prefix).joinpath(sys.exec_prefix).joinpath("bin"))
hidden_console_binary = str(Path(sys.executable))
main_binary = str(Path(sys.executable))
if sys.platform == "win32":
system_information.update({"binary path": sys.exec_prefix})
system_information.update(
{"main binary": str(Path(sys.exec_prefix).joinpath("python.exe"))})
system_information.update(
{"hidden console binary": str(Path(sys.exec_prefix).joinpath("pythonw.exe"))})
else:
system_information.update({"binary path": str(Path(sys.exec_prefix).joinpath(sys.exec_prefix).joinpath("bin"))})
system_information.update(
{"main binary": sys.executable})
system_information.update(
{"hidden console binary": sys.executable})
if sys.prefix == sys.base_prefix:
main_binary = str(Path(sys.exec_prefix).joinpath("python.exe"))
hidden_console_binary = str(Path(sys.exec_prefix).joinpath("pythonw.exe"))
else:
# Virtual environment detected
# TODO: MacOS and Linux?
main_binary = str(Path(sys.prefix) / "Scripts" / "python.exe")
hidden_console_binary = str(Path(sys.prefix) / "Scripts" / "pythonw.exe")
system_information.update({"binary path": binary_path})
system_information.update({"main binary": main_binary})
system_information.update({"hidden console binary": hidden_console_binary})

return system_information


Expand Down

0 comments on commit e89cbaf

Please sign in to comment.