forked from sunpy/sunpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
139 lines (124 loc) · 4.7 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
"""
SunPy: Python for Solar Physics
The SunPy project is an effort to create an open-source software library for
solar physics using the Python programming language.
"""
DOCLINES = __doc__.split("\n")
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Physics',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS'
]
VERSION = '0.3.2'
def git_description():
import subprocess
try:
out = subprocess.Popen(['git', 'describe', '--tags'], stdout = subprocess.PIPE).communicate()[0]
description = out.strip().decode('ascii')
except OSError:
description = 'Error: could not run git'
return description
def write_version_py():
import os
if os.path.exists('.git'):
GIT_DESCRIPTION = git_description()
else:
GIT_DESCRIPTION = 'N/A'
out = open('sunpy/version.py', 'w')
template = """# This file is automatically generated by SunPy's setup.py
version = '%(version)s'
git_description = '%(git_description)s'
"""
try:
out.write(template % {'version': VERSION,
'git_description': GIT_DESCRIPTION})
finally:
out.close()
def install(setup): #pylint: disable=W0621
from setuptools import find_packages
#Crotate Module
from distutils.core import Extension
from os.path import dirname, join
cwd = dirname(__file__)
try:
import numpy as np
except ImportError:
print("SunPy WARNING: NumPy must be installed first to build the C extension")
if 'np' in locals():
module = 'sunpy.image.Crotate' # import this
sourcefiles = [join(cwd, 'sunpy', 'image', 'src', 'rot_extn.c'),
join(cwd, 'sunpy', 'image', 'src', 'transform', 'aff_tr.c')]
libs = ['m']
# -ON for compile optimise
gcc_args = ['-std=c99', '-O3']
# gcc_args = ['-std=c99']
# need *module* name here
crotate = Extension(module,
sources = sourcefiles,
libraries = libs,
extra_compile_args = gcc_args,
include_dirs =
[np.get_include(), join(cwd, 'sunpy', 'image', 'src')]
)
module_ana = 'sunpy.io._pyana'
sourcefiles_ana = [join(cwd, 'sunpy', 'io', 'src', 'ana', 'anacompress.c'),
join(cwd, 'sunpy', 'io', 'src', 'ana', 'anadecompress.c'),
join(cwd, 'sunpy', 'io', 'src', 'ana', 'anarw.c'),
join(cwd, 'sunpy', 'io', 'src', 'ana', 'testrw.c'),
join(cwd, 'sunpy', 'io', 'src', 'ana', '_pyana.c')]
ana = Extension(module_ana,
sources = sourcefiles_ana,
libraries = libs,
extra_compile_args = gcc_args,
include_dirs =
[np.get_include(), join(cwd, 'sunpy', 'io', 'src')]
)
ext_modules = []
if 'crotate' in locals():
ext_modules.append(crotate)
if 'ana' in locals():
ext_modules.append(ana)
write_version_py()
setup(
author="Steven Christe, Matt Earnshaw, Russell Hewett, Keith Hughitt, Jack Ireland, Florian Mayer, Stuart Mumford, Albert Shih, David Perez-Suarez et. al",
author_email="[email protected]",
classifiers=CLASSIFIERS,
description=DOCLINES[0],
download_url="http://www.sunpy.org/download/",
install_requires=[
'numpy>1.6.0',
'astropy>=0.3.0',
'scipy',
'pandas>=0.10.0',
'matplotlib>=1.1',
'sqlalchemy',
],
license="BSD",
long_description="\n".join(DOCLINES[2:]),
maintainer="SunPy Developers",
maintainer_email="[email protected]",
name="sunpy",
packages=find_packages(),
package_data={'': ['*.fits', '*.fit', 'sunpyrc']},
platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
provides=['sunpy'],
url="http://www.sunpy.org/",
use_2to3=True,
version=VERSION,
ext_modules = ext_modules
)
if __name__ == '__main__':
from distribute_setup import use_setuptools
use_setuptools()
from setuptools import setup
install(setup)