forked from alexrudy/AstroObject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
80 lines (62 loc) · 2.28 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
# -*- coding: utf-8 -*-
#
# setup.py
# AstroObject
#
# Created by Alexander Rudy on 2012-04-17.
# Copyright 2012 Alexander Rudy. All rights reserved.
#
from distribute_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages
from distutils.command.build_py import build_py as du_build_py
from distutils.core import Command
from pkg_resources import parse_version
from AstroObject.version import version as versionstr
# Check for matplotlib:
try:
from matplotlib import __version__ as mplversion
assert parse_version(mplversion) >= parse_version("1.0")
except:
print "Matplotlib does not appear to be installed correctly.\nYou must install Matplotlib 1.0 or later."
class Version(Command):
description = "Print the module version"
user_options = []
def initialize_options(self):
pass
def finalize_options (self):
pass
def run(self):
print 'version',versionstr
return
#custom build_py overwrites version.py with a version overwriting the revno-generating version.py
class ao_build_py(du_build_py):
def run(self):
from os import path
res = du_build_py.run(self)
versfile = path.join(self.build_lib,'AstroObject','version.py')
print 'freezing version number to',versfile
with open(versfile,'w') as f: #this overwrites the actual version.py
f.write(self.get_version_py())
return res
def get_version_py(self):
import datetime
from AstroObject.version import _frozen_version_py_template
from AstroObject.version import version,major,minor,bugfix,isdev,devstr
timestamp = str(datetime.datetime.now())
t = (timestamp,version,major,minor,bugfix,isdev,devstr)
return _frozen_version_py_template%t
setup(
name = "AstroObject",
version = versionstr,
packages = find_packages(exclude=['tests']),
package_data = {'':['Defaults.yaml']},
install_requires = ['distribute','pyfits>=2.4','numpy>=1.5','scipy>=0.9',"PyYAML>=3.10",'progressbar'],
test_suite = 'tests',
author = "Alexander Rudy",
author_email = "[email protected]",
cmdclass = {
'build_py' : ao_build_py,
'version' : Version
}
)