setup.py 2.96 KB
Newer Older
Vermaat's avatar
Vermaat committed
1
import os
Laros's avatar
Laros committed
2
3
import sys
from setuptools import setup
4
from distutils.core import Extension
Laros's avatar
Laros committed
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# We do some trickery to assure SWIG is always run before installing the
# generated files.
# http://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module
from setuptools.command.install import install
from distutils.command.build import build
class CustomBuild(build):
    def run(self):
        self.run_command('build_ext')
        build.run(self)
class CustomInstall(install):
    def run(self):
        self.run_command('build_ext')
        self.do_egg_install()
custom_cmdclass = {'build': CustomBuild, 'install': CustomInstall}

Vermaat's avatar
Vermaat committed
21
22
if sys.version_info < (2, 6):
    raise Exception('extractor requires Python 2.6 or higher.')
Laros's avatar
Laros committed
23

Vermaat's avatar
Vermaat committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This is quite the hack, but we don't want to import our package from here
# since that's recipe for disaster (it might have some uninstalled
# dependencies, or we might import another already installed version).
distmeta = {}
for line in open(os.path.join('extractor', '__init__.py')):
    try:
        field, value = (x.strip() for x in line.split('='))
    except ValueError:
        continue
    value = value.strip('\'"')
    distmeta[field] = value

# The __version__ value is actually defined in extractor.h.
for line in open(os.path.join('extractor', 'extractor.h')):
    if ' VERSION = ' in line:
Vermaat's avatar
Vermaat committed
39
40
        version = line.split('=')[-1].replace(';', '').replace('"', '') \
                                     .replace("'", '').strip()
Vermaat's avatar
Vermaat committed
41
42
43
44
45
        distmeta['__version__'] = version
        distmeta['__version_info__'] = tuple(version.split('.'))
        break

try:
Vermaat's avatar
Vermaat committed
46
    with open('README.md') as readme:
Vermaat's avatar
Vermaat committed
47
48
49
        long_description = readme.read()
except IOError:
    long_description = 'See ' + distmeta['__homepage__']
Laros's avatar
Laros committed
50
51

setup(
Vermaat's avatar
Vermaat committed
52
    name='description-extractor',
53
    cmdclass=custom_cmdclass,
54
55
    ext_modules=[Extension('_extractor', ['extractor/extractor.i',
        'extractor/extractor.cc'], swig_opts=['-c++'])],
Vermaat's avatar
Vermaat committed
56
    version=distmeta['__version__'],
Vermaat's avatar
Vermaat committed
57
    description='HGVS variant description extractor',
Vermaat's avatar
Vermaat committed
58
59
60
61
    long_description=long_description,
    author=distmeta['__author__'],
    author_email=distmeta['__contact__'],
    url=distmeta['__homepage__'],
Laros's avatar
Laros committed
62
63
64
65
66
67
68
69
70
    license='MIT License',
    platforms=['any'],
    packages=['extractor'],
    classifiers = [
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Science/Research',
        'Intended Audience :: Developers',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
Vermaat's avatar
Vermaat committed
71
72
73
74
75
76
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
jkvis's avatar
jkvis committed
77
        'Programming Language :: Python :: 3.5',
Laros's avatar
Laros committed
78
79
80
        'Programming Language :: C++',
        'Topic :: Scientific/Engineering',
    ],
jkvis's avatar
jkvis committed
81
    keywords='bioinformatics',
82
    install_requires=['biopython']
Laros's avatar
Laros committed
83
)