ansys-lumerical-core 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ANSYS, Inc. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.4
2
+ Name: ansys-lumerical-core
3
+ Version: 0.1.0
4
+ Summary: Python interface to Ansys Lumerical
5
+ Keywords: Ansys,Lumerical,photonics,simulation
6
+ Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
7
+ Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
8
+ Requires-Python: >=3.10,<4
9
+ Description-Content-Type: text/x-rst
10
+ License-Expression: MIT
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ License-File: LICENSE
20
+ Requires-Dist: ansys-api-lumerical
21
+ Requires-Dist: numpy>=1.26
22
+ Requires-Dist: ansys-sphinx-theme[autoapi]==1.4.2 ; extra == "doc"
23
+ Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
24
+ Requires-Dist: sphinx==8.2.3 ; extra == "doc"
25
+ Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
26
+ Requires-Dist: sphinx_design==0.6.1 ; extra == "doc"
27
+ Requires-Dist: matplotlib==3.10.0 ; extra == "examples"
28
+ Requires-Dist: pytest==8.4.2 ; extra == "tests"
29
+ Requires-Dist: pytest-cov==7.0.0 ; extra == "tests"
30
+ Provides-Extra: doc
31
+ Provides-Extra: examples
32
+ Provides-Extra: tests
33
+
34
+ PyLumerical
35
+ ===========
36
+ |pyansys| |python| |pypi| |codecov| |GH-CI| |MIT| |ruff|
37
+
38
+ .. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
39
+ :target: https://docs.pyansys.com/
40
+ :alt: PyAnsys
41
+
42
+ .. |python| image:: https://img.shields.io/pypi/pyversions/ansys-lumerical-core?logo=pypi
43
+ :target: https://pypi.org/project/ansys-lumerical-core/
44
+ :alt: Python
45
+
46
+ .. |pypi| image:: https://img.shields.io/pypi/v/ansys-lumerical-core.svg?logo=python&logoColor=white&label=PyPI
47
+ :target: https://pypi.org/project/ansys-lumerical-core
48
+ :alt: PyPI
49
+
50
+ .. |codecov| image:: https://codecov.io/github/ansys/pylumerical/graph/badge.svg?token=34FKDS6ZKJ
51
+ :target: https://codecov.io/github/ansys/pylumerical
52
+ :alt: Codecov
53
+
54
+ .. |GH-CI| image:: https://github.com/ansys/pylumerical/actions/workflows/ci_cd_pr.yml/badge.svg
55
+ :target: https://github.com/ansys/pylumerical/actions/workflows/ci_cd_pr.yml
56
+
57
+ .. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
58
+ :target: https://opensource.org/licenses/MIT
59
+ :alt: MIT
60
+
61
+ .. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
62
+ :target: https://github.com/astral-sh/ruff
63
+ :alt: Ruff
64
+
65
+
66
+ A Python wrapper for Ansys Lumerical products.
67
+
68
+ Installing PyLumerical as a user
69
+ --------------------------------
70
+
71
+ You must have an Ansys Lumerical GUI license to use PyLumerical.
72
+
73
+ You can install PyLumerical using pip.
74
+
75
+ First, ensure that you have the latest pip version:
76
+
77
+ .. code:: bash
78
+
79
+ python -m pip install -U pip
80
+
81
+ Then, install using:
82
+
83
+ .. code:: bash
84
+
85
+ python -m pip install ansys-lumerical-core
86
+
87
+ For more information, see the `installation and getting started section <https://lumerical.docs.pyansys.com/version/stable/getting_started/index.html>`_ in the documentation.
88
+
89
+ Contributing to PyLumerical
90
+ ---------------------------
91
+
92
+ For guidelines on contribution and how to install PyLumerical as a developer, see the `contributing section <https://lumerical.docs.pyansys.com/version/stable/contributing.html>`_ section in the documentation.
93
+
94
+ Getting started
95
+ ----------------
96
+
97
+ Please see the `installation and getting started section <https://lumerical.docs.pyansys.com/version/stable/getting_started/index.html>`_ in the documentation for more information.
98
+
@@ -0,0 +1,64 @@
1
+ PyLumerical
2
+ ===========
3
+ |pyansys| |python| |pypi| |codecov| |GH-CI| |MIT| |ruff|
4
+
5
+ .. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
6
+ :target: https://docs.pyansys.com/
7
+ :alt: PyAnsys
8
+
9
+ .. |python| image:: https://img.shields.io/pypi/pyversions/ansys-lumerical-core?logo=pypi
10
+ :target: https://pypi.org/project/ansys-lumerical-core/
11
+ :alt: Python
12
+
13
+ .. |pypi| image:: https://img.shields.io/pypi/v/ansys-lumerical-core.svg?logo=python&logoColor=white&label=PyPI
14
+ :target: https://pypi.org/project/ansys-lumerical-core
15
+ :alt: PyPI
16
+
17
+ .. |codecov| image:: https://codecov.io/github/ansys/pylumerical/graph/badge.svg?token=34FKDS6ZKJ
18
+ :target: https://codecov.io/github/ansys/pylumerical
19
+ :alt: Codecov
20
+
21
+ .. |GH-CI| image:: https://github.com/ansys/pylumerical/actions/workflows/ci_cd_pr.yml/badge.svg
22
+ :target: https://github.com/ansys/pylumerical/actions/workflows/ci_cd_pr.yml
23
+
24
+ .. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
25
+ :target: https://opensource.org/licenses/MIT
26
+ :alt: MIT
27
+
28
+ .. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
29
+ :target: https://github.com/astral-sh/ruff
30
+ :alt: Ruff
31
+
32
+
33
+ A Python wrapper for Ansys Lumerical products.
34
+
35
+ Installing PyLumerical as a user
36
+ --------------------------------
37
+
38
+ You must have an Ansys Lumerical GUI license to use PyLumerical.
39
+
40
+ You can install PyLumerical using pip.
41
+
42
+ First, ensure that you have the latest pip version:
43
+
44
+ .. code:: bash
45
+
46
+ python -m pip install -U pip
47
+
48
+ Then, install using:
49
+
50
+ .. code:: bash
51
+
52
+ python -m pip install ansys-lumerical-core
53
+
54
+ For more information, see the `installation and getting started section <https://lumerical.docs.pyansys.com/version/stable/getting_started/index.html>`_ in the documentation.
55
+
56
+ Contributing to PyLumerical
57
+ ---------------------------
58
+
59
+ For guidelines on contribution and how to install PyLumerical as a developer, see the `contributing section <https://lumerical.docs.pyansys.com/version/stable/contributing.html>`_ section in the documentation.
60
+
61
+ Getting started
62
+ ----------------
63
+
64
+ Please see the `installation and getting started section <https://lumerical.docs.pyansys.com/version/stable/getting_started/index.html>`_ in the documentation for more information.
@@ -0,0 +1,147 @@
1
+ [build-system]
2
+ requires = ["flit_core >=3.2,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "ansys-lumerical-core"
7
+ dynamic = ["version"]
8
+ description = "Python interface to Ansys Lumerical"
9
+ readme = "README.rst"
10
+ requires-python = ">=3.10,<4"
11
+ license = "MIT"
12
+ license_files = ["LICENSE"]
13
+ authors=[
14
+ {name="ANSYS, Inc.", email="pyansys.core@ansys.com"}
15
+ ]
16
+ maintainers=[
17
+ {name="ANSYS, Inc.", email="pyansys.core@ansys.com"}
18
+ ]
19
+ keywords = ["Ansys", "Lumerical", "photonics", "simulation"]
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Intended Audience :: Science/Research",
23
+ "Topic :: Scientific/Engineering :: Information Analysis",
24
+ "Operating System :: OS Independent",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ ]
30
+
31
+ dependencies = [
32
+ "ansys-api-lumerical",
33
+ "numpy>=1.26",
34
+ ]
35
+
36
+ [project.optional-dependencies]
37
+ tests = [
38
+ "pytest==8.4.2",
39
+ "pytest-cov==7.0.0",
40
+ ]
41
+ doc = [
42
+ "ansys-sphinx-theme[autoapi]==1.4.2",
43
+ "numpydoc==1.8.0",
44
+ "sphinx==8.2.3",
45
+ "sphinx-copybutton==0.5.2",
46
+ "sphinx_design==0.6.1",
47
+ ]
48
+ examples = [
49
+ "matplotlib==3.10.0",
50
+ ]
51
+
52
+ [tool.flit.module]
53
+ name = "ansys.lumerical.core"
54
+
55
+ [tool.ruff]
56
+ line-length = 150
57
+ fix = true
58
+ extend-exclude = ["tests/assets", "*.rst"]
59
+
60
+ [tool.ruff.format]
61
+ quote-style = "double"
62
+ indent-style = "space"
63
+ docstring-code-format = true
64
+
65
+ [tool.ruff.lint]
66
+ select = [
67
+ "E", # pycodestyle, see https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
68
+ "D", # pydocstyle, see https://docs.astral.sh/ruff/rules/#pydocstyle-d
69
+ "F", # pyflakes, see https://docs.astral.sh/ruff/rules/#pyflakes-f
70
+ "I", # isort, see https://docs.astral.sh/ruff/rules/#isort-i
71
+ "N", # pep8-naming, see https://docs.astral.sh/ruff/rules/#pep8-naming-n
72
+ "PTH", # flake8-use-pathlib, https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
73
+ "TD", # flake8-todos, https://docs.astral.sh/ruff/rules/#flake8-todos-td
74
+ ]
75
+ ignore = []
76
+
77
+ [tool.ruff.lint.per-file-ignores]
78
+ "examples/*" = ["D100", "E402"]
79
+ "__init__.py" = ["F401"]
80
+ "doc/source/conf.py" = ["N806"]
81
+
82
+ [tool.ruff.lint.pep8-naming]
83
+ ignore-names = [
84
+ "test_MODE_start_session",
85
+ "test_FDTD_start_session",
86
+ ]
87
+
88
+ [tool.ruff.lint.pydocstyle]
89
+ convention = "numpy"
90
+
91
+ [tool.ruff.lint.isort]
92
+ combine-as-imports = true
93
+ force-sort-within-sections = true
94
+ known-first-party = ["ansys.lumerical.core", "ansys.api.lumerical"]
95
+
96
+ [tool.pydocstyle]
97
+ convention = "numpy"
98
+
99
+ [tool.coverage.run]
100
+ source = ["ansys.lumerical"]
101
+
102
+ [tool.coverage.report]
103
+ show_missing = true
104
+
105
+ [tool.towncrier]
106
+ package = "ansys.lumerical.core"
107
+ directory = "doc/source/changelog"
108
+ filename = "doc/source/changelog.rst"
109
+ start_string = ".. towncrier release notes start\n"
110
+ template = "doc/source/changelog/template"
111
+ title_format = "`{version} <https://github.com/ansys/pylumerical/releases/tag/v{version}>`_ - {project_date}"
112
+ issue_format = "`#{issue} <https://github.com/ansys/pylumerical/pull/{issue}>`_"
113
+
114
+ [[tool.towncrier.type]]
115
+ directory = "added"
116
+ name = "Added"
117
+ showcontent = true
118
+
119
+ [[tool.towncrier.type]]
120
+ directory = "dependencies"
121
+ name = "Dependencies"
122
+ showcontent = true
123
+
124
+ [[tool.towncrier.type]]
125
+ directory = "documentation"
126
+ name = "Documentation"
127
+ showcontent = true
128
+
129
+ [[tool.towncrier.type]]
130
+ directory = "fixed"
131
+ name = "Fixed"
132
+ showcontent = true
133
+
134
+ [[tool.towncrier.type]]
135
+ directory = "maintenance"
136
+ name = "Maintenance"
137
+ showcontent = true
138
+
139
+ [[tool.towncrier.type]]
140
+ directory = "miscellaneous"
141
+ name = "Miscellaneous"
142
+ showcontent = true
143
+
144
+ [[tool.towncrier.type]]
145
+ directory = "test"
146
+ name = "Test"
147
+ showcontent = true
@@ -0,0 +1,41 @@
1
+ # Copyright (C) 2025 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """Set up the imports for PyLumerical."""
24
+
25
+ import ansys.api.lumerical
26
+
27
+ # Make common names from lumapi available in the top-level namespace
28
+ from ansys.api.lumerical.lumapi import DEVICE, FDTD, INTERCONNECT, MODE, InteropPaths, SimObject, SimObjectId, SimObjectResults
29
+
30
+ from . import autodiscovery
31
+
32
+ __version__ = "0.1.0"
33
+ """Lumerical API version."""
34
+
35
+ if len(ansys.api.lumerical.lumapi.InteropPaths.LUMERICALINSTALLDIR) == 0:
36
+ install_dir = autodiscovery.locate_lumerical_install()
37
+ if install_dir is not None:
38
+ ansys.api.lumerical.lumapi.InteropPaths.setLumericalInstallPath(install_dir)
39
+ else:
40
+ print("Lumerical installation not found. Please use InteropPaths.setLumericalInstallPath to set the interop library location.")
41
+ del install_dir # remove the local variable to exclude from the namespace
@@ -0,0 +1,119 @@
1
+ # Copyright (C) 2025 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """Autodiscover the Lumerical installation directory."""
24
+
25
+ from pathlib import Path
26
+ import platform
27
+ import re
28
+
29
+ __min_supported_lum_release__ = {"year": 22, "release": 1}
30
+ """
31
+ Supports Lumerical 2022R1 release and later.
32
+ """
33
+
34
+
35
+ def locate_lumerical_install():
36
+ r"""
37
+ Locate the installation directory and interop library directory for Lumerical software.
38
+
39
+ This function attempts to identify the most recent installation path of Lumerical
40
+ software and its associated Python interop library directory based on the operating
41
+ system and predefined directory structures.
42
+
43
+ Returns
44
+ -------
45
+ str or None
46
+ The path to the Lumerical installation directory, or None if not found.
47
+
48
+ Raises
49
+ ------
50
+ RuntimeError
51
+ If the operating system is not Windows or Linux.
52
+
53
+ Notes
54
+ -----
55
+ - On Windows, the function first searches the registry, then searches under "C:\\Program Files\\Lumerical\\" and
56
+ "C:\\Program Files\\Ansys Inc\\Lumerical".
57
+ - On Linux, the function searches under "/opt/lumerical/" and "~/Ansys/ansys_inc/Lumerical".
58
+
59
+ Examples
60
+ --------
61
+ Example 1: Use autodiscovery to locate a Lumerical installation in a default location.
62
+
63
+ >>> import ansys.lumerical.core as lumapi
64
+ >>> # use lumapi ...
65
+
66
+ Example 2: Provide a custom installation path before importing the module.
67
+
68
+ >>> import ansys.api.lumerical.lumapi
69
+ >>> ansys.api.lumerical.lumapi.InteropPaths.setLumericalInstallPath(r"C:\Program Files\Lumerical\v252\")
70
+ >>> import ansys.lumerical.core as lumapi
71
+ >>> # use lumapi ...
72
+
73
+ Example 3: Provide a custom installation path after importing the module.
74
+
75
+ >>> import ansys.lumerical.core as lumapi
76
+ Warning: Lumerical installation not found. Please use InteropPaths.setLumericalInstallPath to set the interop library location.
77
+ >>> lumapi.InteropPaths.setLumericalInstallPath(r"C:\Program Files\Lumerical\v252\")
78
+ >>> # use lumapi ...
79
+ """
80
+ lumerical_install_dir = None
81
+
82
+ if platform.system() == "Windows":
83
+ try:
84
+ import winreg # Import winreg here to avoid errors on non-Windows platforms
85
+
86
+ reg_path = r"SOFTWARE\ANSYS, Inc.\Lumerical"
87
+ with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_path) as key:
88
+ install_folder, regtype = winreg.QueryValueEx(key, "installFolder")
89
+ if Path(install_folder).exists():
90
+ return install_folder
91
+ except (FileNotFoundError, OSError):
92
+ pass
93
+ # if not found in the registry, try to guess the installation path
94
+ guess_base_and_suffix = [["C:\\Program Files\\Lumerical\\", ""], ["C:\\Program Files\\Ansys Inc\\", "Lumerical"]]
95
+ elif platform.system() == "Linux":
96
+ guess_base_and_suffix = [["/opt/lumerical/", ""], [str(Path("~/Ansys/ansys_inc/").expanduser()), "Lumerical"]]
97
+ else:
98
+ raise RuntimeError("Unsupported operating system. Only Windows and Linux are supported.")
99
+
100
+ # Find the latest installed version that is >= the required version
101
+ latest_ver_year = __min_supported_lum_release__["year"]
102
+ latest_ver_release = __min_supported_lum_release__["release"]
103
+
104
+ for guess_base, suffix in guess_base_and_suffix:
105
+ if Path(guess_base).exists():
106
+ for candidate_dir in Path(guess_base).iterdir():
107
+ if Path(candidate_dir, suffix).is_dir():
108
+ match = re.match(r"v(\d{2})(\d)", candidate_dir.name)
109
+ if match:
110
+ ver_year = int(match.group(1))
111
+ ver_maj = int(match.group(2))
112
+ if ver_year > latest_ver_year or (ver_year == latest_ver_year and ver_maj >= latest_ver_release):
113
+ latest_ver_year = ver_year
114
+ latest_ver_release = ver_maj
115
+ # check to make sure the api/python path is there (avoids some false positives from uninstalls)
116
+ if Path(candidate_dir, suffix, "api/python/").exists():
117
+ lumerical_install_dir = str(Path(candidate_dir, suffix))
118
+
119
+ return lumerical_install_dir