Skip to content

Commit d43f194

Browse files
authored
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
1 parent 91f6097 commit d43f194

File tree

8 files changed

+19
-40
lines changed

8 files changed

+19
-40
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
@@ -3,7 +3,6 @@
33
version_info = 0, 5, "dev2"
44
# Nice string for the version
55
__version__ = ".".join(map(str, version_info))
6-
__ansys_version__ = "222"
76
min_server_version = "2.0"
87

98
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
@@ -207,7 +207,7 @@ def get_server_type_from_config(config=None, ansys_path=None):
207207
config.protocol == CommunicationProtocols.gRPC
208208
and not config.legacy
209209
):
210-
from ansys.dpf.core._version import __ansys_version__
210+
from ansys.dpf.core.misc import __ansys_version__
211211

212212
if ansys_path is None:
213213
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/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def server_clayer(request):
357357

358358
@pytest.fixture()
359359
def restore_awp_root(request):
360-
awp_root_name = "AWP_ROOT" + core._version.__ansys_version__
360+
awp_root_name = "AWP_ROOT" + core.misc.__ansys_version__
361361
awp_root_save = os.environ.get(awp_root_name, None)
362362
yield
363363
# restore awp_root

tests/test_launcher.py

Lines changed: 11 additions & 11 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,11 +80,11 @@ 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__)
83+
"AWP_ROOT" + str(core.misc.__ansys_version__)
8484
] = path
8585
except Exception as e:
8686
os.environ[
87-
"AWP_ROOT" + str(core._version.__ansys_version__)
87+
"AWP_ROOT" + str(core.misc.__ansys_version__)
8888
] = path
8989
raise e
9090

@@ -107,22 +107,22 @@ 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__)
110+
"AWP_ROOT" + str(core.misc.__ansys_version__)
111111
]
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__)
118+
"AWP_ROOT" + str(core.misc.__ansys_version__)
119119
]
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__)
125+
"AWP_ROOT" + str(core.misc.__ansys_version__)
126126
] = awp_root
127127
try:
128128
os.unsetenv("ANSYS_DPF_PATH")
@@ -131,7 +131,7 @@ def test_start_local_ansys_path_environment_variable(self, server_config):
131131

132132
except Exception as e:
133133
os.environ[
134-
"AWP_ROOT" + str(core._version.__ansys_version__)
134+
"AWP_ROOT" + str(core.misc.__ansys_version__)
135135
] = awp_root
136136
try:
137137
os.unsetenv("ANSYS_DPF_PATH")
@@ -182,7 +182,7 @@ def test_start_local_wrong_ansys_path(self, server_config):
182182
@staticmethod
183183
def test_launch_server_full_path(server_config):
184184
ansys_path = os.environ.get(
185-
"AWP_ROOT" + core._version.__ansys_version__, core.misc.find_ansys()
185+
"AWP_ROOT" + core.misc.__ansys_version__, core.misc.find_ansys()
186186
)
187187
if os.name == "nt":
188188
path = os.path.join(ansys_path, "aisol", "bin", "winx64")

tests/test_service.py

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

298-
awp_root_name = "AWP_ROOT" + dpf.core._version.__ansys_version__
298+
awp_root_name = "AWP_ROOT" + dpf.core.misc.__ansys_version__
299299
# delete awp_root
300300
del os.environ[awp_root_name]
301301

@@ -372,7 +372,7 @@ def test_load_api_without_awp_root_no_gatebin(restore_awp_root):
372372
legacy_conf = ServerConfig(protocol=CommunicationProtocols.gRPC, legacy=True)
373373
loc_serv = dpf.core.start_local_server(config=legacy_conf, as_global=False)
374374

375-
awp_root_name = "AWP_ROOT" + dpf.core._version.__ansys_version__
375+
awp_root_name = "AWP_ROOT" + dpf.core.misc.__ansys_version__
376376
# delete awp_root
377377
del os.environ[awp_root_name]
378378

0 commit comments

Comments
 (0)