File: setup.py

package info (click to toggle)
python-skbio 0.6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 9,312 kB
  • sloc: python: 60,482; ansic: 672; makefile: 224
file content (240 lines) | stat: -rw-r--r-- 7,318 bytes parent folder | download
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/usr/bin/env python

"""Setup script for scikit-bio installation.

----------------------------------------------------------------------------
Copyright (c) 2013--, scikit-bio development team.

Distributed under the terms of the Modified BSD License.

The full license is in the file LICENSE.txt, distributed with this software.
----------------------------------------------------------------------------
"""

import os
import platform
import re
import ast
import sys
import sysconfig
import subprocess

from setuptools import find_packages, setup
from setuptools.extension import Extension

import numpy as np
from Cython.Build import cythonize


if sys.version_info.major != 3:
    sys.exit(
        "scikit-bio can only be used with Python 3. You are currently "
        "running Python %d." % sys.version_info.major
    )


def check_bin(ccbin, source, allow_dash):
    """Check if a given compiler matches the specified name."""
    # remove any parameters (e.g. gcc -I /a/b/c -> gcc)
    source0 = source.split()[0]
    # remove any path
    bsource = os.path.basename(source0)
    # now let's go search for ccbin
    if allow_dash:
        found = False
        # allow for the ccbin to be between - (e.g. gcc-1.2)
        for el in bsource.split("-"):
            if el == ccbin:
                found = True
                break
    else:
        found = bsource == ccbin
    return found


# Note: We are looking for Apple/MacOS clang, which does not support omp
#       Will treat "real clang" (e.g. llvm based) same as gcc
clang = False

# icc uses slightly different omp cmdline arguments
icc = False

# Are we using the default gcc as the compiler?
gcc = True
try:
    if os.environ["CC"] == "gcc":
        gcc = True
    elif os.environ["CC"] != "":
        gcc = False
except KeyError:
    pass


if not gcc:
    try:
        if check_bin("clang", os.environ["CC"], False):
            # note, the conda provideed clang is not detected here
            # and this is on purpose, as MacOS clang is very different
            # than conda-provised one (which is llvm based)
            # so do not look for substrings
            # (e.g. do not match x86_64-apple-darwin13.4.0-clang)
            clang = True
        elif check_bin("icc", os.environ["CC"], True):
            icc = True
    except KeyError:
        pass
else:
    try:
        if check_bin("clang", sysconfig.get_config_vars()["CC"], False):
            # as above
            clang = True
            gcc = False
        elif check_bin("icc", sysconfig.get_config_vars()["CC"], True):
            icc = True
            gcc = False
    except KeyError:
        pass

if gcc:
    # check if the default gcc is just a wrapper around clang
    try:
        if (
            subprocess.check_output(["gcc", "--version"], universal_newlines=True).find(
                "clang"
            )
            != -1
        ):
            clang = True
    except (subprocess.CalledProcessError, FileNotFoundError):
        pass

# version parsing from __init__ pulled from Flask's setup.py
# https://github.com/mitsuhiko/flask/blob/master/setup.py
_version_re = re.compile(r"__version__\s+=\s+(.*)")

with open("skbio/__init__.py", "rb") as f:
    hit = _version_re.search(f.read().decode("utf-8")).group(1)
    version = str(ast.literal_eval(hit))

classes = """
    Development Status :: 4 - Beta
    License :: OSI Approved :: BSD License
    Topic :: Software Development :: Libraries
    Topic :: Scientific/Engineering
    Topic :: Scientific/Engineering :: Bio-Informatics
    Programming Language :: Python :: 3
    Programming Language :: Python :: 3 :: Only
    Programming Language :: Python :: 3.8
    Programming Language :: Python :: 3.9
    Programming Language :: Python :: 3.10
    Programming Language :: Python :: 3.11
    Programming Language :: Python :: 3.12
    Programming Language :: Python :: 3.13
    Operating System :: Unix
    Operating System :: POSIX
    Operating System :: MacOS :: MacOS X
    Operating System :: Microsoft :: Windows
"""
classifiers = [s.strip() for s in classes.split("\n") if s]

