Skip to content

Commit

Permalink
FIX: PyAEDT installer compatible from 2022R2 (#5159)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys authored Sep 11, 2024
1 parent 3f78101 commit 1db57ef
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 29 deletions.
5 changes: 3 additions & 2 deletions _unittest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ def desktop():
d = Desktop(desktop_version, NONGRAPHICAL, new_thread)
d.odesktop.SetTempDirectory(tempfile.gettempdir())
d.disable_autosave()
d.odesktop.SetDesktopConfiguration("All")
d.odesktop.SetSchematicEnvironment(0)
if desktop_version > "2022.2":
d.odesktop.SetDesktopConfiguration("All")
d.odesktop.SetSchematicEnvironment(0)
yield d
d.release_desktop(True, True)
time.sleep(1)
Expand Down
1 change: 1 addition & 0 deletions _unittest/test_01_3dlayout_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,5 +415,6 @@ def test_23_dissolve_element(self):
assert self.aedtapp.create_ports_on_component_by_nets(comp.name, nets)
assert self.aedtapp.create_pec_on_component_by_nets(comp.name, "GND")

@pytest.mark.skipif(config["desktopVersion"] <= "2024.1", reason="Introduced in 2024R1")
def test_24_open_ic_mode_design(self):
assert self.ic_mode_design.ic_mode
2 changes: 1 addition & 1 deletion _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def test_33_aedt_object(self):

def test_34_force_project_path_disable(self):
settings.force_error_on_missing_project = True
assert settings.force_error_on_missing_project == True
assert settings.force_error_on_missing_project
e = None
exception_raised = False
try:
Expand Down
15 changes: 12 additions & 3 deletions _unittest/test_02_3D_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ def test_18_chamfer(self):
o1 = self.aedtapp.modeler["box_to_split"]
assert abs(o1.volume - 4000.0) / 4000.0 < small_number
assert o1.top_edge_x.chamfer(1)
assert abs(o1.volume - 3990.0) / 3990.0 < small_number # Volume decreased
if config["desktopVersion"] == "2022.2":
assert abs(o1.volume - 3995.0) / 3995.0 < small_number # Volume decreased
else:
assert abs(o1.volume - 3990.0) / 3990.0 < small_number # Volume decreased

def test_19_clone(self):
self.restore_model()
Expand Down Expand Up @@ -521,7 +524,10 @@ def test_40b_create_object_coordinate_system(self):
assert cs
assert cs.name == "obj_cs"
assert cs.entity_id == box.id
assert cs.ref_cs == "Global"
if config["desktopVersion"] == "2022.2":
assert not cs.ref_cs
else:
assert cs.ref_cs == "Global"
cs.props["MoveToEnd"] = False
assert not cs.props["MoveToEnd"]
cs.props["yAxis"]["xDirection"] = 1
Expand All @@ -535,7 +541,10 @@ def test_40b_create_object_coordinate_system(self):
assert cs
assert cs.name == "obj_cs"
assert cs.entity_id == box.id
assert cs.ref_cs == "Global"
if config["desktopVersion"] == "2022.2":
assert not cs.ref_cs
else:
assert cs.ref_cs == "Global"
cs.props["MoveToEnd"] = False
assert not cs.props["MoveToEnd"]
cs.props["xAxis"]["xDirection"] = 1
Expand Down
20 changes: 13 additions & 7 deletions doc/source/Resources/pyaedt_installer_from_aedt.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ def run_pyinstaller_from_c_python(oDesktop):
# enable in debug mode
# f.write("import sys\n")
# f.write('sys.path.insert(0, r"c:\\ansysdev\\git\\repos\\pyaedt")\n')
f.write("from ansys.aedt.core.workflows.installer.pyaedt_installer import add_pyaedt_to_aedt\n")
f.write(
'add_pyaedt_to_aedt(aedt_version="{}", personal_lib=r"{}")\n'.format(
oDesktop.GetVersion()[:6], oDesktop.GetPersonalLibDirectory()))
if version <= "231":
f.write("from pyaedt.workflows.installer.pyaedt_installer import add_pyaedt_to_aedt\n")
f.write(
'add_pyaedt_to_aedt(aedt_version="{}", personallib=r"{}")\n'.format(
oDesktop.GetVersion()[:6], oDesktop.GetPersonalLibDirectory()))
else:
f.write("from ansys.aedt.core.workflows.installer.pyaedt_installer import add_pyaedt_to_aedt\n")
f.write(
'add_pyaedt_to_aedt(aedt_version="{}", personal_lib=r"{}")\n'.format(
oDesktop.GetVersion()[:6], oDesktop.GetPersonalLibDirectory()))

command = r'"{}" "{}"'.format(python_exe, python_script)
oDesktop.AddMessage("", "", 0, "Configuring PyAEDT panels in automation tab.")
Expand Down Expand Up @@ -198,7 +204,7 @@ def install_pyaedt():
# run_command(
# '"{}" --default-timeout=1000 install git+https://github.com/ansys/pyaedt.git@main'.format(pip_exe))
if args.version <= "231":
run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.3"'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.0"'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install jupyterlab'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install ipython -U'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install ipyvtklink'.format(pip_exe))
Expand All @@ -222,14 +228,14 @@ def install_pyaedt():
# Extract all contents to a directory. (You can specify a different extraction path if needed.)
zip_ref.extractall(unzipped_path)
if args.version <= "231":
run_command('"{}" install --no-cache-dir --no-index --find-links={} pyaedt[all]=="0.9.3"'.format(pip_exe,
run_command('"{}" install --no-cache-dir --no-index --find-links={} pyaedt[all]=="0.9.0"'.format(pip_exe,
unzipped_path))
else:
run_command('"{}" install --no-cache-dir --no-index --find-links={} pyaedt[installer]'.format(pip_exe,
unzipped_path))
else:
if args.version <= "231":
run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.3"'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install pyaedt[all]=="0.9.0"'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install jupyterlab'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install ipython -U'.format(pip_exe))
run_command('"{}" --default-timeout=1000 install ipyvtklink'.format(pip_exe))
Expand Down
27 changes: 16 additions & 11 deletions src/ansys/aedt/core/workflows/installer/console_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,31 @@
import os
import sys

aedt_process_id = int(sys.argv[1])
version = sys.argv[2]
print("Loading the PyAEDT Console.")

try:
import ansys.aedt.core
if version <= "2023.1":
import pyaedt
else:
import ansys.aedt.core as pyaedt
except ImportError:
# Debug only purpose. If the tool is added to the ribbon from a GitHub clone, then a link
# to PyAEDT is created in the personal library.
console_setup_dir = os.path.dirname(__file__)
if "PersonalLib" in console_setup_dir:
sys.path.append(os.path.join(console_setup_dir, "../..", "..", ".."))
import ansys.aedt.core

if version <= "2023.1":
import pyaedt
else:
import ansys.aedt.core as pyaedt

# ansys.aedt.core.settings.use_grpc_api = False
settings = ansys.aedt.core.settings
from ansys.aedt.core import Desktop
from ansys.aedt.core.generic.general_methods import active_sessions
from ansys.aedt.core.generic.general_methods import is_windows

aedt_process_id = int(sys.argv[1])
version = sys.argv[2]
print("Loading the PyAEDT Console.")
settings = pyaedt.settings
from pyaedt import Desktop
from pyaedt.generic.general_methods import active_sessions
from pyaedt.generic.general_methods import is_windows


def release(d):
Expand Down
24 changes: 20 additions & 4 deletions src/ansys/aedt/core/workflows/installer/jupyter_template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
"outputs": [],
"source": [
"import sys\n",
"import atexit\n",
"from ansys.aedt.core import *\n",
"import ansys.aedt.core\n",
"ansys.aedt.core.settings.use_grpc_api=False"
"import atexit"
]
},
{
Expand All @@ -34,6 +31,25 @@
"print(\"Loading the PyAEDT Console.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"if version > \"2023.1\":\n",
" from ansys.aedt.core import *\n",
" import ansys.aedt.core\n",
" ansys.aedt.core.settings.use_grpc_api=False\n",
"else:\n",
" from pyaedt import *\n",
" import pyaedt\n",
" pyaedt.settings.use_grpc_api=False"
],
"metadata": {
"collapsed": false
},
"id": "6232be8729ad9638"
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
2 changes: 1 addition & 1 deletion src/pyaedt/workflows/installer/pyaedt_installer.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from ansys.aedt.core.workflows.installeraedt_installer import *
from ansys.aedt.core.workflows.installer.pyaedt_installer import *

0 comments on commit 1db57ef

Please sign in to comment.