setup.py 4.76 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

VIGNET Pierre's avatar
VIGNET Pierre committed
38
__PACKAGE_VERSION__ = "0.1.3"
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 67 68 69 70 71 72 73 74
# 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():
    for unwanted in ('-Wstrict-prototypes', '-DNDEBUG', ' -g ',
                     '-O2', '-D_FORTIFY_SOURCE=2', '-fstack-protector-strong'):
        if str(v).find(unwanted) != -1:
            v = d[k] = str(v).replace(unwanted, ' ')

modules = [
    Extension(
        "_cadbiom",
75
        ["_cadbiom/cadbiom.c"],
76
        language = "c",
77
        include_dirs=['_cadbiom', '.'],
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
        define_macros=[
            ('CADBIOM_VERSION', '"' + __LIBRARY_VERSION__ + '"'),
        ],
        extra_compile_args=[
            "-flto",
            "-march=native",
            "-mtune=native",
            "-Ofast",
            #"-O3",
            #"-Wall",
            #"-g", # Not define NDEBUG macro => Debug build
            "-DNDEBUG", # Force release build
            #"-DBOOST_TEST_DYN_LINK",
            #"-DUSE_ZLIB",
            "-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",
            #BOF protect (use both)
            #"-D_FORTIFY_SOURCE=2",
            #"-fstack-protector-strong",
            "-pthread",
            "-DUSE_PTHREADS",
            "-fopenmp",
            "-D_GLIBCXX_PARALLEL",
        ],
        extra_link_args=[
            "-Ofast",
            "-march=native",
            "-flto",
            "-std=c11",
            "-fopenmp",
        ]
    ),
]

setup(
118
    name="cadbiom",
119
    version=__PACKAGE_VERSION__,
120 121
    author="Pierre Vignet",
    author_email="pierre.vignet@irisa.fr",
122
    url = "https://gitlab.irisa.fr/0000B8EG/Cadbiom/tree/pypi_packaging",
123 124 125 126 127

    # Search all packages recursively
    packages=find_packages(),

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

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