forked from RichieHakim/face-rhythm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
163 lines (132 loc) · 5.29 KB
/
setup.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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
## setup.py file for roicat
from pathlib import Path
import copy
import platform
from distutils.core import setup
## 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
requirements = content.split("\n") ## make a list of requirements split by (\n) which is the new line character
## Filter out any empty strings from the list
requirements = [req for req in requirements if req]
## Filter out any lines starting with #
requirements = [req for req in requirements if not req.startswith("#")]
## Remove any commas, quotation marks, and spaces from each requirement
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 = dict(zip(deps_names, deps_names))
# 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']))
if len(version_opencv) > 0:
version_opencv = f"<={version_opencv}"
## Make different versions of dependencies
### Also pull out the version number from the requirements (specified in deps_all_dict values).
deps_core = [deps_all_dict[dep] for dep in [
'numpy',
'jupyter',
'notebook',
'tensorly',
'opencv_contrib_python',
'matplotlib',
'scikit_learn',
'scikit_image',
'pyyaml',
'tqdm',
'h5py',
'ipywidgets',
'Pillow',
'eva_decord',
'natsort',
'pandas',
'tables',
'einops',
'pytest',
'torch',
'torchvision',
'torchaudio',
'nvidia_ml_py3',
'py_cpuinfo',
'GPUtil',
'psutil',
'requests',
]]
## Make versions with cv2 headless (for servers)
deps_all_dict_cv2Headless = copy.deepcopy(deps_all_dict)
deps_all_dict_cv2Headless['opencv_contrib_python'] = 'opencv_contrib_python_headless' + version_opencv
deps_all_latest_cv2Headless = copy.deepcopy(deps_all_latest)
deps_all_latest_cv2Headless['opencv_contrib_python'] = 'opencv_contrib_python_headless'
## Get README.md
with open(str(dir_parent / "README.md"), "r") as f:
readme = f.read()
## Get face-rhythm version number
with open(str(dir_parent / "face_rhythm" / "__init__.py"), "r") as f:
for line in f:
if line.startswith("__version__"):
version = line.split("=")[1].strip().replace("\"", "").replace("\'", "")
break
setup(
name='face_rhythm',
version=version,
keywords=['neuroscience', 'neuroimaging', 'machine learning'],
description="A pipeline for analysis of facial behavior using optical flow",
long_description=readme,
long_description_content_type='text/markdown',
# The project's main homepage.
url='https://github.com/RichieHakim/face-rhythm',
# Author details
author='Rich Hakim',
# Choose your license
license='LICENSE',
# Supported platforms
platforms=['Any'],
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',
# Indicate who your project is intended for
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Bio-Informatics',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
],
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
# packages=setuptools.find_packages(),
packages=['face_rhythm'],
install_requires=[],
extras_require={
'all': list(deps_all_dict.values()),
'all_latest': list(deps_all_latest.values()),
'all_cv2Headless': list(deps_all_dict_cv2Headless.values()),
'all_latest_cv2Headless': list(deps_all_latest_cv2Headless.values()),
'core': deps_core,
},
include_package_data=True,
)