-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
executable file
·175 lines (155 loc) · 4.96 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
#!/usr/bin/env python
import sys
import os
import shutil
import inspect
import pkgutil
import importlib
from subprocess import check_call, CalledProcessError
from configparser import ConfigParser
from setuptools import setup, find_packages, Extension, _install_setup_requires
from setuptools.command.install import install
from setuptools.command.test import test as TestCommand
try:
from distutils.config import ConfigParser
except ImportError:
from configparser import ConfigParser
conf = ConfigParser()
conf.read(['setup.cfg'])
# Get some config values
metadata = dict(conf.items('metadata'))
PACKAGENAME = metadata.get('package_name', 'subpixal')
DESCRIPTION = metadata.get('description', 'A package aligning images using '
'sub-pixel cross correlation.')
LONG_DESCRIPTION = metadata.get('long_description', 'README.rst')
LONG_DESCRIPTION_CONTENT_TYPE = metadata.get('long_description_content_type',
'text/x-rst')
AUTHOR = metadata.get('author', 'Mihai Cara')
AUTHOR_EMAIL = metadata.get('author_email', '[email protected]')
URL = metadata.get('url', 'https://hsthelp.stsci.edu/')
LICENSE = metadata.get('license', 'BSD-3-Clause')
# load long description
this_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_dir, LONG_DESCRIPTION), encoding='utf-8') as f:
long_description = f.read()
if not pkgutil.find_loader('relic'):
relic_local = os.path.exists('relic')
relic_submodule = (relic_local and
os.path.exists('.gitmodules') and
not os.listdir('relic'))
try:
if relic_submodule:
check_call(['git', 'submodule', 'update', '--init', '--recursive'])
elif not relic_local:
check_call(['git', 'clone', 'https://github.com/spacetelescope/relic.git'])
sys.path.insert(1, 'relic')
except CalledProcessError as e:
print(e)
exit(1)
import relic.release
version = relic.release.get_info()
if not version.date:
default_version = metadata.get('version', '')
default_version_date = metadata.get('version-date', '')
version = relic.git.GitVersion(
pep386=default_version,
short=default_version,
long=default_version,
date=default_version_date,
dirty=True,
commit='',
post='-1'
)
relic.release.write_template(version, os.path.join(*PACKAGENAME.split('.')))
# Install packages required for this setup to proceed:
SETUP_REQUIRES = [
'numpy',
]
_install_setup_requires(dict(setup_requires=SETUP_REQUIRES))
for dep_pkg in SETUP_REQUIRES:
try:
importlib.import_module(dep_pkg)
except ImportError:
print("{0} is required in order to install '{1}'.\n"
"Please install {0} first.".format(dep_pkg, PACKAGENAME),
file=sys.stderr)
exit(1)
PACKAGE_DATA = {
'': [
'README.rst',
'LICENSE.txt',
'CHANGELOG.rst',
'*.fits',
'*.txt',
'*.inc',
'*.cfg',
'*.csv',
'*.yaml',
'*.json'
],
}
INSTALL_REQUIRES=[
'numpy>=1.15',
'scipy',
'astropy>=3.1',
'stsci.tools',
'stsci.skypac',
'stwcs',
'drizzlepac>=2.2.6',
'tweakwcs>=0.4.2'
]
# Setup C module include directories
import numpy
include_dirs = [numpy.get_include()]
# Setup C module macros
define_macros = [('NUMPY', '1')]
# Handle MSVC `wcsset` redefinition
if sys.platform == 'win32':
define_macros += [
('_CRT_SECURE_NO_WARNING', None),
('__STDC__', 1)
]
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = ['subpixal/tests']
self.test_suite = True
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
setup(
name=PACKAGENAME,
version=version.pep386,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
description=DESCRIPTION,
license=LICENSE,
long_description=long_description,
long_description_content_type=LONG_DESCRIPTION_CONTENT_TYPE,
url=URL,
classifiers=[
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: Astronomy',
'Topic :: Software Development :: Libraries :: Python Modules',
'Development Status :: 3 - Alpha',
],
python_requires='>=3.5',
setup_requires=SETUP_REQUIRES,
install_requires=INSTALL_REQUIRES,
tests_require=['pytest'],
packages=find_packages(),
package_data=PACKAGE_DATA,
cmdclass={
'test': PyTest,
},
project_urls={
'Bug Reports': 'https://github.com/spacetelescope/subpixal/issues/',
'Source': 'https://github.com/spacetelescope/subpixal/',
'Help': 'https://hsthelp.stsci.edu/',
},
)