-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdependencies_checker.py
38 lines (34 loc) · 1.34 KB
/
dependencies_checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import shutil
import os
import sys
import platform
class DependenciesChecker:
"""
A class to check and configure dependencies.
Methods:
check_imagemagick():
Checks if ImageMagick is installed on the system.
configure_imagemagick():
Configures the environment to use a bundled version of ImageMagick.
check_and_configure_imagemagick():
Checks if ImageMagick is installed and configures it if not found.
"""
@staticmethod
def check_imagemagick():
return shutil.which("magick") is not None
@staticmethod
def configure_imagemagick():
dll_path = os.path.join(os.path.dirname(sys.argv[0]), 'ImageMagick')
os.environ['PATH'] = dll_path + os.pathsep + os.environ.get('PATH', '')
os.environ['MAGICK_CODER_MODULE_PATH'] = dll_path
print("Using bundled ImageMagick.")
@staticmethod
def check_and_configure_imagemagick():
if DependenciesChecker.check_imagemagick():
print("Using the user's existing ImageMagick.")
else:
if platform.system() == "Windows":
print("System ImageMagick not found. Attempting to configure bundled version.")
DependenciesChecker.configure_imagemagick()
else:
print("No ImageMagick install detected on the system.")