-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
101 lines (88 loc) · 3.34 KB
/
setup.py
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
from setuptools import setup, Extension, find_packages
import platform
from glob import glob
from pybind11.setup_helpers import Pybind11Extension, build_ext
from ctypes.util import find_library
from codecs import open
from os import path
import os
import re
import io
# Get version strip
def read(*names, **kwargs):
with io.open(os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8")) as fp:
return fp.read()
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
# deal with openmp etc
openmp = os.getenv("ompy_OpenMP")
if openmp is None and platform.system() == 'Darwin': # Check if macOS
if find_library("omp") != None:
openmp = True
print("libOMP found, building with OpenMP")
else:
print("libOMP not found, building without OpenMP")
elif openmp in (None, True, "True", "true"):
openmp = True
elif openmp in (False, "False", "false"):
openmp = False
print("Building without OpenMP")
else:
raise ValueError("Env var ompy_OpenMP must be either True or False "
"(or not set); use eg. 'export ompy_OpenMP=False'"
f"Now it is: {openmp}")
extra_compile_args = ["-O3", "-ffast-math", "-march=native"]
extra_link_args = ["-lz"]
if openmp and platform.system() == 'Darwin':
extra_compile_args.insert(-1, "-Xpreprocessor")
extra_compile_args.insert(-1, "-fopenmp")
extra_link_args.insert(-1, "-lomp")
elif openmp:
extra_compile_args.insert(-1, "-fopenmp")
extra_link_args.insert(-1, "-fopenmp")
ext_modules = [
Pybind11Extension("TRACS",
["src/python_bindings.cpp"],
# Example: passing in the version to the compiled code
define_macros = [('VERSION_INFO', find_version("tracs/__init__.py"))],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args),
]
setup(
name="tracs",
version=find_version("tracs/__init__.py"),
author="Gerry Tonkin-Hill",
description=
"A fast python and and c++ pipeline for identifying transmission clusters from single genome and metagenomic data",
long_description_content_type="text/markdown",
url="https://github.com/gtonkinhill/tracs",
install_requires=[
'numpy', 'scipy', 'plotly', 'matplotlib', 'pyfastx', 'datetime', 'tqdm', 'sourmash', 'joblib', 'ncbi_genome_download'
],
python_requires='>=3.9.0',
packages=['tracs'],
keywords='transmission clustering metagenomics',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Bio-Informatics',
],
entry_points={
'console_scripts':
['tracs = tracs.__main__:main',],
},
ext_modules=ext_modules,
extras_require={"test": "pytest"},
# Currently, build_ext only provides an optional "highest supported C++
# level" feature, but in the future it may provide more features.
cmdclass={"build_ext": build_ext},
)