Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/issue_5485' into fix/issue_5485
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzovecchietti committed Dec 24, 2024
2 parents 094f810 + 12f3443 commit 8c6e0a3
Show file tree
Hide file tree
Showing 119 changed files with 72,770 additions and 214,915 deletions.
2 changes: 1 addition & 1 deletion doc/source/Getting_started/ClientServer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In AEDT 2022 R2 and later, PyAEDT fully supports the gRPC API (except for EDB):
# Launch the latest installed version of AEDT in graphical mode.
from ansys.aedt.core import Hfss
from ansys.aedt.core import settings
from ansys.aedt.core.generic.settings import settings
settings.use_grpc_api=True
hfss = Hfss(machine="fullmachinename", port=portnumber)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/Getting_started/versioning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This interface works only on Windows and uses .NET COM objects.
.. code:: python
from ansys.aedt.core import settings
from ansys.aedt.core.generic.settings import settings
settings.use_grpc_api = False
Expand Down
143 changes: 71 additions & 72 deletions doc/source/Resources/pyaedt_installer_from_aedt.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def run_pyinstaller_from_c_python(oDesktop):
if is_student_version(oDesktop):
command.append("--student")
if is_linux:
command.extend(['--edt_root="{}"'.format(edt_root), '--python_version="{}"'.format(python_version)])
command.extend([r'--edt_root={}'.format(edt_root), '--python_version="{}"'.format(python_version)])

if wheelpyaedt:
command.extend(['--wheel="{}"'.format(wheelpyaedt)])
command.extend([r'--wheel={}'.format(wheelpyaedt)])

oDesktop.AddMessage("", "", 0, "Installing PyAEDT.")
return_code = subprocess.call(command)
Expand Down Expand Up @@ -179,8 +179,26 @@ def parse_arguments_for_pyaedt_installer(args=None):
parser.error("No arguments given!")
return args

def unzip_if_zip(path):
"""Unzip path if it is a ZIP file."""
import zipfile

# Extracted folder
unzipped_path = path
if path.suffix == '.zip':
unzipped_path = path.parent / path.stem
if unzipped_path.exists():
shutil.rmtree(unzipped_path, ignore_errors=True)
with zipfile.ZipFile(path, "r") as zip_ref:
# Extract all contents to a directory. (You can specify a different extraction path if needed.)
zip_ref.extractall(unzipped_path)
return unzipped_path


def install_pyaedt():
"""Install PyAEDT in CPython."""
from pathlib import Path

# This is called when run from CPython
args = parse_arguments_for_pyaedt_installer()

Expand All @@ -189,136 +207,117 @@ def install_pyaedt():
python_version = "3_7"

