-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
67 lines (56 loc) · 1.81 KB
/
Copy path__init__.py
File metadata and controls
67 lines (56 loc) · 1.81 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import importlib
import subprocess
import sys
import os
def windows_dependencies():
packages = {
"laspy": "laspy",
"scipy": "scipy",
"osgeo.gdal": "gdal",
"osgeo.osr": "gdal",
"matplotlib": "matplotlib",
"reportlab": "reportlab",
"sklearn": "scikit-learn",
"shapely": "shapely"
}
python_exe = sys.executable
if not os.path.basename(python_exe).lower().startswith("python"):
python_exe = "python"
for mod_name, pip_name in packages.items():
try:
importlib.import_module(mod_name)
except ImportError:
try:
subprocess.check_call([python_exe, "-m", "pip", "install", pip_name])
except Exception as e:
from qgis.PyQt.QtWidgets import QMessageBox
QMessageBox.critical(None, "Dependency installation failed",
f"Failed to install {pip_name}\n\nError: {e}")
raise
def other_so_dependencies():
from pip._internal.cli.main import main as pip_main
packages = {
"laspy": "laspy[lazrs,laszip]",
"scipy": "scipy",
"osgeo.gdal": None,
"osgeo.osr": None,
"matplotlib": "matplotlib",
"reportlab": "reportlab",
"sklearn": "scikit-learn",
"shapely": "shapely"
}
for module_name, pip_name in packages.items():
try:
importlib.import_module(module_name)
except ImportError:
if pip_name is not None:
pip_main(["install", "--upgrade", pip_name])
def ensure_dependencies():
if sys.platform == "win32":
windows_dependencies()
else:
other_so_dependencies()
def classFactory(iface):
ensure_dependencies()
from .my_lidar import MyLiDARPlugin
return MyLiDARPlugin(iface)