File: setup.py

package info (click to toggle)
abpoa 1.5.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,060 kB
  • sloc: ansic: 8,434; sh: 762; makefile: 194; python: 115
file content (75 lines) | stat: -rw-r--r-- 2,727 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
import os

try:
    from setuptools import setup, Extension
except ImportError:
    from distutils.core import setup
    from distutils.extension import Extension


simde = ['-DUSE_SIMDE', '-DSIMDE_ENABLE_NATIVE_ALIASES']

machine_system = os.popen("uname").readlines()[0].rsplit()[0]
machine_arch = os.popen("uname -m").readlines()[0].rsplit()[0]

if machine_system == "Darwin":
    # note: see https://github.com/pypa/wheel/issues/406
    simd_flag = ['-march=native', '-D__AVX2__', '-mmacosx-version-min=10.9']
    if machine_arch in ["aarch64", "arm64"]:
        os.environ['_PYTHON_HOST_PLATFORM'] = "macosx-10.9-arm64"
        os.environ['ARCHFLAGS'] = "-arch arm64"
    else: # x86_64
        os.environ['_PYTHON_HOST_PLATFORM'] = "macosx-10.9-x86_64"
        os.environ['ARCHFLAGS'] = "-arch x86_64"
else:
    if machine_arch in ["aarch64", "arm64"]:
        simd_flag = ['-march=armv8-a+simd', '-D__AVX2__']
    elif machine_arch in ["aarch32"]:
        simd_flag = ['-march=armv8-a+simd', '-mfpu=auto -D__AVX2__']
    else: # x86_64
        simd_flag=[]
        if os.getenv('SSE4', False):
            simd_flag=['-msse4.1']
        elif os.getenv('SSE2', False):
            simd_flag=['-msse2']
        elif os.getenv('AVX2', False):
            simd_flag=['-mavx2']
        elif os.getenv('AVX512BW', False):
           simd_flag='-mavx512bw'

src_dir = 'src/'
inc_dir = 'include/'
sources = [
    'abpoa_align.c', 'abpoa_align_simd.c',
    'abpoa_graph.c', 'abpoa_output.c', 'abpoa_plot.c', 'abpoa_seed.c', 'abpoa_seq.c',
    'abpoa_simd.c', 
    'kalloc.c', 'kstring.c',
    'utils.c']
depends = [
    'abpoa.h', 'abpoa_align.h', 'abpoa_align_simd.h', 
    'abpoa_graph.h', 'abpoa_output.h', 'abpoa_seed.h', 'abpoa_seq.h', 'abpoa_simd.h',
    'kalloc.h', 'khash.h', 'kdq.h', 'kseq.h', 'ksort.h', 'kstring.h', 'kvec.h',
    'simd_instruction.h', 'utils.h']

module_src = 'python/pyabpoa.pyx'
module_dep = 'python/cabpoa.pxd'

long_description = open('python/README.md').read()

setup(
    # Information
    long_description = long_description,
    long_description_content_type="text/markdown",
    setup_requires=["cython"],
    # Build instructions
    ext_modules = [
        Extension(
            "pyabpoa",
            sources=[module_src] + [src_dir + x for x in sources],
            include_dirs=[inc_dir],
            depends=[module_dep] + [src_dir + x for x in depends],
            libraries=['z', 'm', 'pthread'],
            # extra_compile_args=['-O3', '-Wno-error=declaration-after-statement', '-D __DEBUG__'] + simde + simd_flag
            extra_compile_args=['-O3', '-Wno-unused-function', '-Wno-misleading-indentation', '-Wno-error=declaration-after-statement'] + simde + simd_flag
    )]
)