Skip to content

Commit

Permalink
Add support for macOS < 12 with OpenCV version constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
RichieHakim committed Jan 30, 2024
1 parent e67d814 commit 713e07a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
## setup.py file for roicat
from pathlib import Path
import copy
import platform

from distutils.core import setup
import copy

## Get the parent directory of this file
dir_parent = Path(__file__).parent

## Get requirements from requirements.txt
def read_requirements():
with open(str(dir_parent / "requirements.txt"), "r") as req:
content = req.read() ## read the file
Expand All @@ -18,14 +22,24 @@ def read_requirements():
requirements = [req.replace(",", "").replace("\"", "").replace("\'", "").strip() for req in requirements]

return requirements

deps_all = read_requirements()


## Dependencies: latest versions of requirements
### remove everything starting and after the first =,>,<,! sign
deps_names = [req.split('=')[0].split('>')[0].split('<')[0].split('!')[0] for req in deps_all]
deps_all_dict = dict(zip(deps_names, deps_all))
deps_all_latest = copy.deepcopy(deps_names)
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


## Make different versions of dependencies
### Also pull out the version number from the requirements (specified in deps_all_dict values).
Expand Down

0 comments on commit 713e07a

Please sign in to comment.