Skip to content

Commit acd02be

Browse files
committed
fix: reverted all files
1 parent a9a968a commit acd02be

File tree

5 files changed

+115
-114
lines changed

5 files changed

+115
-114
lines changed

.ci/build_wheel.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import argparse
55
import subprocess
6-
from pathlib import Path
76
import os
87
import sys
98
import shutil
@@ -40,13 +39,15 @@
4039
print("Created temporary directory: ", tmpdirname)
4140

4241
# Create the temporary build-opts.cfg
43-
build_opts_path = Path(tmpdirname) / "build-opts.cfg"
44-
45-
build_opts_path.write_text(f"[bdist_wheel]\nplat-name={requested_platform}", encoding="utf-8")
46-
os.environ["DIST_EXTRA_CONFIG"] = str(build_opts_path)
42+
build_opts_path = os.path.join(tmpdirname, "build-opts.cfg")
43+
with open(build_opts_path, "w") as build_opts_file:
44+
build_opts_file.write(f"[bdist_wheel]\nplat-name={requested_platform}")
45+
os.environ["DIST_EXTRA_CONFIG"] = build_opts_path
4746

4847
# Move the binaries
49-
gatebin_folder_path = Path.cwd() / "src" / "ansys" / "dpf" / "gatebin"
48+
gatebin_folder_path = os.path.join(
49+
os.path.curdir, os.path.join("src", "ansys", "dpf", "gatebin")
50+
)
5051
binaries_to_move = []
5152
moved = []
5253
if "win" in requested_platform or "any" == requested_platform:
@@ -59,15 +60,15 @@
5960
binaries_to_move.extend(["_version.py"])
6061

6162
for binary_name in binaries_to_move:
62-
src = gatebin_folder_path / binary_name
63-
dst = Path(tmpdirname) / binary_name
63+
src = os.path.join(gatebin_folder_path, binary_name)
64+
dst = os.path.join(tmpdirname, binary_name)
6465
print(f"Moving {src} to {dst}")
6566
shutil.move(src=src, dst=dst)
6667
moved.append([dst, src])
6768

6869
if "any" == requested_platform:
6970
# Also remove the gatebin folder
70-
gatebin_folder_path.rmdir()
71+
os.rmdir(gatebin_folder_path)
7172

7273
# Call the build
7374
if not args.wheelhouse:
@@ -82,7 +83,7 @@
8283

8384
if "any" == requested_platform:
8485
# Recreate the gatebin folder
85-
gatebin_folder_path.mkdir()
86+
os.mkdir(gatebin_folder_path)
8687

8788
# Move binaries back
8889
for move_back in moved:

.ci/code_generation.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
import shutil
99

1010

11-
local_dir = Path(__file__).parent
12-
TARGET_PATH = local_dir.parent / "src" / "ansys" / "dpf" / "core" / "operators"
13-
files = glob.glob(str(TARGET_PATH / "*"))
11+
local_dir = os.path.dirname(os.path.abspath(__file__))
12+
TARGET_PATH = os.path.join(local_dir, os.pardir, "src", "ansys", "dpf", "core", "operators")
13+
files = glob.glob(os.path.join(TARGET_PATH, "*"))
1414
for f in files:
15-
file_path = Path(f)
16-
if file_path.stem == "specification":
15+
if Path(f).stem == "specification":
1716
continue
18-
if file_path.name == "build.py":
17+
if Path(f).name == "build.py":
1918
continue
20-
if file_path.name == "operator.mustache":
19+
if Path(f).name == "operator.mustache":
2120
continue
2221
try:
23-
if file_path.is_dir():
24-
shutil.rmtree(file_path)
22+
if os.path.isdir(f):
23+
shutil.rmtree(f)
2524
else:
26-
file_path.unlink()
25+
os.remove(f)
2726
except:
2827
pass
2928

.ci/run_examples.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@
1212
os.environ["MPLBACKEND"] = "Agg"
1313

1414
actual_path = pathlib.Path(__file__).parent.absolute()
15-
examples_path = actual_path.parent / "examples"
16-
print(examples_path)
15+
print(os.path.join(actual_path, os.path.pardir, "examples"))
1716

1817
# Get the DPF server version
1918
server = dpf.server.get_or_create_server(None)
2019
server_version = server.version
2120
server.shutdown()
2221
print(f"Server version: {server_version}")
2322

24-
for root, subdirectories, files in examples_path.walk():
23+
for root, subdirectories, files in os.walk(os.path.join(actual_path, os.path.pardir, "examples")):
2524
for subdirectory in subdirectories:
26-
subdir = root / subdirectory
27-
for file in glob.iglob(str(subdir / "*.py")):
25+
subdir = os.path.join(root, subdirectory)
26+
for file in glob.iglob(os.path.join(subdir, "*.py")):
2827
if sys.platform == "linux" and "08-python-operators" in file:
2928
continue
3029
elif "win" in sys.platform and "06-distributed_stress_averaging" in file:

