setup.py 4.57 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
#     Pierre Vignet.
22
#     IRISA/IRSET
23 24
#     Dyliss team
#     IRISA Campus de Beaulieu
25 26 27
#     35042 RENNES Cedex, FRANCE

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

29 30
# Standard imports
import sys
31
from distutils import sysconfig
32
from setuptools import setup, Extension, find_packages
33
from setuptools.command.test import test as TestCommand
34

VIGNET Pierre's avatar
VIGNET Pierre committed
35
__PACKAGE_VERSION__ = "0.2.1"
VIGNET Pierre's avatar
VIGNET Pierre committed
36
__LIBRARY_VERSION__ = "1.0.1"
37

38 39 40 41 42 43 44 45 46 47 48
################################################################################

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
VIGNET Pierre's avatar
VIGNET Pierre committed
49
        errno = pytest.main(self.pytest_args)
50 51 52 53
        sys.exit(errno)

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

54 55 56 57 58 59 60 61 62 63
# 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():
64
    for unwanted in (' -g ',):
65 66 67 68 69 70
        if str(v).find(unwanted) != -1:
            v = d[k] = str(v).replace(unwanted, ' ')

modules = [
    Extension(
        "_cadbiom",
71
        ["_cadbiom/cadbiom.c"],
72
        language = "c",
73
        include_dirs=['_cadbiom', '.'],
74 75 76 77 78
        define_macros=[
            ('CADBIOM_VERSION', '"' + __LIBRARY_VERSION__ + '"'),
        ],
        extra_compile_args=[
            "-flto",
79 80
            #"-march=native",
            #"-mtune=native",
81 82 83 84 85 86 87 88 89 90 91
            "-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",
92
            # BOF protect (use both)
93 94 95 96 97 98
            #"-D_FORTIFY_SOURCE=2",
            #"-fstack-protector-strong",
            "-pthread",
            "-DUSE_PTHREADS",
        ],
        extra_link_args=[
99
            "-fPIC",
100
            "-Ofast",
101
            #"-march=native",
102 103
            "-flto",
            "-std=c11",
104
            "-Wl,--as-needed",
105 106 107 108 109
        ]
    ),
]

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

    # Search all packages recursively
    packages=find_packages(),

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

    # Tests
140
    tests_require=['pytest<3.7'],
141
    cmdclass={'test': PyTest},
142
)