-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
144 lines (125 loc) · 4.25 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
import re
import os
import codecs
import subprocess
from setuptools.command.sdist import sdist
from setuptools.command.build_py import build_py
from setuptools import setup
class BakedRevisionBuilderSdist(sdist):
def make_release_tree(self, base_dir, files):
if not self.dry_run:
write_baked_revision(base_dir)
sdist.make_release_tree(self, base_dir, files)
class BakedRevisionBuilderBuildPy(build_py):
def run(self):
if not self.dry_run:
write_baked_revision(self.build_lib)
build_py.run(self)
def mkpath(path):
if not os.path.exists(path):
os.makedirs(path)
def read(*parts):
# intentionally *not* adding an encoding option to open, See:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
here = os.path.abspath(os.path.dirname(__file__))
return codecs.open(os.path.join(here, *parts), 'r').read()
def remove_rst_roles(txt):
return re.sub(':(cite|doc):`[^`]+` ?', '', txt)
def get_git_rev():
# NOTE: this is a copy from src/libertem_common/versioning.py
# this is because it is not guaranteed that we can import our own packages
# from setup.py AFAIK
try:
new_cwd = os.path.abspath(os.path.dirname(__file__))
rev_raw = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=new_cwd)
return rev_raw.decode("utf8").strip()
except Exception:
return "unknown"
def write_baked_revision(base_dir):
dest_dir = os.path.join(base_dir, 'libertem_common')
baked_dest = os.path.join(dest_dir, '_baked_revision.py')
mkpath(dest_dir)
with open(baked_dest, "w") as f:
f.write(r'revision = "%s"' % get_git_rev())
def find_version(*file_paths):
"""
"stolen" from pip's setup.py
"""
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
setup(
name="libertem-common",
version=find_version("src", "libertem_common", "__version__.py"),
license='GPL v3',
include_package_data=True,
zip_safe=False,
python_requires='>=3.6',
install_requires=[
"numpy",
"scipy",
"sparse",
"distributed>=2.19.0",
"click",
"tornado>=5",
"matplotlib",
"pillow",
"h5py",
"psutil",
# https://github.com/LiberTEM/LiberTEM/issues/763
# https://github.com/LiberTEM/LiberTEM/issues/783
"numba>=0.49.1",
"ncempy>=1.4",
'pywin32!=226;platform_system=="Windows"',
'scikit-image',
'cloudpickle',
'jsonschema',
'scikit-learn',
],
extras_require={
'torch': 'torch',
'hdbscan': 'hdbscan',
'pyfftw': 'pyfftw',
},
package_dir={"": "src"},
packages=[
"libertem_common",
],
# entry_points={
# 'console_scripts': [
# 'libertem-server=libertem.web.cli:main',
# ]
# },
cmdclass={
'sdist': BakedRevisionBuilderSdist,
'build_py': BakedRevisionBuilderBuildPy,
},
keywords="electron microscopy",
description="TODO",
long_description=remove_rst_roles(read("README.rst")),
long_description_content_type="text/x-rst",
url="https://libertem.github.io/LiberTEM-common",
author_email="[email protected]",
author="the LiberTEM team",
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Environment :: Console',
'Intended Audience :: Science/Research',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Natural Language :: English',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Visualization',
],
)