mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-12-09 15:29:09 +00:00
Added checks for necessary python libraries
This commit is contained in:
parent
6eafbd1192
commit
e8b48fcddd
1 changed files with 22 additions and 3 deletions
|
|
@ -24,10 +24,29 @@
|
|||
# Some planetary datasets use planetocentric or planetographic projections — still usable for 2D mapping.
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
def require_module(name, alias=None, install_hint=None):
|
||||
try:
|
||||
module = __import__(name)
|
||||
if alias:
|
||||
globals()[alias] = module
|
||||
else:
|
||||
globals()[name] = module
|
||||
except ImportError:
|
||||
print(f"Error: This script requires the '{name}' package.")
|
||||
if install_hint:
|
||||
print(f"Install it using: {install_hint}")
|
||||
else:
|
||||
print(f"Try: pip install {name}")
|
||||
sys.exit(1)
|
||||
|
||||
# Require necessary modules
|
||||
require_module('rasterio', install_hint='pip install rasterio')
|
||||
require_module('numpy', alias='np', install_hint='pip install numpy')
|
||||
|
||||
# Standard, should always be available:
|
||||
import argparse
|
||||
import numpy as np
|
||||
import rasterio
|
||||
from rasterio.enums import Resampling
|
||||
import json
|
||||
|
||||
# ----------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue