From 55dde3f0d164ce5541aefe9f30b06e9300eef303 Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Fri, 28 Nov 2025 17:42:00 +0100 Subject: [PATCH 1/4] Update copyright notices --- src/ansys/aedt/core/extensions/templates/jupyter.py_build | 4 +++- .../aedt/core/extensions/templates/pyaedt_console.py_build | 4 +++- .../core/extensions/templates/run_extension_manager.py_build | 4 +++- .../aedt/core/extensions/templates/run_pyaedt_script.py_build | 4 +++- .../extensions/templates/run_pyaedt_toolkit_script.py_build | 4 +++- src/pyaedt/workflows/templates/jupyter.py_build | 4 +++- src/pyaedt/workflows/templates/pyaedt_console.py_build | 4 +++- src/pyaedt/workflows/templates/run_extension_manager.py_build | 4 +++- src/pyaedt/workflows/templates/run_pyaedt_script.py_build | 4 +++- .../workflows/templates/run_pyaedt_toolkit_script.py_build | 4 +++- .../workflows/templates/run_pyedb_toolkit_script.py_build | 4 +++- 11 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/ansys/aedt/core/extensions/templates/jupyter.py_build b/src/ansys/aedt/core/extensions/templates/jupyter.py_build index c825279499d..b67e375254e 100644 --- a/src/ansys/aedt/core/extensions/templates/jupyter.py_build +++ b/src/ansys/aedt/core/extensions/templates/jupyter.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/ansys/aedt/core/extensions/templates/pyaedt_console.py_build b/src/ansys/aedt/core/extensions/templates/pyaedt_console.py_build index 2a19a714c72..57ab1eadd54 100644 --- a/src/ansys/aedt/core/extensions/templates/pyaedt_console.py_build +++ b/src/ansys/aedt/core/extensions/templates/pyaedt_console.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/ansys/aedt/core/extensions/templates/run_extension_manager.py_build b/src/ansys/aedt/core/extensions/templates/run_extension_manager.py_build index c4286c2d918..7c80de3e142 100644 --- a/src/ansys/aedt/core/extensions/templates/run_extension_manager.py_build +++ b/src/ansys/aedt/core/extensions/templates/run_extension_manager.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/ansys/aedt/core/extensions/templates/run_pyaedt_script.py_build b/src/ansys/aedt/core/extensions/templates/run_pyaedt_script.py_build index 0c7d42510ef..10f67c2f445 100644 --- a/src/ansys/aedt/core/extensions/templates/run_pyaedt_script.py_build +++ b/src/ansys/aedt/core/extensions/templates/run_pyaedt_script.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/ansys/aedt/core/extensions/templates/run_pyaedt_toolkit_script.py_build b/src/ansys/aedt/core/extensions/templates/run_pyaedt_toolkit_script.py_build index d02f2789f84..a0b66ddb310 100644 --- a/src/ansys/aedt/core/extensions/templates/run_pyaedt_toolkit_script.py_build +++ b/src/ansys/aedt/core/extensions/templates/run_pyaedt_toolkit_script.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/pyaedt/workflows/templates/jupyter.py_build b/src/pyaedt/workflows/templates/jupyter.py_build index 02539325d4e..8099b6d9daf 100644 --- a/src/pyaedt/workflows/templates/jupyter.py_build +++ b/src/pyaedt/workflows/templates/jupyter.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/pyaedt/workflows/templates/pyaedt_console.py_build b/src/pyaedt/workflows/templates/pyaedt_console.py_build index 7c3053e57f8..2fac7124ade 100644 --- a/src/pyaedt/workflows/templates/pyaedt_console.py_build +++ b/src/pyaedt/workflows/templates/pyaedt_console.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/pyaedt/workflows/templates/run_extension_manager.py_build b/src/pyaedt/workflows/templates/run_extension_manager.py_build index 8e92d3741c0..c38f77d17df 100644 --- a/src/pyaedt/workflows/templates/run_extension_manager.py_build +++ b/src/pyaedt/workflows/templates/run_extension_manager.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/pyaedt/workflows/templates/run_pyaedt_script.py_build b/src/pyaedt/workflows/templates/run_pyaedt_script.py_build index f7425c0bbaf..72a45fa0db6 100644 --- a/src/pyaedt/workflows/templates/run_pyaedt_script.py_build +++ b/src/pyaedt/workflows/templates/run_pyaedt_script.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/pyaedt/workflows/templates/run_pyaedt_toolkit_script.py_build b/src/pyaedt/workflows/templates/run_pyaedt_toolkit_script.py_build index f50eca4b911..3310ed2c718 100644 --- a/src/pyaedt/workflows/templates/run_pyaedt_toolkit_script.py_build +++ b/src/pyaedt/workflows/templates/run_pyaedt_toolkit_script.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/pyaedt/workflows/templates/run_pyedb_toolkit_script.py_build b/src/pyaedt/workflows/templates/run_pyedb_toolkit_script.py_build index 37ac2d0db09..6c8cbca1611 100644 --- a/src/pyaedt/workflows/templates/run_pyedb_toolkit_script.py_build +++ b/src/pyaedt/workflows/templates/run_pyedb_toolkit_script.py_build @@ -1,4 +1,6 @@ -# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates. +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # From 18acb3033021a5ed75deca6dc77d4b67a8d11f7e Mon Sep 17 00:00:00 2001 From: Eduardo Blanco Date: Fri, 28 Nov 2025 17:54:23 +0100 Subject: [PATCH 2/4] Add VenvConsole panel --- .../installer/extensions_catalog.toml | 16 ++- .../extensions/installer/pyaedt_installer.py | 17 ++- .../templates/venv_console.py_build | 111 ++++++++++++++++++ 3 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 src/ansys/aedt/core/extensions/templates/venv_console.py_build diff --git a/src/ansys/aedt/core/extensions/installer/extensions_catalog.toml b/src/ansys/aedt/core/extensions/installer/extensions_catalog.toml index 0d2782bd066..4982024acff 100644 --- a/src/ansys/aedt/core/extensions/installer/extensions_catalog.toml +++ b/src/ansys/aedt/core/extensions/installer/extensions_catalog.toml @@ -1,29 +1,35 @@ [Console] +icon = "console.png" name = "PyAEDT Console" script = "console_setup.py" -icon = "console.png" template = "pyaedt_console" +[VenvConsole] +icon = "console.png" +name = "Venv Console" +script = "" +template = "venv_console" + [Jupyter] +icon = "jupyter.png" name = "Jupyter Notebook" script = "jupyter_template.ipynb" -icon = "jupyter.png" template = "jupyter" [Run_Script] +icon = "run_script.png" name = "Run PyAEDT Script" script = "" -icon = "run_script.png" template = "run_pyaedt_script" [ExtensionManager] +icon = "extension_manager.png" name = "Extension Manager" script = "extension_manager.py" -icon = "extension_manager.png" template = "run_extension_manager" [VersionManager] +icon = "version_manager.png" name = "Version Manager" script = "version_manager.py" -icon = "version_manager.png" template = "run_pyaedt_toolkit_script" diff --git a/src/ansys/aedt/core/extensions/installer/pyaedt_installer.py b/src/ansys/aedt/core/extensions/installer/pyaedt_installer.py index ed6baab88a2..1586debd98b 100644 --- a/src/ansys/aedt/core/extensions/installer/pyaedt_installer.py +++ b/src/ansys/aedt/core/extensions/installer/pyaedt_installer.py @@ -69,9 +69,22 @@ def add_pyaedt_to_aedt( def __add_pyaedt_tabs(personal_lib, aedt_version, skip_version_manager, odesktop=None): """Add PyAEDT tabs in AEDT.""" if skip_version_manager: - pyaedt_tabs = ["Console", "Jupyter", "Run_Script", "ExtensionManager"] + pyaedt_tabs = [ + "Console", + "VenvConsole", + "Jupyter", + "Run_Script", + "ExtensionManager", + ] else: - pyaedt_tabs = ["Console", "Jupyter", "Run_Script", "ExtensionManager", "VersionManager"] + pyaedt_tabs = [ + "Console", + "VenvConsole", + "Jupyter", + "Run_Script", + "ExtensionManager", + "VersionManager", + ] extensions_catalog = read_toml(os.path.join(os.path.dirname(__file__), "extensions_catalog.toml")) diff --git a/src/ansys/aedt/core/extensions/templates/venv_console.py_build b/src/ansys/aedt/core/extensions/templates/venv_console.py_build new file mode 100644 index 00000000000..6413a797a45 --- /dev/null +++ b/src/ansys/aedt/core/extensions/templates/venv_console.py_build @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +""" +* * * This script is meant to run in IronPython within AEDT. * * * + +This script opens a native terminal with the PyAEDT virtual environment activated. + +""" +import os +import sys + +is_linux = os.name == "posix" + +if is_linux: + import subprocessdotnet as subprocess +else: + import subprocess + +sys.path.append(r"##EXTENSION_TEMPLATES##") + +import pyaedt_utils + + +def main(): + try: + # Get AEDT version + version_short = oDesktop.GetVersion()[2:6].replace(".", "") + oDesktop.AddMessage("", "", 0, "Opening terminal with PyAEDT environment...") + + # Virtual environment path - use default PyAEDT venv location + if is_linux: + venv_path = os.path.join(os.path.expanduser("~"), ".pyaedt_env") + else: + # Windows: C:\Users\\AppData\Roaming\.pyaedt_env + venv_path = os.path.join(os.getenv("APPDATA"), ".pyaedt_env") + + if not os.path.exists(venv_path): + pyaedt_utils.show_error( + "PyAEDT virtual environment not found at: {}".format(venv_path), + oDesktop + ) + return + + # Add environment variables + pyaedt_utils.environment_variables(oDesktop) + pyaedt_utils.set_ansys_em_environment(oDesktop) + + # Open terminal with venv activated + if is_linux: + # For Linux systems + command = pyaedt_utils.get_linux_terminal_command() + if not command: + pyaedt_utils.show_error("No terminal found on system.", oDesktop) + return + bash_activate = os.path.normpath(os.path.join(venv_path, "bin", "activate")) + venv_flag = pyaedt_utils.check_file(bash_activate, oDesktop) + if not venv_flag: + return + command.extend(["bash", "-c", "source '{}' && bash".format(bash_activate)]) + my_env = os.environ.copy() + subprocess.Popen(command, env=my_env) + else: + # For Windows systems - use cmd.exe to launch PowerShell + venv_activate = os.path.normpath(os.path.join(venv_path, "3_10", "Scripts", "Activate.ps1")) + + # Check if venv activation script exists + venv_flag = pyaedt_utils.check_file(venv_activate, oDesktop) + if not venv_flag: + return + + my_env = os.environ.copy() + + # Create PowerShell command to activate venv and change directory + # Use cmd.exe with /c to properly launch PowerShell + repo_path = os.path.dirname(venv_path) + ps_command = "& '{0}'; Set-Location '{1}'".format(venv_activate, repo_path) + + # Use cmd.exe to launch PowerShell (more reliable with IronPython subprocess) + command = 'cmd.exe /c start powershell.exe -NoExit -Command "{0}"'.format(ps_command) + subprocess.Popen(command, env=my_env) + + oDesktop.AddMessage("", "", 0, "Terminal opened successfully with virtual environment activated.") + + except Exception as e: + pyaedt_utils.show_error(str(e), oDesktop) + + +if __name__ == "__main__": + main() From 7bcf32be16b80098c7b628149a7320c433459dde Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 16:55:17 +0000 Subject: [PATCH 3/4] CHORE: Auto fixes from pre-commit hooks --- .../extensions/templates/venv_console.py_build | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ansys/aedt/core/extensions/templates/venv_console.py_build b/src/ansys/aedt/core/extensions/templates/venv_console.py_build index 6413a797a45..0ad01294ec3 100644 --- a/src/ansys/aedt/core/extensions/templates/venv_console.py_build +++ b/src/ansys/aedt/core/extensions/templates/venv_console.py_build @@ -48,25 +48,25 @@ def main(): # Get AEDT version version_short = oDesktop.GetVersion()[2:6].replace(".", "") oDesktop.AddMessage("", "", 0, "Opening terminal with PyAEDT environment...") - + # Virtual environment path - use default PyAEDT venv location if is_linux: venv_path = os.path.join(os.path.expanduser("~"), ".pyaedt_env") else: # Windows: C:\Users\\AppData\Roaming\.pyaedt_env venv_path = os.path.join(os.getenv("APPDATA"), ".pyaedt_env") - + if not os.path.exists(venv_path): pyaedt_utils.show_error( "PyAEDT virtual environment not found at: {}".format(venv_path), oDesktop ) return - + # Add environment variables pyaedt_utils.environment_variables(oDesktop) pyaedt_utils.set_ansys_em_environment(oDesktop) - + # Open terminal with venv activated if is_linux: # For Linux systems @@ -89,20 +89,20 @@ def main(): venv_flag = pyaedt_utils.check_file(venv_activate, oDesktop) if not venv_flag: return - + my_env = os.environ.copy() - + # Create PowerShell command to activate venv and change directory # Use cmd.exe with /c to properly launch PowerShell repo_path = os.path.dirname(venv_path) ps_command = "& '{0}'; Set-Location '{1}'".format(venv_activate, repo_path) - + # Use cmd.exe to launch PowerShell (more reliable with IronPython subprocess) command = 'cmd.exe /c start powershell.exe -NoExit -Command "{0}"'.format(ps_command) subprocess.Popen(command, env=my_env) - + oDesktop.AddMessage("", "", 0, "Terminal opened successfully with virtual environment activated.") - + except Exception as e: pyaedt_utils.show_error(str(e), oDesktop) From 24e5deee163b3b1995388678fc3b135f9f772eba Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 28 Nov 2025 16:57:49 +0000 Subject: [PATCH 4/4] chore: adding changelog file 6961.added.md [dependabot-skip] --- doc/changelog.d/6961.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/6961.added.md diff --git a/doc/changelog.d/6961.added.md b/doc/changelog.d/6961.added.md new file mode 100644 index 00000000000..eb1eb521d70 --- /dev/null +++ b/doc/changelog.d/6961.added.md @@ -0,0 +1 @@ +Venv console panel