-
Notifications
You must be signed in to change notification settings - Fork 29
/
setup_pypi.py
188 lines (169 loc) · 6.51 KB
/
setup_pypi.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env python
"""`Setup_pypi.py` for Connectome Mapper 3 for publication to PyPI that does not contain `cmtklib.data`."""
import os
import sys
import setuptools
from setuptools.command.install import install
from cmp.info import __version__
class VerifyVersionCommand(install):
"""Custom command to verify that the git tag matches our version"""
description = "verify that the git tag matches our version"
def run(self):
"""Verify that the git tag (`CIRCLE_TAG`) matches our version."""
tag = os.getenv('CIRCLE_TAG')
version = f'{__version__}'
if tag != version:
info = f"Git tag: {tag} does not match the version of this app: {version}"
sys.exit(info)
# Get directory where this file is located
directory = os.path.abspath(os.path.dirname(__file__))
# Remove any MANIFEST of a previous installation
if os.path.exists("MANIFEST"):
os.remove("MANIFEST")
# Define the packages to be installed
packages = [
"cmp",
"cmp.cli",
"cmp.stages",
"cmp.stages.preprocessing",
"cmp.stages.segmentation",
"cmp.stages.parcellation",
"cmp.stages.registration",
"cmp.stages.diffusion",
"cmp.stages.functional",
"cmp.stages.connectome",
"cmp.stages.eeg",
"cmp.pipelines",
"cmp.viz",
"cmp.pipelines.anatomical",
"cmp.pipelines.diffusion",
"cmp.pipelines.functional",
"cmp.bidsappmanager",
"cmp.bidsappmanager.gui",
"cmp.bidsappmanager.stages",
"cmp.bidsappmanager.stages.preprocessing",
"cmp.bidsappmanager.stages.segmentation",
"cmp.bidsappmanager.stages.parcellation",
"cmp.bidsappmanager.stages.registration",
"cmp.bidsappmanager.stages.diffusion",
"cmp.bidsappmanager.stages.eeg",
"cmp.bidsappmanager.stages.functional",
"cmp.bidsappmanager.stages.connectome",
"cmp.bidsappmanager.pipelines",
"cmp.bidsappmanager.pipelines.anatomical",
"cmp.bidsappmanager.pipelines.diffusion",
"cmp.bidsappmanager.pipelines.functional",
"cmtklib",
"cmtklib.bids",
"cmtklib.data.parcellation",
"cmtklib.interfaces",
"resources",
]
# Define the package data to be installed
package_data = {
"cmp": ["cmp3_icon.png", "config/*.json"],
"cmp.bidsappmanager": [
"images/*.png",
"pipelines/anatomical/*.png",
"pipelines/diffusion/*.png",
"pipelines/functional/*.png",
],
"resources": ["buttons/*.png", "icons/*png"],
"cmtklib": [
"data/parcellation/lausanne2018/*.*",
"data/parcellation/lausanne2018/*/*.*",
"data/parcellation/nativefreesurfer/*/*.*",
"data/parcellation/lausanne2018/mni-space/*.*",
"data/report/carbonfootprint/css/*.*",
"data/report/carbonfootprint/js/*.*",
],
}
# Extract package requirements from Conda environment.yml
include_conda_pip_dependencies = False
install_requires = []
dependency_links = []
if include_conda_pip_dependencies:
path = os.path.join(directory, "docker", "environment.yml")
with open(path) as read_file:
state = "PREAMBLE"
for line in read_file:
line = line.rstrip().lstrip(" -")
if line == "dependencies:":
state = "CONDA_DEPS"
elif line == "pip:":
state = "PIP_DEPS"
elif state == "CONDA_DEPS":
line = "==".join(line.split("="))
line = line.split("==")[0]
# Python is a valid dependency for Conda but not setuptools, so skip it
if "python" in line:
pass
else:
# Appends to dependencies
install_requires.append(line)
elif state == "PIP_DEPS":
line = line.split("==")[0]
# Appends to dependency links
dependency_links.append(line)
# Adds package name to dependencies
install_requires.append(line)
# Install automatically codecarbon with CMP3
install_requires.append('codecarbon==1.2.0')
install_requires.append('dash-bootstrap-components==0.13.1')
print(f'Install requires: {install_requires}')
print(f'Dependency links: {dependency_links}')
# Read the contents of your README file
with open(os.path.join(directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()
def main():
"""Main function of CMP3 ``setup.py``"""
# Setup configuration
setuptools.setup(
name="connectomemapper",
version=__version__,
description="Connectome Mapper 3: A Flexible and Open-Source Pipeline Software for Multiscale Multimodal Human Connectome Mapping",
long_description=long_description,
long_description_content_type="text/markdown",
author="Sebastien Tourbier",
author_email="[email protected]",
url="https://github.com/connectomicslab/connectomemapper3",
entry_points={
"console_scripts": [
'connectomemapper3 = cmp.cli.connectomemapper3:main',
'cmpbidsappmanager = cmp.cli.cmpbidsappmanager:main',
'showmatrix_gpickle = cmp.cli.showmatrix_gpickle:main',
'visualize_eeg_pipeline_outputs = cmp.cli.visualize_eeg_pipeline_outputs:main',
'connectomemapper3_docker = cmp.cli.connectomemapper3_docker:main',
'connectomemapper3_singularity = cmp.cli.connectomemapper3_singularity:main'
]
},
license="BSD-3-Clause",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python :: 3.7",
],
maintainer="Connectomics Lab, CHUV",
maintainer_email="[email protected]",
packages=packages,
include_package_data=True,
package_data=package_data,
# requires=["numpy (>=1.18)", "nipype (>=1.5.0)", "pybids (>=0.10.2)"],
install_requires=install_requires,
dependency_links=dependency_links,
python_requires=">=3.7",
cmdclass={
"verify": VerifyVersionCommand,
},
)
if __name__ == "__main__":
main()