| 1 |
import os |
| 2 |
|
| 3 |
try: |
| 4 |
from setuptools import setup, Extension |
| 5 |
except ImportError: |
| 6 |
from distutils.core import setup |
| 7 |
from distutils.extension import Extension |
| 8 |
|
| 9 |
|
| 10 |
simde = ['-DUSE_SIMDE', '-DSIMDE_ENABLE_NATIVE_ALIASES'] |
| 11 |
|
| 12 |
machine_system = os.popen("uname").readlines()[0].rsplit()[0] |
| 13 |
machine_arch = os.popen("uname -m").readlines()[0].rsplit()[0] |
| 14 |
|
| 15 |
if machine_system == "Darwin": |
| 16 |
# note: see https://github.com/pypa/wheel/issues/406 |
| 17 |
simd_flag = ['-march=native', '-D__AVX2__', '-mmacosx-version-min=10.9'] |
| 18 |
if machine_arch in ["aarch64", "arm64"]: |
| 19 |
os.environ['_PYTHON_HOST_PLATFORM'] = "macosx-10.9-arm64" |
| 20 |
os.environ['ARCHFLAGS'] = "-arch arm64" |
| 21 |
else: # x86_64 |
| 22 |
os.environ['_PYTHON_HOST_PLATFORM'] = "macosx-10.9-x86_64" |
| 23 |
os.environ['ARCHFLAGS'] = "-arch x86_64" |
| 24 |
else: |
| 25 |
if machine_arch in ["aarch64", "arm64"]: |
| 26 |
simd_flag = ['-march=armv8-a+simd', '-D__AVX2__'] |
| 27 |
elif machine_arch in ["aarch32"]: |
| 28 |
simd_flag = ['-march=armv8-a+simd', '-mfpu=auto -D__AVX2__'] |
| 29 |
elif machine_arch.startswith("riscv"): |
| 30 |
simd_flag = ['-D__AVX2__'] |
| 31 |
else: # x86_64 |
| 32 |
simd_flag=['-march=native'] |
| 33 |
if os.getenv('SSE4', False): |
| 34 |
simd_flag=['-msse4.1'] |
| 35 |
elif os.getenv('SSE2', False): |
| 36 |
simd_flag=['-msse2'] |
| 37 |
elif os.getenv('AVX2', False): |
| 38 |
simd_flag=['-mavx2'] |
| 39 |
elif os.getenv('AVX512BW', False): |
| 40 |
simd_flag='-mavx512bw' |
| 41 |
|
| 42 |
src_dir = 'src/' |
| 43 |
inc_dir = 'include/' |
| 44 |
sources = [ |
| 45 |
'abpoa_align.c', 'abpoa_align_simd.c', |
| 46 |
'abpoa_graph.c', 'abpoa_output.c', 'abpoa_plot.c', 'abpoa_seed.c', 'abpoa_seq.c', |
| 47 |
'abpoa_simd.c', |
| 48 |
'kalloc.c', 'kstring.c', |
| 49 |
'utils.c'] |
| 50 |
depends = [ |
| 51 |
'abpoa.h', 'abpoa_align.h', 'abpoa_align_simd.h', |
| 52 |
'abpoa_graph.h', 'abpoa_output.h', 'abpoa_seed.h', 'abpoa_seq.h', 'abpoa_simd.h', |
| 53 |
'kalloc.h', 'khash.h', 'kdq.h', 'kseq.h', 'ksort.h', 'kstring.h', 'kvec.h', |
| 54 |
'simd_instruction.h', 'utils.h'] |
| 55 |
|
| 56 |
module_src = 'python/pyabpoa.pyx' |
| 57 |
module_dep = 'python/cabpoa.pxd' |
| 58 |
|
| 59 |
long_description = open('python/README.md').read() |
| 60 |
|
| 61 |
setup( |
| 62 |
# Information |
| 63 |
long_description = long_description, |
| 64 |
long_description_content_type="text/markdown", |
| 65 |
setup_requires=["cython"], |
| 66 |
# Build instructions |
| 67 |
ext_modules = [ |
| 68 |
Extension( |
| 69 |
"pyabpoa", |
| 70 |
sources=[module_src] + [src_dir + x for x in sources], |
| 71 |
include_dirs=[inc_dir], |
| 72 |
depends=[module_dep] + [src_dir + x for x in depends], |
| 73 |
libraries=['z', 'm', 'pthread'], |
| 74 |
# extra_compile_args=['-O3', '-Wno-error=declaration-after-statement', '-D __DEBUG__'] + simde + simd_flag |
| 75 |
extra_compile_args=['-O3', '-Wno-unused-function', '-Wno-misleading-indentation', '-Wno-error=declaration-after-statement'] + simde + simd_flag |
| 76 |
)] |
| 77 |
) |