-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
88 lines (76 loc) · 2.36 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
# This downloads and install setuptools if it is not installed.
from ez_setup import use_setuptools
use_setuptools()
import os
import setuptools
from numpy.distutils.core import setup, Extension
import warnings
MAJOR = 0
MINOR = 6
MICRO = 0
ISRELEASED = False
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
QUALIFIER = ''
FULLVERSION = VERSION
print FULLVERSION
if not ISRELEASED:
FULLVERSION += '.dev'
try:
import subprocess
try:
pipe = subprocess.Popen(["git", "describe", "HEAD"],
stdout=subprocess.PIPE).stdout
except OSError:
# msysgit compatibility
pipe = subprocess.Popen(
["git.cmd", "describe", "HEAD"],
stdout=subprocess.PIPE).stdout
rev = pipe.read().strip()
# makes distutils blow up on Python 2.7
import sys
if sys.version_info[0] >= 3:
rev = rev.decode('ascii')
FULLVERSION = rev.lstrip('v')
except:
warnings.warn("WARNING: Couldn't get git revision")
else:
FULLVERSION += QUALIFIER
def write_version_py(filename=None):
cnt = """\
version = '%s'
short_version = '%s'
"""
if not filename:
filename = os.path.join(
os.path.dirname(__file__), 'mr', 'version.py')
a = open(filename, 'w')
try:
a.write(cnt % (FULLVERSION, VERSION))
finally:
a.close()
write_version_py()
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
# Installation tries ext_modules but omits them if compiling fails.
setup_parameters = dict(
name = "mr",
version = FULLVERSION,
description = "microrheology toolkit",
author = "Daniel Allan",
author_email = "[email protected]",
url = "https://github.com/danielballan/mr",
packages = ['mr', 'mr.video', 'mr.wire', 'customized_trackpy'],
long_description = read('README.md'),
ext_modules = [Extension('_Cfilters', ['mr/src/Cfilters.c'])],
package_dir = {'mr': 'mr'},
package_data = {'mr': ['doc/*', 'db_schema.sql']},
)
try:
setup(**setup_parameters)
except SystemExit:
warnings.warn(
"""DON'T PANIC! Compiling C is not working, so I will fall back
on pure Python code that does the same thing, just slower.""")
# Try again without ext_modules.
del setup_parameters['ext_modules']
setup(**setup_parameters)