.ci/run_non_regression_examples.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,45 @@
99
os.environ["MPLBACKEND"] = "Agg"
1010

1111
actual_path = pathlib.Path(__file__).parent.absolute()
12-
examples_path = actual_path.parent / "examples"
13-
print(examples_path)
12+
print(os.path.join(actual_path, os.path.pardir, "examples"))
1413

1514

1615
list_tests = [
17-
examples_path / "00-basic",
18-
examples_path / "01-transient_analyses",
19-
examples_path / "02-modal_analyses",
20-
examples_path / "03-harmonic_analyses",
21-
examples_path / "06-plotting" / "00-basic_plotting.py",
22-
examples_path / "06-plotting" / "05-plot_on_warped_mesh.py",
23-
examples_path / "07-distributed-post" / "00-distributed_total_disp.py",
16+
os.path.join(actual_path, os.path.pardir, "examples", "00-basic"),
17+
os.path.join(actual_path, os.path.pardir, "examples", "01-transient_analyses"),
18+
os.path.join(actual_path, os.path.pardir, "examples", "02-modal_analyses"),
19+
os.path.join(actual_path, os.path.pardir, "examples", "03-harmonic_analyses"),
20+
os.path.join(actual_path, os.path.pardir, "examples", "06-plotting", "00-basic_plotting.py"),
21+
os.path.join(
22+
actual_path,
23+
os.path.pardir,
24+
"examples",
25+
"06-plotting",
26+
"05-plot_on_warped_mesh.py",
27+
),
28+
os.path.join(
29+
actual_path,
30+
os.path.pardir,
31+
"examples",
32+
"07-distributed-post",
33+
"00-distributed_total_disp.py",
34+
),
2435
]
2536

2637
if core.SERVER_CONFIGURATION != core.AvailableServerConfigs.InProcessServer:
27-
list_tests.append(examples_path / "08-python-operators" / "00-wrapping_numpy_capabilities.py")
38+
list_tests.append(
39+
os.path.join(
40+
actual_path,
41+
os.path.pardir,
42+
"examples",
43+
"08-python-operators",
44+
"00-wrapping_numpy_capabilities.py",
45+
)
46+
)
2847

2948
for path in list_tests:
30-
if path.is_dir():
31-
for file in glob.iglob(str(path / "*.py")):
49+
if os.path.isdir(path):
50+
for file in glob.iglob(os.path.join(path, "*.py")):
3251
print("\n--------------------------------------------------")
3352
print(file)
3453
try:

.ci/update_dpf_dependencies.py

Lines changed: 60 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,69 @@
1-
"""Script to update ansys.dpf.gate.generated, ansys.dpf.gatebin and ansys.grpc.dpf.
2-
3-
This script should only be used to quickly test changes to any of these dependencies.
4-
Actual commit of updated code should not occur.
5-
The GitHub pipelines take care of the actual update in ansys-dpf-core.
6-
7-
Define environment variables to know where to get the code from:
8-
- "DPFDV_ROOT" defines the DPF repo where ansys-grpc-dpf resides.
9-
Will unzip the latest wheel built in DPF/proto/dist/.
10-
- "ANSYSDPFPYGATE_ROOT" defines where the ansys-dpf-pygate repository resides.
11-
12-
It will update the current repo
13-
or the repo defined by the environment variable "ANSYSDPFCORE_ROOT" if it exists.
14-
"""
15-
161
import os
172
import glob
18-
from pathlib import Path
19-
import platform
20-
import shutil
21-
import zipfile
3+
from ansys.dpf import core
4+
import pathlib
5+
import subprocess
6+
import sys
227

8+
os.environ["PYVISTA_OFF_SCREEN"] = "true"
9+
os.environ["MPLBACKEND"] = "Agg"
2310

24-
grpc_path_key = "DPFDV_ROOT"
25-
gate_path_key = "ANSYSDPFPYGATE_ROOT"
26-
core_path = Path(__file__).parent.parent
27-
if "ANSYSDPFCORE_ROOT" in os.environ:
28-
core_path = os.environ["ANSYSDPFCORE_ROOT"]
11+
actual_path = pathlib.Path(__file__).parent.absolute()
12+
print(os.path.join(actual_path, os.path.pardir, "examples"))
2913

30-
grpc_path = os.getenv(grpc_path_key, None)
31-
gate_path = os.getenv(gate_path_key, None)
3214

