forked from cggh/scikit-allel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
123 lines (100 loc) · 3.74 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
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, division
from ast import literal_eval
from setuptools import setup, Extension
DISTNAME = 'scikit-allel'
PACKAGE_NAME = 'allel'
DESCRIPTION = 'A Python package for exploring and analysing genetic ' \
'variation data.'
with open('README.rst') as f:
LONG_DESCRIPTION = f.read()
MAINTAINER = 'Alistair Miles',
MAINTAINER_EMAIL = '[email protected]',
URL = 'https://github.com/cggh/scikit-allel'
DOWNLOAD_URL = 'http://pypi.python.org/pypi/scikit-allele'
LICENSE = 'MIT'
# strictly speaking, allel requires numpy, scipy and numexpr, but numexpr
# won't install unless numpy is already installed, so leave this blank for now
# and require user to pre-install numpy, scipy and numexpr themselves
INSTALL_REQUIRES = []
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
]
def get_version(source='allel/__init__.py'):
with open(source) as sf:
for line in sf:
if line.startswith('__version__'):
return literal_eval(line.split('=')[-1].lstrip())
raise ValueError("__version__ not found")
VERSION = get_version()
# noinspection PyUnresolvedReferences
def setup_extensions(metadata):
try:
# only build extensions if numpy is available
import numpy as np
except ImportError:
# numpy not available
pass
else:
# check for cython
try:
# build with cython
from Cython.Build import cythonize
ext_modules = cythonize([
Extension('allel.opt.model',
sources=['allel/opt/model.pyx'],
include_dirs=[np.get_include()],
# define_macros=[('CYTHON_TRACE', 1)],
),
Extension('allel.opt.stats',
sources=['allel/opt/stats.pyx'],
include_dirs=[np.get_include()],
# define_macros=[('CYTHON_TRACE', 1)],
),
])
except ImportError:
# build previously cythonized C
ext_modules = [
Extension('allel.opt.model',
sources=['allel/opt/model.c'],
include_dirs=[np.get_include()]),
Extension('allel.opt.stats',
sources=['allel/opt/stats.c'],
include_dirs=[np.get_include()]),
]
metadata['ext_modules'] = ext_modules
def setup_package():
metadata = dict(
name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
license=LICENSE,
url=URL,
download_url=DOWNLOAD_URL,
version=VERSION,
package_dir={'': '.'},
packages=['allel', 'allel.model', 'allel.chunked', 'allel.stats',
'allel.opt', 'allel.test'],
classifiers=CLASSIFIERS,
install_requires=INSTALL_REQUIRES,
)
setup_extensions(metadata)
setup(**metadata)
if __name__ == '__main__':
setup_package()