-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Move ansys-tools-path #16
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
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8c4a257
feat: Move ansys-tools-path
AlejandroFernandezLuces 87667d4
fix: Metadata
AlejandroFernandezLuces 5b2c1bd
fix: Metadata
AlejandroFernandezLuces ff067ea
fix: metadata
AlejandroFernandezLuces f484a66
fix: Code comments
AlejandroFernandezLuces 5da0e58
Merge branch 'main' into feat/add-tools-path
AlejandroFernandezLuces 268bf0d
test: Mark tests that require mapdl
AlejandroFernandezLuces cb60c5b
Merge branch 'feat/add-tools-path' of https://github.com/ansys-intern…
AlejandroFernandezLuces 169fe6a
test: Remove unneeded test
AlejandroFernandezLuces 6984534
test: Fix
AlejandroFernandezLuces 3e136d3
test: fix ci
AlejandroFernandezLuces 6a55b87
fix: Revert
AlejandroFernandezLuces 0e54ce6
test: Separate mapdl dependant tests
AlejandroFernandezLuces 978d30f
fix: Rename CI
AlejandroFernandezLuces dbfb7ef
Merge branch 'main' into feat/add-tools-path
AlejandroFernandezLuces 608ced0
Merge branch 'main' into feat/add-tools-path
AlejandroFernandezLuces 28d263f
fix: Move to common folder and add latest changes
AlejandroFernandezLuces a3cf025
fix: Update module paths
AlejandroFernandezLuces 919f95f
fix: Missing module fix
AlejandroFernandezLuces 4c3a2c0
fix: Comments
AlejandroFernandezLuces File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: MAPDL dependent tests for paths tool | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
| push: | ||
| tags: | ||
| - "*" | ||
| branches: | ||
| - main | ||
|
|
||
| env: | ||
| PACKAGE_NAME: ansys-tools-common | ||
| MAIN_PYTHON_VERSION: 3.13 | ||
|
|
||
| jobs: | ||
| build-tests: | ||
| name: Build and Testing | ||
| runs-on: ubuntu-22.04 | ||
| container: | ||
| image: ghcr.io/ansys/pymapdl/mapdl:v22.2-ubuntu | ||
| options: "-u=0:0 --entrypoint /bin/bash" | ||
| credentials: | ||
| username: ${{ secrets.GH_USERNAME }} | ||
| password: ${{ secrets.GH_TOKEN }} | ||
| env: | ||
| ANSYS_LOCAL: true | ||
| ON_UBUNTU: true | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ env.MAIN_PYTHON_VERSION }} | ||
| - name: Install library, with test extra | ||
| run: python -m pip install .[tests] | ||
|
|
||
| - name: Unit testing | ||
| run: | | ||
| python -m pytest -vx --cov=${{ env.PACKAGE_NAMESPACE }} --cov-report=term --cov-report=xml:.cov/coverage.xml --cov-report=html:.cov/html | ||
|
|
||
| - name: Upload coverage reports to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| files: .cov/coverage.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Copyright (C) 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. | ||
|
|
||
| """ | ||
| Tools to find/cache installed Ansys products. | ||
|
|
||
| WARNING: This is not concurrent-safe (multiple python processes might race on this data.) | ||
| """ | ||
|
|
||
| from ansys.tools.common.path.path import ( | ||
| LOG, | ||
| SETTINGS_DIR, | ||
| SUPPORTED_ANSYS_VERSIONS, | ||
| change_default_ansys_path, # deprecated | ||
| change_default_dyna_path, | ||
| change_default_mapdl_path, | ||
| change_default_mechanical_path, | ||
| clear_configuration, | ||
| find_ansys, # deprecated | ||
| find_dyna, | ||
| find_mapdl, | ||
| find_mechanical, | ||
| get_ansys_path, # deprecated | ||
| get_available_ansys_installations, | ||
| get_dyna_path, | ||
| get_latest_ansys_installation, | ||
| get_mapdl_path, | ||
| get_mechanical_path, | ||
| get_saved_application_path, | ||
| save_ansys_path, # deprecated | ||
| save_dyna_path, | ||
| save_mapdl_path, | ||
| save_mechanical_path, | ||
| version_from_path, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "LOG", | ||
| "SETTINGS_DIR", | ||
| "SUPPORTED_ANSYS_VERSIONS", | ||
| "change_default_mapdl_path", | ||
| "change_default_mechanical_path", | ||
| "change_default_dyna_path", | ||
| "clear_configuration", | ||
| "find_mapdl", | ||
| "find_mechanical", | ||
| "find_dyna", | ||
| "get_available_ansys_installations", | ||
| "get_latest_ansys_installation", | ||
| "get_mapdl_path", | ||
| "get_mechanical_path", | ||
| "get_saved_application_path", | ||
| "get_dyna_path", | ||
| "save_mapdl_path", | ||
| "save_mechanical_path", | ||
| "save_dyna_path", | ||
| "version_from_path", | ||
| "change_default_ansys_path", | ||
| "find_ansys", | ||
| "get_ansys_path", | ||
| "save_ansys_path", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Copyright (C) 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. | ||
|
|
||
| """ | ||
| Application plugin for ansys-tools-path. | ||
|
|
||
| This defines the interface of a plugin, which is implemented using a module. | ||
| """ | ||
|
|
||
| # TODO - consider using pluggy? | ||
| # TODO: Remove? | ||
|
|
||
|
|
||
| class ApplicationPlugin: | ||
| """Class for application plugins.""" | ||
|
|
||
| def is_valid_executable_path(self, exe_loc: str) -> bool: | ||
| r"""Check if the executable path is valid for the application. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| exe_loc : str | ||
| The path to the executable file. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| ``True`` if the path is valid for the application, ``False`` otherwise. | ||
| """ | ||
| raise Exception("This is just a base class.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Copyright (C) 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. | ||
|
|
||
| """dyna-specific logic for ansys-tools-path.""" | ||
|
|
||
|
|
||
| # TODO: Remove? | ||
| def is_valid_executable_path(exe_loc: str) -> bool: | ||
| """Check if the executable path is valid for Ansys Dyna. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| exe_loc : str | ||
| The path to the executable file. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| ``True`` if the path is valid for Ansys Dyna, ``False`` otherwise. | ||
| """ | ||
| # dyna paths can be anything | ||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Copyright (C) 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. | ||
|
|
||
| """MAPDL-specific logic for ansys-tools-path.""" | ||
|
|
||
| from pathlib import Path | ||
| import re | ||
|
|
||
|
|
||
| def is_valid_executable_path(exe_loc: str) -> bool: | ||
| """Check if the executable path is valid for Ansys MAPDL. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| exe_loc : str | ||
| The path to the executable file. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| ``True`` if the path is valid for Ansys MAPDL, ``False`` otherwise. | ||
| """ | ||
| path = Path(exe_loc) | ||
| return path.is_file() and re.search(r"ansys\d{3}", path.name) is not None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright (C) 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. | ||
|
|
||
| """Mechanical-specific logic for ansys-tools-path.""" | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
| import re | ||
|
|
||
|
|
||
| def is_valid_executable_path(exe_loc: str) -> bool: | ||
| """Check if the executable path is valid for Ansys Mechanical. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| exe_loc : str | ||
| The path to the executable file. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| ``True`` if the path is valid for Ansys Mechanical, ``False`` otherwise. | ||
| """ | ||
| path = Path(exe_loc) | ||
| if os.name == "nt": # pragma: no cover | ||
| return path.is_file() and re.search("AnsysWBU.exe", path.name, re.IGNORECASE) is not None | ||
| return path.is_file() and re.search(r"\.workbench$", path.name) is not None |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.