Skip to content

Commit 026b419

Browse files
authored
Merge branch 'main' into feat/save-as
2 parents a986385 + fb124be commit 026b419

File tree

6 files changed

+45
-16
lines changed

6 files changed

+45
-16
lines changed

.github/workflows/ci_cd.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ on:
1212
- '251'
1313
- '242'
1414
- '241'
15-
- '232'
1615
description: 'The Mechanical revision number to run tests on.'
17-
default: '251' #stable version is 251, must match $stable_container
16+
default: '252' #stable version is 252, must match $stable_container
1817
schedule:
1918
- cron: '00 22 * * *' # UTC time, may start 5-15 mins later than scheduled time
2019
# registry_package:
@@ -38,7 +37,7 @@ env:
3837
DOCUMENTATION_CNAME: mechanical.docs.pyansys.com
3938
MAIN_PYTHON_VERSION: '3.12'
4039
# DEV_REVN & its Docker image are used in scheduled or registry package runs
41-
STABLE_REVN: '251'
40+
STABLE_REVN: '252'
4241
DEV_REVN: '261'
4342
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
4443
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }}
@@ -173,7 +172,7 @@ jobs:
173172
run: |
174173
# if a tag(release) is pushed, test all versions
175174
if ${{ github.event_name == 'push' }} && ${{ contains(github.ref, 'refs/tags') }}; then
176-
echo "matrix={\"mechanical-version\":['23.2.0', '24.1.0', '24.2.0', '25.1.0'],\"experimental\":[false]}" >> $GITHUB_OUTPUT
175+
echo "matrix={\"mechanical-version\":['24.1.0', '24.2.0', '25.1.0', '25.2.0'],\"experimental\":[false]}" >> $GITHUB_OUTPUT
177176
else
178177
echo "matrix={\"mechanical-version\":['${{ needs.revn-variations.outputs.test_docker_image_version }}'],\"experimental\":[false]}" >> $GITHUB_OUTPUT
179178
fi
@@ -399,7 +398,7 @@ jobs:
399398
NUM_CORES: 1
400399
PYTHONUNBUFFERED: 1
401400
run: |
402-
mkdir /root/Documents # work around bug #1301340
401+
mkdir $HOME/Documents # work around bug #1301340
403402
. /env/bin/activate
404403
if [ "${{ needs.container-stability-check.outputs.container_stable_exit }}" = "true" ]; then
405404
xvfb-run mechanical-env pytest -m embedding -s --junitxml test_results${{ matrix.python-version }}.xml
@@ -643,7 +642,7 @@ jobs:
643642
NUM_CORES: 1
644643
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 0
645644
run: |
646-
mkdir /root/Documents # work around #1301340
645+
mkdir $HOME/Documents # work around #1301340
647646
. /env/bin/activate
648647
# Make html or pdf doc
649648
make_doc() {

doc/changelog.d/1234.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add option for pep8 aliases in binding

doc/changelog.d/1237.maintenance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update ci/cd to use 25r2

doc/changelog.d/1242.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Create document folder under home

src/ansys/mechanical/core/embedding/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class App:
143143
Whether to enable logging. Default is True.
144144
log_level : str, optional
145145
The logging level for the application. Default is "WARNING".
146+
pep8 : bool, optional
147+
Whether to enable PEP 8 style binding for the assembly. Default is False.
146148
147149
Examples
148150
--------
@@ -230,7 +232,8 @@ def __init__(self, db_file=None, private_appdata=False, **kwargs):
230232
profile = UniqueUserProfile(new_profile_name, copy_profile=copy_profile)
231233
profile.update_environment(os.environ)
232234

233-
runtime.initialize(self._version)
235+
pep8_alias = kwargs.get("pep8", False)
236+
runtime.initialize(self._version, pep8_aliases=pep8_alias)
234237
self._app = _start_application(configuration, self._version, db_file)
235238
connect_warnings(self)
236239
self._poster = None

src/ansys/mechanical/core/embedding/runtime.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,44 @@ def __register_function_codec():
4545
Ansys.Mechanical.CPython.Codecs.FunctionCodec.Register()
4646

4747

48-
def _bind_assembly_for_explicit_interface(assembly_name: str):
49-
"""Bind the assembly for explicit interface implementation."""
48+
def _bind_assembly(
49+
assembly_name: str, explicit_interface: bool = False, pep8_aliases: bool = False
50+
) -> None:
51+
"""Bind the assembly for explicit interface and/or pep8 aliases.
52+
53+
Parameters
54+
----------
55+
assembly_name : str
56+
The name of the assembly to bind.
57+
explicit_interface : bool, optional
58+
If True, allows explicit interface implementation. Default is False.
59+
pep8_aliases : bool, optional
60+
If True, enables PEP 8 aliases. Default is False.
61+
"""
5062
# if pythonnet is not installed, we can't bind the assembly
5163
try:
5264
distribution("pythonnet")
5365
Logger.warning("Cannot bind for explicit interface because pythonnet is installed")
5466
return
5567
except ModuleNotFoundError:
5668
pass
57-
58-
Logger.debug(f"Binding assembly for explicit interface {assembly_name}")
5969
import clr
6070

61-
Logger.debug(f"Binding assembly for explicit interface, Loading {assembly_name}")
71+
Logger.debug(f"Binding assembly {assembly_name}")
6272
assembly = clr.AddReference(assembly_name)
63-
Logger.debug(f"Binding assembly for explicit interface, Loaded {assembly_name}")
6473
from Python.Runtime import BindingManager, BindingOptions
6574

6675
binding_options = BindingOptions()
67-
binding_options.AllowExplicitInterfaceImplementation = True
76+
if explicit_interface:
77+
Logger.debug(f"Binding explicit interface for {assembly_name}")
78+
binding_options.AllowExplicitInterfaceImplementation = True
79+
if pep8_aliases:
80+
Logger.debug(f"Setting PEP 8 aliases for {assembly_name}")
81+
binding_options.Pep8Aliases = True
6882
BindingManager.SetBindingOptions(assembly, binding_options)
6983

7084

71-
def initialize(version: int) -> None:
85+
def initialize(version: int, pep8_aliases: bool = False) -> None:
7286
"""Initialize the runtime.
7387
7488
Pythonnet is already initialized but we need to
@@ -86,4 +100,14 @@ def initialize(version: int) -> None:
86100
__register_function_codec()
87101
Logger.debug("Registered function codec")
88102

89-
_bind_assembly_for_explicit_interface("Ansys.ACT.WB1")
103+
explicit_interface = True
104+
105+
if os.environ.get("PYMECHANICAL_EXPLICIT_INTERFACE") == "0":
106+
explicit_interface = False
107+
108+
# TODO: When the pep8_aliases option is enabled (True by default),
109+
# keep three environment variables to turn explicit, pep8, and both off.
110+
111+
_bind_assembly(
112+
"Ansys.ACT.WB1", explicit_interface=explicit_interface, pep8_aliases=pep8_aliases
113+
)

0 commit comments

Comments
 (0)