|
11 | 11 | launch.run_pip("install packaging", "packaging requirement for depthmap script")
|
12 | 12 | from packaging.version import Version
|
13 | 13 |
|
| 14 | +def ensure(module_name, min_version=None): |
| 15 | + if launch.is_installed(module_name): |
| 16 | + if min_version is None or Version(importlib_metadata.version(module_name)) >= Version(min_version): |
| 17 | + return |
| 18 | + cmd = f'install "{module_name}>={min_version}"' if min_version is not None else f'install {module_name}' |
| 19 | + msg = f'{module_name} {min_version + " " if min_version is not None else ""}requirement for depthmap script' |
| 20 | + launch.run_pip(cmd, msg) |
| 21 | + |
14 | 22 | if not launch.is_installed("timm"): #0.6.7
|
15 | 23 | launch.run_pip('install --force-reinstall "timm==0.6.12"', "timm requirement for depthmap script")
|
16 | 24 |
|
17 |
| -if not launch.is_installed("matplotlib"): |
18 |
| - launch.run_pip("install matplotlib", "matplotlib requirement for depthmap script") |
| 25 | +ensure('matplotlib') |
| 26 | + |
| 27 | +ensure('trimesh') |
19 | 28 |
|
20 |
| -if not launch.is_installed("trimesh"): |
21 |
| - launch.run_pip("install trimesh", "requirements for depthmap script") |
22 |
| - |
23 |
| -if not launch.is_installed("numba") or Version(importlib_metadata.version("numba")) < Version("0.57.0"): |
24 |
| - launch.run_pip('install "numba>=0.57.0"', "numba requirement for depthmap script") |
25 |
| -if not launch.is_installed("vispy"): |
26 |
| - launch.run_pip("install vispy", "vispy requirement for depthmap script") |
| 29 | +ensure('numba', '0.57.0') |
| 30 | +ensure('vispy') |
27 | 31 |
|
28 |
| -if not launch.is_installed("rembg"): |
29 |
| - launch.run_pip("install rembg", "rembg requirement for depthmap script") |
| 32 | +ensure('rembg') |
30 | 33 |
|
31 | 34 | if not launch.is_installed("moviepy"):
|
32 | 35 | launch.run_pip('install "moviepy==1.0.2"', "moviepy requirement for depthmap script")
|
33 |
| -if not launch.is_installed("transforms3d"): |
34 |
| - launch.run_pip("install transforms3d", "transforms3d requirement for depthmap script") |
35 |
| -if not launch.is_installed("imageio"): #2.4.1 |
36 |
| - launch.run_pip("install imageio", "imageio requirement for depthmap script") |
37 |
| -if not launch.is_installed("imageio-ffmpeg"): |
38 |
| - launch.run_pip("install imageio-ffmpeg", "imageio-ffmpeg requirement for depthmap script") |
| 36 | +ensure('transforms3d', '0.4.1') |
| 37 | + |
| 38 | +ensure('imageio') # 2.4.1 |
| 39 | +ensure('imageio-ffmpeg') |
39 | 40 | if not launch.is_installed("networkx"):
|
40 | 41 | launch.run_pip('install install "networkx==2.5"', "networkx requirement for depthmap script")
|
41 | 42 | if platform.system() == 'Windows':
|
42 |
| - if not launch.is_installed("pyqt5"): |
43 |
| - launch.run_pip("install pyqt5", "pyqt5 requirement for depthmap script") |
| 43 | + ensure('pyqt5') |
44 | 44 |
|
45 | 45 | if platform.system() == 'Darwin':
|
46 |
| - if not launch.is_installed("pyqt6"): |
47 |
| - launch.run_pip("install pyqt6", "pyqt6 requirement for depthmap script") |
| 46 | + ensure('pyqt6') |
0 commit comments