Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
197 lines (171 loc) · 7.08 KB
/
Copy pathsetup.py
File metadata and controls
197 lines (171 loc) · 7.08 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
# -*- coding: utf-8 -*-
"""Made by Luuk Visser (UL/TUD), with tweaks by Brett Morris (NASA GSFC/UMD)"""
import os
import sys
import shutil
import subprocess
import atexit
import urllib2
def internet_on():
refURL = 'http://74.125.228.100' ## One Google IP address (bypass DNS lookup)
try:
response=urllib2.urlopen(refURL,timeout=1)
return True
except urllib2.URLError as err: pass
return False
# Checking for all required packages and if these are recent enough
minimum_numpy_version = "1.6"
minimum_matplotlib_version = "1.0"
minimum_pyfits_version = "3.1.0" # lower versions may work (not tested)
minimum_scipy_version = "0.10" # lower versions may work (not tested)
minimum_wxpython_version = "2.0" # lower versions may work (not tested)
sysplatform = sys.platform
if not hasattr(sys, 'real_prefix'):
# Currently only Python 2.7.x is supported
if sys.version_info[:2] != (2, 7):
raise RuntimeError("must use python 2.7.x")
if not internet_on():
raise RuntimeError("Must be connected to the internet to complete "\
"install. Please connect to the internet and start "\
"the install again.")
# Check if the package dependancies/requirements are fulfilled
try:
from setuptools import setup
except:
raise RuntimeError("Setuptools not found, setup cannot continue without it")
try:
import numpy as np
except:
raise RuntimeError("Numpy not found")
if np.__version__ < minimum_numpy_version:
print("*Error*: NumPy version is lower than needed: %s < %s" %
(np.__version__, minimum_numpy_version))
sys.exit(1)
try:
import scipy
except:
raise RuntimeError("Scipy not found")
if scipy.__version__ < minimum_scipy_version:
print("*Error*: Scipy version is lower than needed: %s < %s" %
(scipy.__version__, minimum_scipy_version))
sys.exit(1)
try:
import matplotlib
except:
raise RuntimeError("matplotlib not found")
if matplotlib.__version__ < minimum_matplotlib_version:
print("*Error*: matplotlib version is lower than needed: %s < %s" %
(matplotlib.__version__, minimum_matplotlib_version))
sys.exit(1)
try:
import pyfits
except:
raise RuntimeError("PyFITS not found")
if pyfits.__version__ < minimum_pyfits_version:
print("*Error*: PyFITS version is lower than needed: %s < %s" %
(pyfits.__version__, minimum_pyfits_version))
sys.exit(1)
try:
if sysplatform == 'darwin' or 'linux2':
import wx
else:
""" (assuming in this case that sysplatform == 'win32' """
import wxPython
except:
raise RuntimeError("wxPython not found")
if wx.__version__ < minimum_wxpython_version:
print("*Error*: wxPython version is lower than needed: %s < %s" %
(wx.__version__, minimum_wxpython_version))
sys.exit(1)
else:
from setuptools import setup
# Walk through the subdirs and add all non-python scripts to MANIFEST.in
def create_manifest():
print 'creating manifest.in'
matches = []
for root, dirnames, filenames in os.walk('oscaar'):
if ('.git' in str(root)) == False:
for filename in filenames:
if filename.endswith(('.py', '.pyc')) == False:
matches.append(os.path.join(root, filename))
for root, dirnames, filenames in os.walk('docs'):
if ('.git' in str(root)) == False:
for filename in filenames:
if filename.endswith(('.py', '.pyc')) == False:
matches.append(os.path.join(root, filename))
# Manually add extra files from the top-level directory
matches.append(os.path.join(os.path.dirname(__file__),'post_setup.py'))
matches.append(os.path.join(os.path.dirname(__file__),'INSTALL.txt'))
matches.append(os.path.join(os.path.dirname(__file__),'LICENSE.txt'))
with open('MANIFEST.in', 'w') as f:
f.writelines(("include %s\n" % l.replace(' ','?') for l in matches))
# To remove the manifest file after installation
def delete_manifest():
if os.path.exists('MANIFEST.in'):
os.remove('MANIFEST.in')
# Create list for Python scripts directories to include
def get_packages():
print 'searching for packages'
matches = []
for root, dirnames, filenames in os.walk('oscaar'):
if ('.git' in str(root)) == False:
for filename in filenames:
if filename.endswith(('.py', '.pyc')) == True:
matches.append(root)
matches = list(set(matches))
return matches
def del_dir(dirname):
if os.path.exists(dirname):
shutil.rmtree(dirname)
# The setup configuration for installing OSCAAR
def setup_package():
create_manifest()
list = ['Numpy>=1.6','Scipy>=0.1','pyfits>=3.1','pyephem>=3.7',\
'matplotlib>=1.2.1']
setup(
name = "OSCAAR",
version = "2.0beta",
author = "Core Developer: Brett M. Morris. Contributors: "+\
"Daniel Galdi, Dharmatej Mikkilineni, Luuk Visser",
author_email = "oscaarteam@gmail.com",
description = ("oscaar is an open source project aimed at "+\
"helping you begin to study transiting extrasolar "+\
"planets with differential photometry."),
license = 'LICENSE.txt',
keywords = "oscaar transit astronomy photometry exoplanets",
url = "https://github.com/OSCAAR/OSCAAR/wiki",
packages=get_packages(),
include_package_data = True,
zip_safe = False,
long_description=open(os.path.join(os.path.dirname(\
os.path.abspath(__file__)),'README')).read(),
download_url='https://github.com/OSCAAR/OSCAAR/archive/master.zip',
install_requires=list,
dependency_links = ['https://downloads.sourceforge.net/project/'+\
'matplotlib/matplotlib/matplotlib-1.2.1/'+\
'matplotlib-1.2.1.tar.gz'],
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: C',
'Topic :: Scientific/Engineering :: Astronomy',
'Topic :: Scientific/Engineering :: Physics'
],
)
# At exit delete temporary files, and run post setup script if
# argument is 'install'
def to_do_at_exit():
delete_manifest()
#del_dir('build')
#del_dir('OSCAAR.egg-info')
if 'install' in sys.argv:
del_dir('dist')
'Installation finished. Starting DS9 downloader and compile C\n'
subprocess.check_call(['python', 'post_setup.py',sys.argv[-1]])
#Set function to be executed at exit of code (when script is finished)
atexit.register(to_do_at_exit)
if __name__ == '__main__':
setup_package()