if is_windows:
venv_dir = os.path.join(os.environ["APPDATA"], VENV_DIR_PREFIX, python_version)
python_exe = os.path.join(venv_dir, "Scripts", "python.exe")
pip_exe = os.path.join(venv_dir, "Scripts", "pip.exe")
venv_dir = Path(os.environ["APPDATA"], VENV_DIR_PREFIX, python_version)
python_exe = venv_dir / "Scripts" / "python.exe"
pip_exe = venv_dir / "Scripts" / "pip.exe"
else:
venv_dir = os.path.join(os.environ["HOME"], VENV_DIR_PREFIX, python_version)
python_exe = os.path.join(venv_dir, "bin", "python")
pip_exe = os.path.join(venv_dir, "bin", "pip")
venv_dir = Path(os.environ["HOME"], VENV_DIR_PREFIX, python_version)
python_exe = venv_dir / "bin" / "python"
pip_exe = venv_dir / "bin" / "pip"
os.environ["ANSYSEM_ROOT{}".format(args.version)] = args.edt_root
ld_library_path_dirs_to_add = [
"{}/commonfiles/CPython/{}/linx64/Release/python/lib".format(
r"{}/commonfiles/CPython/{}/linx64/Release/python/lib".format(
args.edt_root, args.python_version.replace(".", "_")
),
"{}/common/mono/Linux64/lib64".format(args.edt_root),
"{}".format(args.edt_root),
r"{}/common/mono/Linux64/lib64".format(args.edt_root),
r"{}".format(args.edt_root),
]
if args.version < "232":
ld_library_path_dirs_to_add.append("{}/Delcross".format(args.edt_root))
ld_library_path_dirs_to_add.append(r"{}/Delcross".format(args.edt_root))
os.environ["LD_LIBRARY_PATH"] = ":".join(ld_library_path_dirs_to_add) + ":" + os.getenv("LD_LIBRARY_PATH", "")
os.environ["TK_LIBRARY"] = "{}/commonfiles/CPython/{}/linx64/Release/python/lib/tk8.5".format(
os.environ["TK_LIBRARY"] = r"{}/commonfiles/CPython/{}/linx64/Release/python/lib/tk8.5".format(
args.edt_root, args.python_version.replace(".", "_")
)
os.environ["TCL_LIBRARY"] = "{}/commonfiles/CPython/{}/linx64/Release/python/lib/tcl8.5".format(
os.environ["TCL_LIBRARY"] = r"{}/commonfiles/CPython/{}/linx64/Release/python/lib/tcl8.5".format(
args.edt_root, args.python_version.replace(".", "_")
)

if not os.path.exists(venv_dir):

if args.version == "231":
subprocess.call([sys.executable, "-m", "venv", venv_dir, "--system-site-packages"])
if not venv_dir.exists():
print("Creating the virtual environment in {}".format(venv_dir))
if args.version <= "231":
subprocess.call([sys.executable, "-m", "venv", str(venv_dir), "--system-site-packages"])
else:
subprocess.call([sys.executable, "-m", "venv", venv_dir])
subprocess.call([sys.executable, "-m", "venv", str(venv_dir)])

if args.wheel and os.path.exists(args.wheel):
wheel_pyaedt = args.wheel
if wheel_pyaedt.endswith(".zip"):
import zipfile

unzipped_path = os.path.join(
os.path.dirname(wheel_pyaedt), os.path.splitext(os.path.basename(wheel_pyaedt))[0]
)
if os.path.exists(unzipped_path):
shutil.rmtree(unzipped_path, ignore_errors=True)
with zipfile.ZipFile(wheel_pyaedt, "r") as zip_ref:
# Extract all contents to a directory. (You can specify a different extraction path if needed.)
zip_ref.extractall(unzipped_path)
else:
# Extracted folder.
unzipped_path = wheel_pyaedt
if args.wheel and Path(args.wheel).exists():
print("Installing PyAEDT using provided wheels argument")
unzipped_path = unzip_if_zip(Path(args.wheel))
if args.version <= "231":
subprocess.call(
[
pip_exe,
str(pip_exe),
"install",
"--no-cache-dir",
"--no-index",
"--find-links={}".format(unzipped_path),
"pyaedt[all,dotnet]",
r"--find-links={}".format(str(unzipped_path)),
"pyaedt[all,dotnet]=='0.9.0'",
]
)
else:
subprocess.call(
[
pip_exe,
str(pip_exe),
"install",
"--no-cache-dir",
"--no-index",
"--find-links={}".format(unzipped_path),
r"--find-links={}".format(str(unzipped_path)),
"pyaedt[installer]",
]
)

else:
subprocess.call([python_exe, "-m", "pip", "install", "--upgrade", "pip"])
subprocess.call([pip_exe, "--default-timeout=1000", "install", "wheel"])
print("Installing PyAEDT using online sources")
subprocess.call([str(python_exe), "-m", "pip", "install", "--upgrade", "pip"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "wheel"])
if args.version <= "231":
subprocess.call([pip_exe, "--default-timeout=1000", "install", "pyaedt[all]=='0.9.0'"])
subprocess.call([pip_exe, "--default-timeout=1000", "install", "jupyterlab"])
subprocess.call([pip_exe, "--default-timeout=1000", "install", "ipython", "-U"])
subprocess.call([pip_exe, "--default-timeout=1000", "install", "ipyvtklink"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "pyaedt[all]=='0.9.0'"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "jupyterlab"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "ipython", "-U"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "ipyvtklink"])
else:
subprocess.call([pip_exe, "--default-timeout=1000", "install", "pyaedt[installer]"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "pyaedt[installer]"])

if args.version == "231":
subprocess.call([pip_exe, "uninstall", "-y", "pywin32"])
if args.version <= "231":
subprocess.call([str(pip_exe), "uninstall", "-y", "pywin32"])

else:
subprocess.call([pip_exe, "uninstall", "-y", "pyaedt"])
print("Using existing virtual environment in {}".format(venv_dir))
subprocess.call([str(pip_exe), "uninstall", "-y", "pyaedt"])

if args.wheel and os.path.exists(args.wheel):
wheel_pyaedt = args.wheel
import zipfile

unzipped_path = os.path.join(
os.path.dirname(wheel_pyaedt), os.path.splitext(os.path.basename(wheel_pyaedt))[0]
)
if os.path.exists(unzipped_path):
shutil.rmtree(unzipped_path, ignore_errors=True)
with zipfile.ZipFile(wheel_pyaedt, "r") as zip_ref:
# Extract all contents to a directory. (You can specify a different extraction path if needed.)
zip_ref.extractall(unzipped_path)
if args.wheel and Path(args.wheel).exists():
print("Installing PyAEDT using provided wheels argument")
unzipped_path = unzip_if_zip(Path(args.wheel))
if args.version <= "231":
subprocess.call(
[
pip_exe,
str(pip_exe),
"install",
"--no-cache-dir",
"--no-index",
"--find-links={}".format(unzipped_path),
"pyaedt[all]=='0.9.0'",
r"--find-links={}".format(str(unzipped_path)),
"pyaedt[all,dotnet]=='0.9.0'",
]
)
else:
subprocess.call(
[
pip_exe,
str(pip_exe),
"install",
"--no-cache-dir",
"--no-index",
"--find-links={}".format(unzipped_path),
r"--find-links={}".format(str(unzipped_path)),
"pyaedt[installer]",
]
)
else:
print("Installing PyAEDT using online sources")
if args.version <= "231":
subprocess.call([pip_exe, "--default-timeout=1000", "install", "pyaedt[all]=='0.9.0'"])
subprocess.call([pip_exe, "--default-timeout=1000", "install", "jupyterlab"])
subprocess.call([pip_exe, "--default-timeout=1000", "install", "ipython", "-U"])
subprocess.call([pip_exe, "--default-timeout=1000", "install", "ipyvtklink"])
subprocess.call([str(pip_exe), "pip=1000", "install", "pyaedt[all]=='0.9.0'"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "jupyterlab"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "ipython", "-U"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "ipyvtklink"])
else:
subprocess.call([pip_exe, "--default-timeout=1000", "install", "pyaedt[installer]"])
subprocess.call([str(pip_exe), "--default-timeout=1000", "install", "pyaedt[installer]"])
sys.exit(0)


Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def deprecation_warning():

# Define and use custom showwarning
def custom_show_warning(message, category, filename, lineno, file=None, line=None):
"""Custom warning used to remove <stdin>:loc: pattern."""
"""Define and use custom warning to remove <stdin>:loc: pattern."""
print(f"{category.__name__}: {message}")

warnings.showwarning = custom_show_warning
Expand Down
18 changes: 0 additions & 18 deletions src/ansys/aedt/core/application/aedt_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def oradfield(self):
References
----------
>>> oDesign.GetModule("RadField")
"""
if self.design_type == "HFSS" and self._odesign.GetSolutionType() not in ["EigenMode", "Characteristic Mode"]:
Expand All @@ -111,7 +110,6 @@ def o_symbol_manager(self):
References
----------
>>> oSymbolManager = oDefinitionManager.GetManager("Symbol")
"""
if self.odefinition_manager:
Expand All @@ -124,7 +122,6 @@ def opadstackmanager(self):
References
----------
>>> oPadstackManger = oDefinitionManager.GetManager("Padstack")
"""
if self._oproject and not self._opadstackmanager:
Expand Down Expand Up @@ -153,7 +150,6 @@ def oimport_export(self):
References
----------
>>> oDesktop.GetTool("ImportExport")
"""
if not self._oimport_export:
Expand All @@ -166,7 +162,6 @@ def ooptimetrics(self):
References
----------
>>> oDesign.GetModule("Optimetrics")
"""
if not self._ooptimetrics and self.design_type not in ["Circuit Netlist", "Maxwell Circuit", "EMIT"]:
Expand All @@ -179,7 +174,6 @@ def ooutput_variable(self):
References
----------
>>> oDesign.GetModule("OutputVariable")
"""
if not self._ooutput_variable and self.design_type not in ["EMIT", "Maxwell Circuit", "Circuit Netlist"]:
Expand All @@ -192,7 +186,6 @@ def oanalysis(self):
References
----------
>>> oDesign.GetModule("SolveSetups")
>>> oDesign.GetModule("SimSetup")
>>> oDesign.GetModule("AnalysisSetup")
Expand All @@ -215,7 +208,6 @@ def odefinition_manager(self):
References
----------
>>> oDefinitionManager = oProject.GetDefinitionManager()
"""
if not self._odefinition_manager and self._oproject:
Expand All @@ -228,7 +220,6 @@ def omaterial_manager(self):
References
----------
>>> oMaterialManager = oDefinitionManager.GetManager("Material")
"""
if self.odefinition_manager and not self._omaterial_manager:
Expand All @@ -241,7 +232,6 @@ def omodelsetup(self):
References
----------
>>> oDesign.GetModule("ModelSetup")
"""
if self.design_type not in ["Maxwell 3D", "Maxwell 2D", "HFSS"]:
Expand All @@ -261,7 +251,6 @@ def o_maxwell_parameters(self):
References
----------
>>> oDesign.GetModule("MaxwellParameterSetup")
"""
if self._odesign and self.design_type not in ["Maxwell 3D", "Maxwell 2D"]:
Expand All @@ -285,7 +274,6 @@ def osolution(self):
References
----------
>>> oModule = oDesign.GetModule("Solutions")
"""
if not self._osolution:
Expand All @@ -310,7 +298,6 @@ def oexcitation(self):
References
----------
>>> oModule = oDesign.GetModule("Excitations")
"""
if self.design_type not in ["HFSS3DLayout", "HFSS 3D Layout Design"]:
Expand Down Expand Up @@ -339,7 +326,6 @@ def ofieldsreporter(self):
References
----------
>>> oDesign.GetModule("FieldsReporter")
"""
if self.design_type in [
Expand All @@ -366,7 +352,6 @@ def oreportsetup(self):
References
----------
>>> oDesign.GetModule("ReportSetup")
"""
if not self._oreportsetup:
Expand All @@ -379,7 +364,6 @@ def omeshmodule(self):
References
----------
>>> oDesign.GetModule("MeshRegion")
"""
meshers = {
Expand All @@ -403,7 +387,6 @@ def oeditor(self):
References
----------
>>> oEditor = oDesign.SetActiveEditor("SchematicEditor")"""
if not self._oeditor and self._odesign:
if self.design_type in ["Circuit Design", "Twin Builder", "Maxwell Circuit", "EMIT"]:
Expand All @@ -427,7 +410,6 @@ def layouteditor(self):
References
----------
>>> oDesign.SetActiveEditor("Layout")
"""
if not self._layouteditor and self.design_type in ["Circuit Design"]:
Expand Down
Loading

0 comments on commit 8c6e0a3

Please sign in to comment.