Skip to content

Commit

Permalink
REFACTOR: Add possibility to specify python venv directory (#5633)
Browse files Browse the repository at this point in the history
Co-authored-by: ring630 <@gmail.com>
  • Loading branch information
hui-zhou-a authored Jan 9, 2025
1 parent 9754999 commit 59e48a4
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions doc/source/Resources/pyaedt_installer_from_aedt.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@


VENV_DIR_PREFIX = ".pyaedt_env"

"""
It is possible create Python virtual environment in a specific directory by setting variable VENV_DIR.
For example,
VENV_DIR = "e:/pyaedt_env"
"""
VENV_DIR = None
if not VENV_DIR:
if is_windows:
VENV_DIR = os.path.join(os.environ["APPDATA"], VENV_DIR_PREFIX)
else:
VENV_DIR = os.path.join(os.environ["HOME"], VENV_DIR_PREFIX)


DISCLAIMER = (
"This script will download and install certain third-party software and/or "
"open-source software (collectively, 'Third-Party Software'). Such Third-Party "
Expand Down Expand Up @@ -99,10 +113,10 @@ def run_pyinstaller_from_c_python(oDesktop):
# Add PyAEDT tabs in AEDT
# Virtual environment path and Python executable
if is_windows:
venv_dir = os.path.join(os.environ["APPDATA"], VENV_DIR_PREFIX, python_version_new)
venv_dir = os.path.join(VENV_DIR, python_version_new)
python_exe = os.path.join(venv_dir, "Scripts", "python.exe")
else:
venv_dir = os.path.join(os.environ["HOME"], VENV_DIR_PREFIX, python_version_new)
venv_dir = os.path.join(VENV_DIR, python_version_new)
python_exe = os.path.join(venv_dir, "bin", "python")
pyaedt_path = os.path.join(venv_dir, "Lib", "site-packages", "ansys", "aedt", "core")
if is_linux:
Expand Down Expand Up @@ -207,11 +221,11 @@ def install_pyaedt():
python_version = "3_7"

if is_windows:
venv_dir = Path(os.environ["APPDATA"], VENV_DIR_PREFIX, python_version)
venv_dir = Path(VENV_DIR, python_version)
python_exe = venv_dir / "Scripts" / "python.exe"
pip_exe = venv_dir / "Scripts" / "pip.exe"
else:
venv_dir = Path(os.environ["HOME"], VENV_DIR_PREFIX, python_version)
venv_dir = Path(VENV_DIR, python_version)
python_exe = venv_dir / "bin" / "python"
pip_exe = venv_dir / "bin" / "pip"
os.environ["ANSYSEM_ROOT{}".format(args.version)] = args.edt_root
Expand Down

0 comments on commit 59e48a4

Please sign in to comment.