-
Notifications
You must be signed in to change notification settings - Fork 14
/
setup.py
126 lines (106 loc) · 3.87 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
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/ptychography40/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, 'ptychography40')
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="ptychography40",
version=find_version("src", "ptychography40", "__version__.py"),
license='GPL v3',
include_package_data=True,
zip_safe=False,
python_requires='>=3.7',
install_requires=[
"numpy",
"scipy",
"sparse",
"libertem>=0.7.0",
# Pinned due to https://github.com/pydata/sparse/issues/257
# Ensure compatibility with numpy 1.17
"numba>=0.46",
],
extras_require={
},
package_dir={"": "src"},
packages=[
"ptychography40",
],
cmdclass={
'sdist': BakedRevisionBuilderSdist,
'build_py': BakedRevisionBuilderBuildPy,
},
keywords="Ptychography",
description="Phase reconstruction using ptychography",
long_description=remove_rst_roles(read("README.rst")),
long_description_content_type="text/x-rst",
url="https://ptychography-4-0.github.io/ptychography/",
author_email="[email protected]",
author="the Ptychography 4.0 team",
classifiers=[
'Development Status :: 4 - Beta',
'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',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Environment :: Console',
'Intended Audience :: Science/Research',
'Natural Language :: English',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Visualization',
],
)