setup.py 4.51 KB
Newer Older
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# Copyright (C) 2010-2017  IRISA
4
#
5
6
7
8
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
9
#
10
11
12
13
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
14
#
15
16
17
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
#
19
# The original code contained here was initially developed by:
20
#
21
22
23
24
25
26
27
28
29
30
#     Geoffroy Andrieux.
#     IRISA/IRSET
#     Symbiose team
#     IRISA  Campus de Beaulieu
#     35042 RENNES Cedex, FRANCE
#
#
# Contributor(s): Michel Le Borgne, Nolwenn Le Meur, Pierre Vignet

"""Definition of setup function for setuptools module."""
31

32
33
# Standard imports
import sys
34
from distutils import sysconfig
35
from setuptools import setup, Extension, find_packages
36
from setuptools.command.test import test as TestCommand
37

38
__PACKAGE_VERSION__ = "0.1.5"
39
40
__LIBRARY_VERSION__ = "0.1.0"

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
################################################################################

class PyTest(TestCommand):
    """Call tests with the custom 'python setup.py test' command."""

    def initialize_options(self):
        TestCommand.initialize_options(self)
        self.pytest_args = []

    def run_tests(self):
        import pytest
        errno = pytest.main()
        sys.exit(errno)

################################################################################

57
58
59
60
61
62
63
64
65
66
# Delete unwanted flags for C compilation
# Distutils has the lovely feature of providing all the same flags that
# Python was compiled with. The result is that adding extra flags is easy,
# but removing them is a total pain. Doing so involves subclassing the
# compiler class, catching the arguments and manually removing the offending
# flag from the argument list used by the compile function.
# That's the theory anyway, the docs are too poor to actually guide you
# through what you have to do to make that happen.
d = sysconfig.get_config_vars()
for k, v in d.items():
67
    for unwanted in (' -g ', '-O2'):
68
69
70
71
72
73
        if str(v).find(unwanted) != -1:
            v = d[k] = str(v).replace(unwanted, ' ')

modules = [
    Extension(
        "_cadbiom",
74
        ["_cadbiom/cadbiom.c"],
75
        language = "c",
76
        include_dirs=['_cadbiom', '.'],
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
        define_macros=[
            ('CADBIOM_VERSION', '"' + __LIBRARY_VERSION__ + '"'),
        ],
        extra_compile_args=[
            "-flto",
            "-march=native",
            "-mtune=native",
            "-Ofast",
            #"-Wall",
            #"-g", # Not define NDEBUG macro => Debug build
            "-DNDEBUG", # Force release build
            "-std=c11",
            "-Wno-unused-variable",
            "-Wno-unused-but-set-variable",
            # assume that signed arithmetic overflow of addition, subtraction
            # and multiplication wraps around using twos-complement
            # representation
            "-fwrapv",
95
            # BOF protect (use both)
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
            #"-D_FORTIFY_SOURCE=2",
            #"-fstack-protector-strong",
            "-pthread",
            "-DUSE_PTHREADS",
            "-D_GLIBCXX_PARALLEL",
        ],
        extra_link_args=[
            "-Ofast",
            "-march=native",
            "-flto",
            "-std=c11",
        ]
    ),
]

setup(
112
    name="cadbiom",
113
    version=__PACKAGE_VERSION__,
114
115
    author="Pierre Vignet",
    author_email="pierre.vignet@irisa.fr",
116
    url = "https://gitlab.inria.fr/pvignet/cadbiom",
117
118
119
120
121

    # Search all packages recursively
    packages=find_packages(),

    classifiers=[
122
        "Development Status :: 4 - Beta",
123
124
        "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
        "Natural Language :: French",
125
126
        "Intended Audience :: Developers",
        "Operating System :: OS Independent",
127
        "Programming Language :: C",
128
        "Programming Language :: Python :: 2.7",
129
        "Topic :: Scientific/Engineering :: Bio-Informatics",
130
    ],
131
132
133
    ext_modules=modules,
    description="Cadbiom library",
    long_description=open('README.md').read(),
134
    install_requires=["networkx<2", "lxml", "pycryptosat>0.1.2"],
135
136
137
138

    # Tests
    tests_require=['pytest'],
    cmdclass={'test': PyTest},
139
)