33-
if grpc_path:
34-
# Update ansys-grpc-dpf with latest in proto/dist
35-
print("Updating ansys.grpc.dpf")
36-
dist_path = Path(grpc_path) / "proto" / "dist" / "*"
37-
print(f"from {dist_path}")
38-
destination = Path(core_path) / "src"
39-
print(f"into {destination}")
40-
latest_wheel = max(glob.glob(str(dist_path)), key=os.path.getctime)
41-
with zipfile.ZipFile(latest_wheel, "r") as wheel:
42-
for file in wheel.namelist():
43-
# print(file)
44-
if file.startswith("ansys/"):
45-
wheel.extract(
46-
file,
47-
path=destination,
48-
)
49-
print("Done updating ansys.grpc.dpf")
50-
else:
51-
print(f"{grpc_path_key} environment variable is not defined. " "Cannot update ansys-grpc-dpf.")
15+
list_tests = [
16+
os.path.join(actual_path, os.path.pardir, "examples", "00-basic"),
17+
os.path.join(actual_path, os.path.pardir, "examples", "01-transient_analyses"),
18+
os.path.join(actual_path, os.path.pardir, "examples", "02-modal_analyses"),
19+
os.path.join(actual_path, os.path.pardir, "examples", "03-harmonic_analyses"),
20+
os.path.join(actual_path, os.path.pardir, "examples", "06-plotting", "00-basic_plotting.py"),
21+
os.path.join(
22+
actual_path,
23+
os.path.pardir,
24+
"examples",
25+
"06-plotting",
26+
"05-plot_on_warped_mesh.py",
27+
),
28+
os.path.join(
29+
actual_path,
30+
os.path.pardir,
31+
"examples",
32+
"07-distributed-post",
33+
"00-distributed_total_disp.py",
34+
),
35+
]
5236

53-
if gate_path:
54-
# Update ansys-dpf-gate
55-
print("Updating ansys.dpf.gate generated code")
56-
dist_path = Path(gate_path) / "ansys-dpf-gate" / "ansys" / "dpf" / "gate" / "generated"
57-
print(f"from {dist_path}")
58-
destination = Path(core_path) / "src" / "ansys" / "dpf" / "gate" / "generated"
59-
print(f"into {destination}")
60-
shutil.copytree(
61-
src=dist_path,
62-
dst=destination,
63-
dirs_exist_ok=True,
64-
ignore=lambda directory, contents: ["__pycache__"] if str(directory)[-5:] == "gate" else [],
37+
if core.SERVER_CONFIGURATION != core.AvailableServerConfigs.InProcessServer:
38+
list_tests.append(
39+
os.path.join(
40+
actual_path,
41+
os.path.pardir,
42+
"examples",
43+
"08-python-operators",
44+
"00-wrapping_numpy_capabilities.py",
45+
)
6546
)
6647

67-
dist_path = Path(gate_path) / "ansys-dpf-gate" / "ansys" / "dpf" / "gate" / "__init__.py"
68-
print(f"from {dist_path}")
69-
destination = Path(core_path) / "src" / "ansys" / "dpf" / "gate" / "__init__.py"
70-
print(f"into {destination}")
71-
shutil.copy(src=dist_path, dst=destination)
72-
print("Done updating ansys.dpf.gate generated code")
73-
74-
# Update ansys-dpf-gatebin
75-
print("Updating ansys.dpf.gatebin")
76-
dist_path = Path(gate_path) / "ansys-dpf-gatebin" / "ansys"
77-
print(f"from {dist_path}")
78-
destination = Path(core_path) / "src" / "ansys"
79-
print(f"into {destination}")
80-
shutil.copytree(src=dist_path, dst=destination, dirs_exist_ok=True)
81-
print(f"Done updating ansys.dpf.gatebin for {platform.system()}")
82-
else:
83-
print(
84-
f"{gate_path_key} environment variable is not defined. "
85-
"Cannot update ansys.dpf.gate or ansys.dpf.gatebin."
86-
)
48+
for path in list_tests:
49+
if os.path.isdir(path):
50+
for file in glob.iglob(os.path.join(path, "*.py")):
51+
print("\n--------------------------------------------------")
52+
print(file)
53+
try:
54+
subprocess.check_call([sys.executable, file])
55+
except subprocess.CalledProcessError as e:
56+
sys.stderr.write(str(e.args))
57+
if e.returncode != 3221225477:
58+
raise e
59+
print("PASS")
60+
else:
61+
print("\n--------------------------------------------------")
62+
print(path)
63+
try:
64+
subprocess.check_call([sys.executable, file])
65+
except subprocess.CalledProcessError as e:
66+
sys.stderr.write(str(e.args))
67+
if e.returncode != 3221225477:
68+
raise e
69+
print("PASS")

0 commit comments

Comments
 (0)