Skip to content
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

added pythonnet check with warning output #235

Merged
merged 24 commits into from
May 8, 2023
Merged
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b9caa98
added pythonnet check with warning output
May 4, 2023
33849b4
try except for cases of older versions of pip - src/ansys/mechanical/…
klmcadams May 4, 2023
8b3880e
added comment describing code block - src/ansys/mechanical/core/embed…
klmcadams May 4, 2023
1c58a27
adjusted warning output & pip comment spacing
klmcadams May 4, 2023
9ffcca4
moved pythonnet check to initializer.py
klmcadams May 7, 2023
bf63fbe
created unit test for pythonnet embedded instance
klmcadams May 7, 2023
c07c28b
updated changelog
klmcadams May 7, 2023
01ad078
Merge branch 'main' into fix/pythonnetconflict
klmcadams May 7, 2023
75c5860
adjusted syntax & added print lines
klmcadams May 7, 2023
8886aad
added remote session unit tests
klmcadams May 7, 2023
86a32a2
fixed style issues
klmcadams May 7, 2023
c32cee4
dynamic python path & used importlib.metadata to detect pythonnet
klmcadams May 7, 2023
80d957a
added apt install python venv to ci_cd yml file
klmcadams May 7, 2023
3b72fc7
added -y flag to apt install python venv
klmcadams May 7, 2023
c6da2f4
remove whitespace - src/ansys/mechanical/core/embedding/app.py
klmcadams May 8, 2023
cf4be53
pass instead of print in try/except - src/ansys/mechanical/core/embed…
klmcadams May 8, 2023
547c818
condensing stderr_output if statement - tests/embedding/test_app.py
klmcadams May 8, 2023
54ea106
assert not warning statement - tests/test_mechanical.py
klmcadams May 8, 2023
17a8976
assert not warning - tests/test_mechanical.py
klmcadams May 8, 2023
35fdee4
Updated comments for warning checking - tests/test_mechanical.py
klmcadams May 8, 2023
b9abfaf
Updated comment for warning check - tests/test_mechanical.py
klmcadams May 8, 2023
e7d2d9b
Updated comment for warning check - tests/embedding/test_app.py
klmcadams May 8, 2023
cd79873
changed assert warning statement - tests/embedding/test_app.py
klmcadams May 8, 2023
b129cd8
removed print statements
klmcadams May 8, 2023
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
20 changes: 20 additions & 0 deletions src/ansys/mechanical/core/embedding/app.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,12 @@
import atexit
import os
import typing
import warnings

try:
from pip._internal.operations import freeze
except ImportError: # pip < 10.0
from pip.operations import freeze

from ansys.mechanical.core.embedding import initializer, runtime
from ansys.mechanical.core.embedding.config import Configuration, configure
@@ -71,6 +77,20 @@ def __init__(self, db_file=None, **kwargs):
if self._version == None:
self._version = _get_default_version()
initializer.initialize(self._version)

# Check if 'pythonnet' is installed... and if so, throw warning
pkgs = freeze.freeze()
for pkg in pkgs:
indx = pkg.index("=")
if pkg[:indx] == "pythonnet":
warnings.warn(
"The pythonnet package was found in your environment "
"which interferes with the ansys-pythonnet package. "
"Some APIs may not work due to pythonnet being installed.",
stacklevel=2,
)
break

import clr

clr.AddReference("Ansys.Mechanical.Embedding")