Skip to content

Commit f154415

Browse files
committed
Merged PR 338503: Maint/get ansys version from pygate (#420)
Maint/get ansys version from pygate (#420) * Remove __ansys_version__ from setup.py * Get __ansys_version__ from gate instead of core in core.misc * Get __ansys_version__ from core.misc and not core._version * Fix flake8 import error (cherry picked from commit d43f194) Related work items: #685003
1 parent 8886491 commit f154415

File tree

7 files changed

+23
-44
lines changed

7 files changed

+23
-44
lines changed

.ci/edit_ansys_version.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

ansys/dpf/core/_version.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
# Nice string for the version
66
__version__ = ".".join(map(str, version_info))
7-
__ansys_version__ = "231"
87
min_server_version = "2.0"
98

109
server_to_ansys_grpc_dpf_version = {

ansys/dpf/core/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import glob
44
import os
55
from pkgutil import iter_modules
6-
from ansys.dpf.core._version import (
6+
from ansys.dpf.gate._version import (
77
__ansys_version__
88
)
99

ansys/dpf/core/server_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def get_server_type_from_config(config=None, ansys_path=None):
192192
config.protocol == CommunicationProtocols.gRPC
193193
and not config.legacy
194194
):
195-
from ansys.dpf.core._version import __ansys_version__
195+
from ansys.dpf.core.misc import __ansys_version__
196196

197197
if ansys_path is None:
198198
ansys_path = os.environ.get(

ansys/dpf/core/server_types.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
from ansys.dpf.core import errors, session
2424
from ansys.dpf.core._version import (
2525
server_to_ansys_grpc_dpf_version,
26-
server_to_ansys_version,
27-
__ansys_version__
26+
server_to_ansys_version
2827
)
28+
from ansys.dpf.core.misc import __ansys_version__
2929
from ansys.dpf.gate import load_api, data_processing_grpcapi
3030

3131
import logging
@@ -43,12 +43,11 @@
4343

4444
def _get_dll_path(name, ansys_path=None):
4545
"""Helper function to get the right dll path for Linux or Windows"""
46-
from ansys.dpf.core import _version
4746
ISPOSIX = os.name == "posix"
4847
if ansys_path is None:
4948
ansys_path = os.environ.get("ANSYS_DPF_PATH")
5049
if ansys_path is None:
51-
ANSYS_INSTALL = os.environ.get("AWP_ROOT" + str(_version.__ansys_version__), None)
50+
ANSYS_INSTALL = os.environ.get("AWP_ROOT" + str(__ansys_version__), None)
5251
else:
5352
ANSYS_INSTALL = ansys_path
5453
SUB_FOLDERS = os.path.join(ANSYS_INSTALL, load_api._get_path_in_install())

tests/test_launcher.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def reset_server():
6363
reason="Ans.Dpf.Grpc.bat and .sh need AWP_ROOT221 for 221 install",
6464
)
6565
def test_start_local_custom_ansys_path(self, server_config):
66-
path = os.environ["AWP_ROOT" + str(core._version.__ansys_version__)]
66+
path = os.environ["AWP_ROOT" + str(core.misc.__ansys_version__)]
6767
try:
68-
os.unsetenv("AWP_ROOT" + str(core._version.__ansys_version__))
68+
os.unsetenv("AWP_ROOT" + str(core.misc.__ansys_version__))
6969
except:
70-
del os.environ["AWP_ROOT" + str(core._version.__ansys_version__)]
70+
del os.environ["AWP_ROOT" + str(core.misc.__ansys_version__)]
7171
try:
7272
server = core.start_local_server(
7373
ansys_path=path,
@@ -80,12 +80,12 @@ def test_start_local_custom_ansys_path(self, server_config):
8080
p = psutil.Process(server.info["server_process_id"])
8181
assert path in p.cwd()
8282
os.environ[
83-
"AWP_ROOT" + str(core._version.__ansys_version__)
84-
] = path
83+
"AWP_ROOT" + str(core.misc.__ansys_version__)
84+
] = path
8585
except Exception as e:
8686
os.environ[
87-
"AWP_ROOT" + str(core._version.__ansys_version__)
88-
] = path
87+
"AWP_ROOT" + str(core.misc.__ansys_version__)
88+
] = path
8989
raise e
9090

9191
def test_start_local_no_ansys_path(self, server_config):
@@ -107,32 +107,32 @@ def test_start_local_no_ansys_path(self, server_config):
107107
)
108108
def test_start_local_ansys_path_environment_variable(self, server_config):
109109
awp_root = os.environ[
110-
"AWP_ROOT" + str(core._version.__ansys_version__)
111-
]
110+
"AWP_ROOT" + str(core.misc.__ansys_version__)
111+
]
112112
try:
113113
os.environ["ANSYS_DPF_PATH"] = awp_root
114114
try:
115-
os.unsetenv("AWP_ROOT" + str(core._version.__ansys_version__))
115+
os.unsetenv("AWP_ROOT" + str(core.misc.__ansys_version__))
116116
except:
117117
del os.environ[
118-
"AWP_ROOT" + str(core._version.__ansys_version__)
119-
]
118+
"AWP_ROOT" + str(core.misc.__ansys_version__)
119+
]
120120
server = core.start_local_server(
121121
use_docker_by_default=False, config=server_config
122122
)
123123
assert isinstance(server.os, str)
124124
os.environ[
125-
"AWP_ROOT" + str(core._version.__ansys_version__)
126-
] = awp_root
125+
"AWP_ROOT" + str(core.misc.__ansys_version__)
126+
] = awp_root
127127
try:
128128
os.unsetenv("ANSYS_DPF_PATH")
129129
except:
130130
del os.environ["ANSYS_DPF_PATH"]
131131

132132
except Exception as e:
133133
os.environ[
134-
"AWP_ROOT" + str(core._version.__ansys_version__)
135-
] = awp_root
134+
"AWP_ROOT" + str(core.misc.__ansys_version__)
135+
] = awp_root
136136
try:
137137
os.unsetenv("ANSYS_DPF_PATH")
138138
except:

tests/test_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def test_load_api_without_awp_root():
284284
legacy_conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True)
285285
loc_serv = dpf.core.start_local_server(config=legacy_conf, as_global=False)
286286

287-
awp_root_name = "AWP_ROOT" + dpf.core._version.__ansys_version__
287+
awp_root_name = "AWP_ROOT" + dpf.core.misc.__ansys_version__
288288
awp_root_save = os.environ.get(awp_root_name, None)
289289

290290
# without awp_root
@@ -365,7 +365,7 @@ def test_load_api_without_awp_root_no_gatebin():
365365
legacy_conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True)
366366
loc_serv = dpf.core.start_local_server(config=legacy_conf, as_global=False)
367367

368-
awp_root_name = "AWP_ROOT" + dpf.core._version.__ansys_version__
368+
awp_root_name = "AWP_ROOT" + dpf.core.misc.__ansys_version__
369369
awp_root_save = os.environ.get(awp_root_name, None)
370370

371371
# without awp_root

0 commit comments

Comments
 (0)