|
12 | 12 |
|
13 | 13 | from __future__ import annotations |
14 | 14 |
|
| 15 | +from importlib.util import find_spec |
15 | 16 | from pathlib import Path |
16 | 17 |
|
17 | | -import pymunk |
18 | 18 | from PyInstaller.compat import is_darwin, is_unix, is_win |
19 | 19 |
|
20 | | -import arcade |
21 | | - |
22 | | -pymunk_path = Path(pymunk.__file__).parent |
23 | | -arcade_path = Path(arcade.__file__).parent |
24 | | - |
25 | | -datas = [ |
26 | | - ( |
27 | | - arcade_path / "resources" / "system", |
28 | | - "./arcade/resources/system", |
29 | | - ), |
30 | | - ( |
31 | | - arcade_path / "VERSION", |
32 | | - "./arcade/VERSION", |
33 | | - ), |
34 | | -] |
35 | | - |
36 | | -if is_win: |
37 | | - binaries = [ |
38 | | - (pymunk_path / "_chipmunk.pyd", "."), |
39 | | - ] |
40 | | -elif is_darwin: |
41 | | - binaries = [ |
42 | | - (pymunk_path / "_chipmunk.abi3.so", "."), |
43 | | - (arcade_path / "lib", "./arcade/lib"), |
44 | | - ] |
45 | | -elif is_unix: |
46 | | - binaries = [ |
47 | | - (pymunk_path / "_chipmunk.abi3.so", "."), |
48 | | - ] |
49 | | -else: |
| 20 | +# check for supported operating systems |
| 21 | +if not is_win and not is_darwin and not is_unix: |
50 | 22 | raise NotImplementedError( |
51 | 23 | "You are running on an unsupported operating system. " |
52 | 24 | "Only Linux, Mac, and Windows are supported." |
53 | 25 | ) |
| 26 | + |
| 27 | +datas = [] |
| 28 | +binaries = [] |
| 29 | + |
| 30 | +# Add Arcade resources |
| 31 | +arcade_spec = find_spec("arcade") |
| 32 | +if arcade_spec is None or arcade_spec.origin is None: |
| 33 | + raise ImportError("Arcade is not installed. Cannot continue.") |
| 34 | + |
| 35 | +arcade_path = Path(arcade_spec.origin).parent |
| 36 | +datas.extend( |
| 37 | + [ |
| 38 | + ( |
| 39 | + arcade_path / "resources" / "system", |
| 40 | + "./arcade/resources/system", |
| 41 | + ), |
| 42 | + ( |
| 43 | + arcade_path / "VERSION", |
| 44 | + "./arcade/VERSION", |
| 45 | + ), |
| 46 | + ] |
| 47 | +) |
| 48 | + |
| 49 | +if is_darwin: |
| 50 | + binaries.append((arcade_path / "lib", "./arcade/lib")) |
| 51 | + |
| 52 | +# Add Pymunk resources |
| 53 | +pymunk_spec = find_spec("pymunk") |
| 54 | +if pymunk_spec is not None and pymunk_spec.origin is not None: |
| 55 | + pymunk_path = Path(pymunk_spec.origin).parent |
| 56 | + |
| 57 | + if is_win: |
| 58 | + binaries.append((pymunk_path / "_chipmunk.pyd", ".")) |
| 59 | + elif is_darwin: |
| 60 | + binaries.append((pymunk_path / "_chipmunk.abi3.so", ".")) |
| 61 | + elif is_unix: |
| 62 | + binaries.append((pymunk_path / "_chipmunk.abi3.so", ".")) |
| 63 | +else: |
| 64 | + print("Pymunk is not available. Skipping Pymunk resources.") |
0 commit comments