|
22 | 22 | import os |
23 | 23 | import re |
24 | 24 | import shutil |
| 25 | +import tempfile |
25 | 26 | from pathlib import Path |
26 | 27 |
|
27 | 28 | import matplotlib as mpl |
@@ -90,7 +91,7 @@ def find_jar(jar_name): |
90 | 91 | logger.critical(msg) |
91 | 92 | raise RuntimeError(msg) |
92 | 93 |
|
93 | | - core_jar_path = find_jar("library/core") |
| 94 | + core_jar_path = find_jar("library/core*") |
94 | 95 | svg_jar_path = find_jar("svg") |
95 | 96 | dxf_jar_path = find_jar("dxf") |
96 | 97 | pdf_jar_path = find_jar("pdf") |
@@ -301,24 +302,36 @@ def build_signatures(v): |
301 | 302 | ) |
302 | 303 |
|
303 | 304 | # add the jars |
304 | | - def copy_jars(jar_dir, dest): |
| 305 | + def copy_jars(jar_dir, dest, *, match_regex=None): |
| 306 | + regex = re.compile(match_regex) if match_regex else None |
| 307 | + version_regex = re.compile(r"-\d\.\d\.\d") |
305 | 308 | dest.mkdir(parents=True, exist_ok=True) |
306 | 309 | for jar in jar_dir.glob("*.jar"): |
307 | | - shutil.copy(jar, dest) |
| 310 | + if regex and not regex.match(jar.name): |
| 311 | + continue |
| 312 | + shutil.copy(jar, dest / version_regex.sub("", jar.name)) |
308 | 313 |
|
309 | | - copy_jars(core_jar_path.parent, build_dir / "py5" / "jars") |
| 314 | + copy_jars( |
| 315 | + core_jar_path.parent, |
| 316 | + build_dir / "py5" / "jars", |
| 317 | + match_regex=f"(core|gluegen|jogl)(?!.*natives).*$", |
| 318 | + ) |
310 | 319 | copy_jars(svg_jar_path.parent, build_dir / "py5" / "jars" / "svg") |
311 | 320 | copy_jars(dxf_jar_path.parent, build_dir / "py5" / "jars" / "dxf") |
312 | 321 | copy_jars(pdf_jar_path.parent, build_dir / "py5" / "jars" / "pdf") |
313 | 322 | shutil.copy(py5_jar_path, build_dir / "py5" / "jars") |
314 | 323 |
|
315 | 324 | # add the native libraries |
| 325 | + temp_dir = tempfile.TemporaryDirectory() |
| 326 | + native_lib_temp_dir = Path(temp_dir.name) |
| 327 | + native_lib_temp_dir.mkdir(parents=True, exist_ok=True) |
| 328 | + for jar in core_jar_path.parent.glob("*natives*.jar"): |
| 329 | + os.system(f"cd {native_lib_temp_dir} && jar xf {jar.absolute()}") |
316 | 330 | shutil.copytree( |
317 | | - core_jar_path.parent, |
| 331 | + native_lib_temp_dir / "natives", |
318 | 332 | build_dir / "py5" / "natives", |
319 | | - ignore=lambda _, names: [n for n in names if Path(n).suffix == ".jar"], |
320 | | - dirs_exist_ok=True, |
321 | 333 | ) |
| 334 | + temp_dir.cleanup() |
322 | 335 |
|
323 | 336 | build_dir.touch() |
324 | 337 |
|
|
0 commit comments