description = (
    "Data structures, algorithms and educational " "resources for bioinformatics."
)

with open("README.rst") as f:
    long_description = f.read()


# Compile SSW module
ssw_extra_compile_args = ["-I."]

if platform.system() != "Windows":
    if icc:
        ssw_extra_compile_args.extend(["-qopenmp-simd", "-DSIMDE_ENABLE_OPENMP"])
    elif not clang:
        ssw_extra_compile_args.extend(["-fopenmp-simd", "-DSIMDE_ENABLE_OPENMP"])
elif platform.system() == "Windows":
    ssw_extra_compile_args.extend(["-openmp:experimental"])

stats_extra_compile_args = [] + ssw_extra_compile_args
stats_extra_link_args = []
if platform.system() != "Windows":
    if icc:
        stats_extra_compile_args.extend(["-qopenmp"])
        stats_extra_link_args.extend(["-qopenmp"])
    elif not clang:
        stats_extra_compile_args.extend(["-fopenmp"])
        stats_extra_link_args.extend(["-fopenmp"])


# Cython modules (*.pyx). They will be compiled into C code (*.c) during build.
ext = ".pyx"
extensions = [
    Extension("skbio.metadata._intersection", ["skbio/metadata/_intersection" + ext]),
    Extension(
        "skbio.alignment._ssw_wrapper",
        ["skbio/alignment/_ssw_wrapper" + ext],
        include_dirs=[np.get_include()],
        libraries=['ssw']
    ),
    Extension(
        "skbio.diversity._phylogenetic",
        ["skbio/diversity/_phylogenetic" + ext],
        include_dirs=[np.get_include()],
    ),
    Extension(
        "skbio.stats.ordination._cutils",
        ["skbio/stats/ordination/_cutils" + ext],
        extra_compile_args=stats_extra_compile_args,
        extra_link_args=stats_extra_link_args,
    ),
    Extension(
        "skbio.stats.distance._cutils",
        ["skbio/stats/distance/_cutils" + ext],
        extra_compile_args=stats_extra_compile_args,
        extra_link_args=stats_extra_link_args,
    ),
]

extensions = cythonize(extensions, force=True)


setup(
    name="scikit-bio",
    version=version,
    license="BSD-3-Clause",
    description=description,
    long_description=long_description,
    author="scikit-bio development team",
    author_email="qiyunzhu@gmail.com",
    maintainer="scikit-bio development team",
    maintainer_email="qiyunzhu@gmail.com",
    url="https://scikit.bio",
    packages=find_packages(),
    ext_modules=extensions,
    include_dirs=[np.get_include()],
    tests_require=["pytest", "coverage"],
    install_requires=[
        "requests >= 2.20.0",
        "decorator >= 3.4.2",
        "natsort >= 4.0.3",
        "numpy >= 1.17.0",
        "pandas >= 1.5.0",
        "scipy >= 1.9.0",
        "h5py >= 3.6.0",
        "biom-format >= 2.1.16",
        "statsmodels >= 0.14.0",
    ],
    classifiers=classifiers,
    package_data={
        "skbio.diversity.alpha.tests": ["data/qiime-191-tt/*"],
        "skbio.diversity.beta.tests": ["data/qiime-191-tt/*"],
        "skbio.io.tests": ["data/*"],
        "skbio.io.format.tests": ["data/*"],
        "skbio.stats.tests": ["data/*"],
        "skbio.stats.distance.tests": ["data/*"],
        "skbio.stats.ordination.tests": ["data/*"],
        "skbio.metadata.tests": ["data/invalid/*", "data/valid/*"],
        "skbio.embedding.tests": ["data/*"],
    },
)