|
29 | 29 | import urllib.request
|
30 | 30 |
|
31 | 31 | # First, get all environment variables that start with AWP_ROOT
|
32 |
| -awp_root = {} |
| 32 | +awp_root: dict[int, str] = {} |
33 | 33 | for env_key, env_val in os.environ.items():
|
34 | 34 | if env_key.startswith("AWP_ROOT"):
|
35 | 35 | # There is an Ansys installation... Check that the version is at
|
36 | 36 | # least 2024R1. Environment variables are in the form
|
37 | 37 | # AWP_ROOT241=/path/to/2024R1
|
38 | 38 | #
|
39 | 39 | # Get the version number
|
40 |
| - version = env_key.split("AWP_ROOT")[1] |
41 |
| - if version < "241": |
| 40 | + version = int(env_key.split("AWP_ROOT")[1]) |
| 41 | + if version < 241: |
42 | 42 | # This version is too old, so we will ignore it
|
43 | 43 | continue
|
44 | 44 | else:
|
|
95 | 95 | # Copy the Geometry Service files to the temporary directory
|
96 | 96 | print(f">>> Copying Geometry Service files to temporary directory to {TMP_DIR}")
|
97 | 97 | if backend_selection == 1:
|
98 |
| - BIN_DIR = TMP_DIR / "bins" / "DockerWindows" / "bin" / "x64" / "Release_Headless" / "net472" |
| 98 | + BIN_DIR = TMP_DIR / "archive" / "bin" / "x64" / "Release_Headless" / "net472" |
99 | 99 | else:
|
100 |
| - BIN_DIR = TMP_DIR / "bins" / "DockerWindows" / "bin" / "x64" / "Release_Core_Windows" / "net8.0" |
| 100 | + BIN_DIR = TMP_DIR / "archive" / "bin" / "x64" / "Release_Core_Windows" / "net8.0" |
101 | 101 |
|
102 | 102 | # Create the directory structure
|
103 | 103 | shutil.copytree(
|
|
110 | 110 | zip_file = shutil.make_archive(
|
111 | 111 | "windows-dms-binaries" if backend_selection == 1 else "windows-core-binaries",
|
112 | 112 | "zip",
|
113 |
| - root_dir=TMP_DIR / "bins", |
| 113 | + root_dir=TMP_DIR / "archive", |
114 | 114 | )
|
115 | 115 |
|
116 | 116 | # Move the ZIP file to the docker directory
|
|
119 | 119 |
|
120 | 120 | # Remove the temporary directory
|
121 | 121 | print(">>> Removing Geometry Service files")
|
122 |
| -shutil.rmtree(TMP_DIR / "bins") |
| 122 | +shutil.rmtree(TMP_DIR / "archive") |
123 | 123 |
|
124 | 124 | # Download the Dockerfile from the repository
|
125 | 125 | print(">>> Downloading Dockerfile")
|
|
146 | 146 | line = dockerfile.find("ENV AWP_ROOT")
|
147 | 147 | if line != -1:
|
148 | 148 | # Get the environment variable name
|
149 |
| - env_var = dockerfile[line : LENGTH_NO_VER + line] + ANSYS_VER |
| 149 | + env_var = f"{dockerfile[line : LENGTH_NO_VER + line]}{ANSYS_VER}" |
150 | 150 | # Replace the environment variable with the correct value
|
151 | 151 | dockerfile = dockerfile.replace(
|
152 | 152 | dockerfile[line : LENGTH_VER + line],
|
153 | 153 | env_var,
|
154 | 154 | )
|
| 155 | + # Write the updated Dockerfile |
| 156 | + with Path.open(TMP_DIR / "Dockerfile", "w") as f: |
| 157 | + f.write(dockerfile) |
155 | 158 | else:
|
156 | 159 | print(
|
157 | 160 | "XXXXXXX No AWP_ROOT environment variable found in Dockerfile.. exiting process. XXXXXXX" # noqa: E501
|
|
0 commit comments