Skip to content

FIX: fixed add_pyaedt_to_aedt #6189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/6189.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixed add_pyaedt_to_aedt
27 changes: 20 additions & 7 deletions doc/source/Getting_started/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,21 @@ Finally, in the Python console, run the following commands:
.. code::

from ansys.aedt.core.extensions.installer.pyaedt_installer import add_pyaedt_to_aedt
add_pyaedt_to_aedt(“your_aedt_version", r“path_to_personalib")
add_pyaedt_to_aedt(“your_aedt_version", r“path_to_aedtlib")

You can also install the PyAEDT panels using the following steps, this is also useful if you have a centralized PyAEDT installation:
- Replace "your_aedt_version" with the version of AEDT you are using (for example, "2025.1").
- Replace "path_to_aedtlib" with the full path of your PersonalLib or syslib as specified in AEDT.
- If you use your PersonalLib, the PyAEDT icons are installed at user level in the AEDT ribbon.
- If you use the syslib, the PyAEDT icons are installed at application level in the AEDT ribbon.
- You can skip the installation of the version manager by specifying the extra argument skip_version_manager=True:

- Download the following file: :download:`PyAEDT panel Installer Python file <../Resources/toolkit_installer_from_aedt.py>`
.. code::

- Define an environment variable called `PYAEDT_INTERPRETER` with the path of the Python interpreter in which PyAEDT is installed.
add_pyaedt_to_aedt(“your_aedt_version", r“path_to_aedtlib", skip_version_manager=True)

- Open an Electronics Desktop Session and click on Tools->Run Script and execute the file. You do not need the previous step if
you pass as an argument the path of the Python interpreter.
.. note::
If you created your own virtual environment and you are managing a centralized installation of pyAEDT,
it is better to do not install the version manager.


Linux support
Expand Down Expand Up @@ -187,7 +192,15 @@ Finally, in the Python console, run the following commands:
.. code::

from ansys.aedt.core.extensions.installer.pyaedt_installer import add_pyaedt_to_aedt
add_pyaedt_to_aedt(“your_aedt_version", r“path_to_personalib")
add_pyaedt_to_aedt(“your_aedt_version", r“path_to_aedtlib")

- Replace "your_aedt_version" with the version of AEDT you are using (for example, "2025.1").
- Replace "path_to_aedtlib" with the full path of your PersonalLib or syslib as specified in AEDT, depending if you want to install the PyAEDT icons at user level or application level.
- You can skip the installation of the version manager by specifying the extra argument skip_version_manager=True:

.. code::

add_pyaedt_to_aedt(“your_aedt_version", r“path_to_aedtlib", skip_version_manager=True)


Install PyAEDT in Conda virtual environment
Expand Down
112 changes: 0 additions & 112 deletions doc/source/Resources/toolkit_installer_from_aedt.py

This file was deleted.

4 changes: 3 additions & 1 deletion doc/styles/config/vocabularies/ANSYS/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ padstack
padstacks
parametrics
PDF
[Pp]ersonal[Ll]ib
PMs
[Pp]olyline
polylines
Expand Down Expand Up @@ -95,6 +96,7 @@ Stackup 3D
stackups
stripline
subcircuit
[Ss]ys[Ll]ib
[Tt]oolkits
[Tt]oolkit [Mm]anager
Twin Builder
Expand All @@ -116,4 +118,4 @@ i.e.
solderballs
pin_mapping
refdes
gnd
gnd
5 changes: 3 additions & 2 deletions src/ansys/aedt/core/extensions/customize_automation_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import logging
import os
import re
import shutil
import subprocess # nosec
import sys
Expand Down Expand Up @@ -317,8 +318,8 @@

templates_dir = os.path.dirname(ansys.aedt.core.extensions.templates.__file__)

ipython_executable = executable_version_agnostic.replace("python" + __exe(), "ipython" + __exe())
jupyter_executable = executable_version_agnostic.replace("python" + __exe(), "jupyter" + __exe())
ipython_executable = re.sub(r"python" + __exe() + r"$", "ipython" + __exe(), executable_version_agnostic)
jupyter_executable = re.sub(r"python" + __exe() + r"$", "jupyter" + __exe(), executable_version_agnostic)

