Skip to content

Commit

Permalink
doc: change to only .ci files
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-ad committed Dec 5, 2024
1 parent afdf633 commit 8bf8781
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 78 deletions.
21 changes: 10 additions & 11 deletions .ci/build_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import argparse
import subprocess
from pathlib import Path
import os
import sys
import shutil
Expand Down Expand Up @@ -39,15 +40,13 @@
print("Created temporary directory: ", tmpdirname)

# Create the temporary build-opts.cfg
build_opts_path = os.path.join(tmpdirname, "build-opts.cfg")
with open(build_opts_path, "w") as build_opts_file:
build_opts_file.write(f"[bdist_wheel]\nplat-name={requested_platform}")
os.environ["DIST_EXTRA_CONFIG"] = build_opts_path
build_opts_path = Path(tmpdirname) / "build-opts.cfg"

build_opts_path.write_text(f"[bdist_wheel]\nplat-name={requested_platform}", encoding="utf-8")
os.environ["DIST_EXTRA_CONFIG"] = str(build_opts_path)

# Move the binaries
gatebin_folder_path = os.path.join(
os.path.curdir, os.path.join("src", "ansys", "dpf", "gatebin")
)
gatebin_folder_path = Path.cwd() / "src" / "ansys" / "dpf" / "gatebin"
binaries_to_move = []
moved = []
if "win" in requested_platform or "any" == requested_platform:
Expand All @@ -60,15 +59,15 @@
binaries_to_move.extend(["_version.py"])

for binary_name in binaries_to_move:
src = os.path.join(gatebin_folder_path, binary_name)
dst = os.path.join(tmpdirname, binary_name)
src = gatebin_folder_path / binary_name
dst = Path(tmpdirname) / binary_name
print(f"Moving {src} to {dst}")
shutil.move(src=src, dst=dst)
moved.append([dst, src])

if "any" == requested_platform:
# Also remove the gatebin folder
os.rmdir(gatebin_folder_path)
gatebin_folder_path.rmdir()

# Call the build
if not args.wheelhouse:
Expand All @@ -83,7 +82,7 @@

if "any" == requested_platform:
# Recreate the gatebin folder
os.mkdir(gatebin_folder_path)
gatebin_folder_path.mkdir()

# Move binaries back
for move_back in moved:
Expand Down
19 changes: 10 additions & 9 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
import shutil


local_dir = os.path.dirname(os.path.abspath(__file__))
TARGET_PATH = os.path.join(local_dir, os.pardir, "src", "ansys", "dpf", "core", "operators")
files = glob.glob(os.path.join(TARGET_PATH, "*"))
local_dir = Path(__file__).parent
TARGET_PATH = local_dir.parent / "src" / "ansys" / "dpf" / "core" / "operators"
files = glob.glob(str(TARGET_PATH / "*"))
for f in files:
if Path(f).stem == "specification":
file_path = Path(f)
if file_path.stem == "specification":
continue
if Path(f).name == "build.py":
if file_path.name == "build.py":
continue
if Path(f).name == "operator.mustache":
if file_path.name == "operator.mustache":
continue
try:
if os.path.isdir(f):
shutil.rmtree(f)
if file_path.is_dir():
shutil.rmtree(file_path)
else:
os.remove(f)
file_path.unlink()
except:
pass

Expand Down
9 changes: 5 additions & 4 deletions .ci/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
os.environ["MPLBACKEND"] = "Agg"

actual_path = pathlib.Path(__file__).parent.absolute()
print(os.path.join(actual_path, os.path.pardir, "examples"))
examples_path = actual_path.parent / "examples"
print(examples_path)

# Get the DPF server version
server = dpf.server.get_or_create_server(None)
server_version = server.version
server.shutdown()
print(f"Server version: {server_version}")

for root, subdirectories, files in os.walk(os.path.join(actual_path, os.path.pardir, "examples")):
for root, subdirectories, files in examples_path.walk():
for subdirectory in subdirectories:
subdir = os.path.join(root, subdirectory)
for file in glob.iglob(os.path.join(subdir, "*.py")):
subdir = root / subdirectory
for file in glob.iglob(str(subdir / "*.py")):
if sys.platform == "linux" and "08-python-operators" in file:
continue
elif "win" in sys.platform and "06-distributed_stress_averaging" in file:
Expand Down
43 changes: 12 additions & 31 deletions .ci/run_non_regression_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,26 @@
os.environ["MPLBACKEND"] = "Agg"

actual_path = pathlib.Path(__file__).parent.absolute()
print(os.path.join(actual_path, os.path.pardir, "examples"))
examples_path = actual_path.parent / "examples"
print(examples_path)


