Skip to content

Commit

Permalink
switch deps from - to _ and fix bug in setup headless version
Browse files Browse the repository at this point in the history
  • Loading branch information
RichieHakim committed Jan 31, 2024
1 parent b1cfcac commit 68a9c57
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## Required
h5py
eva-decord
eva_decord
ipywidgets
kornia
matplotlib
natsort
numba
numpy
opencv-contrib-python
opencv_contrib_python
optuna
pandas
paramiko
psutil
PyYAML
pytest
scikit-learn
scikit_learn
tqdm
sparse
scipy
Expand All @@ -25,19 +25,19 @@ torchaudio

## Optional / Advanced
tables
opt-einsum
# rolling-quantiles
opt_einsum
# rolling_quantiles
pulp
spconv
torch-sparse
torch_sparse
av
pynwb
sendgrid
pycuda
cuml
cupy
cudf
scanimage-tiff-reader
scanimage_tiff_reader
jupyter
PyWavelets
mat73
46 changes: 29 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,24 @@ def read_requirements():
deps_all_latest = dict(zip(deps_names, deps_names))


## Operating system specific dependencies
### OpenCV >= 4.9 is not supported on macOS < 12
system, version = platform.system(), platform.mac_ver()[0]
if system == "Darwin" and version and ('opencv_contrib_python' in deps_all_dict):
if tuple(map(int, version.split('.'))) < (12, 0, 0):
version_opencv_macosSub12 = "opencv_contrib_python<=4.8.1.78"
deps_all_dict['opencv_contrib_python'], deps_all_latest['opencv_contrib_python'] = version_opencv_macosSub12, version_opencv_macosSub12

# Operating system specific dependencies
# OpenCV >= 4.9 is not supported on macOS < 12
system, version_macos = platform.system(), platform.mac_ver()[0]
print(f"System: {system}")
if (system == "Darwin"):
# Safely convert version string components to integers
version_parts = version_macos.split('.')
version_major_macos = int(version_parts[0])

# Check macOS version and adjust the OpenCV version accordingly
if (version_major_macos < 12) and ('opencv_contrib_python' in deps_all_dict):
version_opencv_macos_sub12 = "opencv_contrib_python<=4.8.1.78"
print(f"Detected macOS version {version_major_macos}, which is < 12. Installing an older version of OpenCV: {version_opencv_macos_sub12}")
deps_all_dict['opencv_contrib_python'] = version_opencv_macos_sub12
deps_all_latest['opencv_contrib_python'] = version_opencv_macos_sub12
import re
## find the numbers in the string
version_opencv = '.'.join(re.findall(r'[0-9]+', deps_all_dict['opencv_contrib_python']))

## Make different versions of dependencies
### Also pull out the version number from the requirements (specified in deps_all_dict values).
Expand All @@ -49,10 +59,10 @@ def read_requirements():
'kornia',
'matplotlib',
'numba',
'scikit-learn',
'scikit_learn',
'tqdm',
'h5py',
'opencv-contrib-python',
'opencv_contrib_python',
'optuna',
'sparse',
'natsort',
Expand All @@ -65,24 +75,24 @@ def read_requirements():
'torchvision',
'torchaudio',
'ipywidgets',
'eva-decord',
'eva_decord',
]}

deps_advanced = {dep: deps_all_dict[dep] for dep in [
'tables',
'opt-einsum',
# 'rolling-quantiles',
'opt_einsum',
# 'rolling_quantiles',
'pulp',
'spconv',
'torch-sparse',
'torch_sparse',
'av',
'pynwb',
'sendgrid',
'pycuda',
'cuml',
'cupy',
'cudf',
'scanimage-tiff-reader',
'scanimage_tiff_reader',
'jupyter',
'PyWavelets',
'mat73',
Expand All @@ -93,9 +103,11 @@ def read_requirements():

## Make versions with cv2 headless (for servers)
deps_core_dict_cv2Headless = copy.deepcopy(deps_core)
deps_core_dict_cv2Headless['opencv-contrib-python'] = 'opencv-contrib-python-headless' + deps_core_dict_cv2Headless['opencv-contrib-python'][21:]
deps_core_dict_cv2Headless['opencv_contrib_python'] = 'opencv_contrib_python_headless' + '<=' + version_opencv
deps_core_latest_cv2Headless = copy.deepcopy(deps_core_latest)
deps_core_latest_cv2Headless['opencv-contrib-python'] = 'opencv-contrib-python-headless'
deps_core_latest_cv2Headless['opencv_contrib_python'] = 'opencv_contrib_python_headless'

## Print out


extras_require = {
Expand Down

0 comments on commit 68a9c57

Please sign in to comment.