Check warning on line 322 in src/ansys/aedt/core/extensions/customize_automation_tab.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/extensions/customize_automation_tab.py#L321-L322

Added lines #L321 - L322 were not covered by tests

with open(os.path.join(templates_dir, template_file + ".py_build"), "r") as build_file:
with open(os.path.join(tool_dir, template_file + ".py"), "w") as out_file:
Expand Down
12 changes: 9 additions & 3 deletions src/ansys/aedt/core/extensions/installer/pyaedt_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
def add_pyaedt_to_aedt(
aedt_version,
personal_lib,
skip_version_manager=False,
):
"""Add PyAEDT tabs in AEDT.

Expand All @@ -43,6 +44,8 @@ def add_pyaedt_to_aedt(
AEDT release.
personal_lib : str
AEDT personal library folder.
skip_version_manager : bool, optional
Skip the version manager tab. The default is ``False``.
"""
logger = logging.getLogger("Global")
if not personal_lib or not aedt_version:
Expand All @@ -58,12 +61,15 @@ def add_pyaedt_to_aedt(
extensions_dir = os.path.join(personal_lib, "Toolkits")
os.makedirs(extensions_dir, exist_ok=True)

__add_pyaedt_tabs(personal_lib, aedt_version)
__add_pyaedt_tabs(personal_lib, aedt_version, skip_version_manager)


def __add_pyaedt_tabs(personal_lib, aedt_version):
def __add_pyaedt_tabs(personal_lib, aedt_version, skip_version_manager):
"""Add PyAEDT tabs in AEDT."""
pyaedt_tabs = ["Console", "Jupyter", "Run_Script", "ExtensionManager", "VersionManager"]
if skip_version_manager:
pyaedt_tabs = ["Console", "Jupyter", "Run_Script", "ExtensionManager"]
else:
pyaedt_tabs = ["Console", "Jupyter", "Run_Script", "ExtensionManager", "VersionManager"]

extensions_catalog = read_toml(os.path.join(os.path.dirname(__file__), "extensions_catalog.toml"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,17 @@ def main():
pyaedt_utils.environment_variables(oDesktop)
# Call console script
if is_linux:
term = pyaedt_utils.get_linux_terminal()
if not term:
pyaedt_utils.show_error("No Terminals found.", oDesktop)
command = pyaedt_utils.get_linux_terminal_command()
if not command:
pyaedt_utils.show_error("No terminal found on system.", oDesktop)
pyaedt_utils.set_ansys_em_environment(oDesktop)
command = [
term,
"-e",
command.extend([
python_exe,
"-i",
pyaedt_script,
str(oDesktop.GetProcessID()),
str(oDesktop.GetVersion()[:6]),
]
])
subprocess.Popen(command)
else:
command = [
Expand Down
26 changes: 21 additions & 5 deletions src/ansys/aedt/core/extensions/templates/pyaedt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,27 @@ def check_file(file_path, oDesktop):
def get_linux_terminal():
"""Get a Linux terminal."""
for terminal in ["x-terminal-emulator", "xterm", "gnome-terminal", "lxterminal", "mlterm"]:
term = which(terminal)
if term:
return term
return None
terminal_exe = which(terminal)
if terminal_exe:
return terminal, terminal_exe
return None, None


def get_linux_terminal_command():
"""Get the command to open a Linux terminal."""
terminal, terminal_exe = get_linux_terminal()
if terminal == "x-terminal-emulator":
return [terminal_exe, "-e"]
elif terminal == "xterm":
return [terminal_exe, "-e"]
elif terminal == "gnome-terminal":
return [terminal_exe, "--"]
elif terminal == "lxterminal":
return [terminal_exe, "--command"]
elif terminal == "mlterm":
return [terminal_exe, "-e"]
else:
return None


def which(program):
Expand All @@ -92,7 +109,6 @@ def is_exe(fpath):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file

return None


Expand Down