-
-
Notifications
You must be signed in to change notification settings - Fork 132
/
setup.py
184 lines (159 loc) · 5.46 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
"""
Module that defines a setup function and publishes the package to PyPI.
Use the command `python setup.py upload`.
"""
import codecs
import contextlib
import io
import os
import re
import sys
from pprint import pprint
from shutil import rmtree
from typing import List
from setuptools import Command, find_packages, setup
VERSION = None
HERE = os.path.abspath(os.path.dirname(__file__))
NAME = "graphein"
# Import the PYPI README and use it as the long-description.
# Note: this will only work if "README.md" is present in your MANIFEST.in file!
try:
with io.open(os.path.join(HERE, "README.md"), encoding="utf-8") as f:
long_description = "\n" + f.read()
except FileNotFoundError:
long_description = DESCRIPTION
with io.open(
os.path.join(os.path.dirname(__file__), "graphein/__init__.py"),
encoding="utf-8",
) as f:
for l in f:
if not l.startswith("__version__"):
continue
VERSION = l.split("=")[1].strip(" \"'\n")
break
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))
def read(*parts):
# intentionally *not* adding an encoding option to open
return codecs.open(os.path.join(HERE, *parts), "r").read()
def read_requirements(*parts):
"""
Return requirements from parts.
Given a requirements.txt (or similar style file),
returns a list of requirements.
Assumes anything after a single '#' on a line is a comment, and ignores
empty lines.
:param parts: list of filenames which contain the installation "parts",
i.e. submodule-specific installation requirements
:returns: A compiled list of requirements.
"""
requirements = []
for line in read(*parts).splitlines():
new_line = re.sub( # noqa: PD005
r"(\s*)?#.*$", # the space immediately before the
# hash mark, the hash mark, and
# anything that follows it
"", # replace with a blank string
line,
)
new_line = re.sub( # noqa: PD005
r"-r.*$", # link to another requirement file
"", # replace with a blank string
new_line,
)
new_line = re.sub( # noqa: PD005
r"-e \..*$", # link to editable install
"", # replace with a blank string
new_line,
)
# print(line, "-->", new_line)
if new_line: # i.e. we have a non-zero-length string
requirements.append(new_line)
return requirements
INSTALL_REQUIRES = read_requirements(".requirements/base.in")
EXTRA_REQUIRES = {
"dev": read_requirements(".requirements/dev.in"),
"extras": read_requirements(".requirements/extras.in"),
}
# Add all requires
all_requires = []
for v in EXTRA_REQUIRES.values():
all_requires.extend(v)
EXTRA_REQUIRES["all"] = set(all_requires)
pprint(EXTRA_REQUIRES)
class UploadCommand(Command):
"""Support setup.py upload."""
description = "Build and publish the package."
user_options: List = []
@staticmethod
def status(s):
"""Print things in bold."""
print("\033[1m{0}\033[0m".format(s))
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
"""Publish package to PyPI."""
with contextlib.suppress(OSError):
self.status("Removing previous builds…")
rmtree(os.path.join(HERE, "dist"))
self.status("Building Source and Wheel (universal) distribution…")
os.system(
"{0} setup.py sdist bdist_wheel --universal".format(sys.executable)
)
self.status("Uploading the package to PyPI via Twine…")
os.system("twine upload dist/*")
self.status("Pushing git tags…")
os.system("git tag v{0}".format(VERSION))
os.system("git push --tags")
sys.exit()
setup(
name="graphein",
version="1.7.7",
description="Protein & Interactomic Graph Construction for Machine Learning",
long_description=long_description,
long_description_content_type="text/markdown",
author="Arian Jamasb",
author_email="[email protected]",
url="https://github.com/a-r-j/graphein",
project_urls={
"homepage": "https://github.com/a-r-j/graphein",
"changelog": "https://github.com/a-r-j/graphein/blob/master/CHANGELOG.md",
"issue": "https://github.com/a-r-j/graphein/issues",
"documentation": "https://graphein.ai/",
},
packages=find_packages(),
package_data={
"": ["LICENSE.txt", "README.md", "requirements.txt", "*.csv"]
},
include_package_data=True,
# install_requires=install_reqs,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRA_REQUIRES,
python_requires=">=3.7",
license="MIT",
platforms="any",
classifiers=[
"License :: OSI Approved :: MIT License",
"Development Status :: 5 - Production/Stable",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
],
# $ setup.py publish support.
cmdclass={
"upload": UploadCommand,
},
entry_points={
"console_scripts": [
"graphein = graphein.cli:main",
],
},
)