list_tests = [
os.path.join(actual_path, os.path.pardir, "examples", "00-basic"),
os.path.join(actual_path, os.path.pardir, "examples", "01-transient_analyses"),
os.path.join(actual_path, os.path.pardir, "examples", "02-modal_analyses"),
os.path.join(actual_path, os.path.pardir, "examples", "03-harmonic_analyses"),
os.path.join(actual_path, os.path.pardir, "examples", "06-plotting", "00-basic_plotting.py"),
os.path.join(
actual_path,
os.path.pardir,
"examples",
"06-plotting",
"05-plot_on_warped_mesh.py",
),
os.path.join(
actual_path,
os.path.pardir,
"examples",
"07-distributed-post",
"00-distributed_total_disp.py",
),
examples_path / "00-basic",
examples_path / "01-transient_analyses",
examples_path / "02-modal_analyses",
examples_path / "03-harmonic_analyses",
examples_path / "06-plotting" / "00-basic_plotting.py",
examples_path / "06-plotting" / "05-plot_on_warped_mesh.py",
examples_path / "07-distributed-post" / "00-distributed_total_disp.py",
]

if core.SERVER_CONFIGURATION != core.AvailableServerConfigs.InProcessServer:
list_tests.append(
os.path.join(
actual_path,
os.path.pardir,
"examples",
"08-python-operators",
"00-wrapping_numpy_capabilities.py",
)
)
list_tests.append(examples_path / "08-python-operators" / "00-wrapping_numpy_capabilities.py")

for path in list_tests:
if os.path.isdir(path):
for file in glob.iglob(os.path.join(path, "*.py")):
if path.is_dir():
for file in glob.iglob(str(path / "*.py")):
print("\n--------------------------------------------------")
print(file)
try:
Expand Down
40 changes: 17 additions & 23 deletions .ci/update_dpf_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@

import os
import glob
import pathlib
from pathlib import Path
import platform
import shutil
import zipfile


grpc_path_key = "DPFDV_ROOT"
gate_path_key = "ANSYSDPFPYGATE_ROOT"
core_path = pathlib.Path(__file__).parent.parent.resolve()
core_path = Path(__file__).parent.parent
if "ANSYSDPFCORE_ROOT" in os.environ:
core_path = os.environ["ANSYSDPFCORE_ROOT"]

grpc_path = os.getenv(grpc_path_key, None)
gate_path = os.getenv(gate_path_key, None)

if grpc_path is not None:
if grpc_path:
# Update ansys-grpc-dpf with latest in proto/dist
print("Updating ansys.grpc.dpf")
dist_path = os.path.join(grpc_path, "proto", "dist", "*")
dist_path = Path(grpc_path) / "proto" / "dist" / "*"
print(f"from {dist_path}")
destination = os.path.join(core_path, "src")
destination = Path(core_path) / "src"
print(f"into {destination}")
latest_wheel = max(glob.glob(dist_path), key=os.path.getctime)
latest_wheel = max(glob.glob(str(dist_path)), key=os.path.getctime)
with zipfile.ZipFile(latest_wheel, "r") as wheel:
for file in wheel.namelist():
# print(file)
Expand All @@ -50,40 +50,34 @@
else:
print(f"{grpc_path_key} environment variable is not defined. " "Cannot update ansys-grpc-dpf.")

if gate_path is not None:
if gate_path:
# Update ansys-dpf-gate
print("Updating ansys.dpf.gate generated code")
dist_path = os.path.join(gate_path, "ansys-dpf-gate", "ansys", "dpf", "gate", "generated")
dist_path = Path(gate_path) / "ansys-dpf-gate" / "ansys" / "dpf" / "gate" / "generated"
print(f"from {dist_path}")
destination = os.path.join(core_path, "src", "ansys", "dpf", "gate", "generated")
destination = Path(core_path) / "src" / "ansys" / "dpf" / "gate" / "generated"
print(f"into {destination}")
shutil.copytree(
src=dist_path,
dst=destination,
dirs_exist_ok=True,
ignore=lambda directory, contents: ["__pycache__"] if directory[-5:] == "gate" else [],
ignore=lambda directory, contents: ["__pycache__"] if str(directory)[-5:] == "gate" else [],
)
dist_path = os.path.join(gate_path, "ansys-dpf-gate", "ansys", "dpf", "gate", "__init__.py")

dist_path = Path(gate_path) / "ansys-dpf-gate" / "ansys" / "dpf" / "gate" / "__init__.py"
print(f"from {dist_path}")
destination = os.path.join(core_path, "src", "ansys", "dpf", "gate", "__init__.py")
destination = Path(core_path) / "src" / "ansys" / "dpf" / "gate" / "__init__.py"
print(f"into {destination}")
shutil.copy(
src=dist_path,
dst=destination,
)
shutil.copy(src=dist_path, dst=destination)
print("Done updating ansys.dpf.gate generated code")

# Update ansys-dpf-gatebin
print("Updating ansys.dpf.gatebin")
dist_path = os.path.join(gate_path, "ansys-dpf-gatebin", "ansys")
dist_path = Path(gate_path) / "ansys-dpf-gatebin" / "ansys"
print(f"from {dist_path}")
destination = os.path.join(core_path, "src", "ansys")
destination = Path(core_path) / "src" / "ansys"
print(f"into {destination}")
shutil.copytree(
src=dist_path,
dst=destination,
dirs_exist_ok=True,
)
shutil.copytree(src=dist_path, dst=destination, dirs_exist_ok=True)
print(f"Done updating ansys.dpf.gatebin for {platform.system()}")
else:
print(
Expand Down

0 comments on commit 8bf8781

Please sign in to comment.