Skip to content

Commit

Permalink
Add error path for potentially missing examples module
Browse files Browse the repository at this point in the history
  • Loading branch information
widerschein committed Apr 26, 2024
1 parent 643ddd0 commit ad42dc6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ansys/optislang/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
from ansys.optislang.core.osl_process import OslServerProcess, ServerNotification

# Provide examples directory path
if spec := importlib.util.find_spec("ansys.optislang.core.examples"):
examples = "ansys.optislang.core.examples"
if spec := importlib.util.find_spec(examples):
if spec.origin:
os.environ["OSL_EXAMPLES"] = os.path.dirname(spec.origin)
else:
LOG.logger.warning(f"Could not set path to examples. Missing spec for module {examples}.")
else:
LOG.logger.warning(f"Could not set path to examples. Missing origin for module {examples}.")

0 comments on commit ad42dc6

Please sign in to comment.