-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
95 lines (77 loc) · 2.72 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
# -*- coding: utf-8 -*-
try:
from Cython.Build import cythonize
EXIST_CYTHON = True
except ImportError:
EXIST_CYTHON = False
# http://wiki.python.org/moin/PortingPythonToPy3k
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
# 2.x
from distutils.command.build_py import build_py
from setuptools import find_packages
from setuptools.extension import Extension
try:
from cx_Freeze import setup, Executable
Executable # for omitting the flake8 warning
EXIST_CX_FREEZE = True
except ImportError:
from setuptools import setup
EXIST_CX_FREEZE = False
from setuptools.command.test import test as TestCommand
from genecoder.version import VERSION
import os.path
import glob
from itertools import chain
version = VERSION
class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
import pytest
pytest.main(self.test_args)
def _make_extensions(ext_name_with_wildcard):
ext = '.pyx' if EXIST_CYTHON else '.c'
filenames = glob.glob(ext_name_with_wildcard.replace('.', os.path.sep) + ext)
return [Extension(
name=filename.replace(os.path.sep, '.')[:-len(ext)],
sources=[filename],
extra_compile_args=["-Wno-unneeded-internal-declaration", "-Wno-unused-function"],
) for filename in filenames]
def _load_requires_from_file(filepath):
return [pkg_name.rstrip('\r\n') for pkg_name in open(filepath).readlines()]
def _install_requires():
return _load_requires_from_file('requirements.txt')
def _test_requires():
return _load_requires_from_file('test-requirements.txt')
packages = find_packages(exclude=['tests'])
# gather package/*.[pyx|c]
extensions = list(chain.from_iterable(map(lambda s: _make_extensions(s + '.*'), packages)))
if EXIST_CYTHON:
print('running cythonize')
extensions = cythonize(extensions)
setup(
name='genecoder',
version=version,
description='code analysis for genes',
url='https://github.com/kerug/genecoder',
long_description=open('README.rst').read() + '\n' + open('CHANGELOG.txt').read(),
classifiers=['Topic :: Scientific/Engineering :: Bio-Informatics'],
keywords='analyze gene',
author='kerug',
author_email='keru.work@gmail.com',
license='MIT',
packages=packages,
package_data={'genecoder': ['genecoder.ini']},
install_requires=_install_requires(),
tests_require=_test_requires(),
test_suite='nose.collector',
zip_safe=False,
ext_modules=extensions,
scripts=[],
entry_points={'console_scripts': ['genecoder = genecoder.main:main']},
cmdclass={'build_py': build_py, 'test': PyTest},
)