-
Notifications
You must be signed in to change notification settings - Fork 22
/
setup.py
executable file
·113 lines (103 loc) · 4.95 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from setuptools import find_packages
from distutils.core import setup, Extension
import os
from Cython.Build import cythonize
import numpy
import platform
import sys
import re
if platform.system() == "Darwin":
if platform.processor() == "arm":
os.environ["CC"] = "/opt/homebrew/opt/llvm/bin/clang"
os.environ["LDFLAGS"] = "-L/opt/homebrew/opt/llvm/lib"
os.environ["CPPFLAGS"] = "-I/opt/homebrew/opt/llvm/include"
gsl_inc = "/opt/homebrew/opt/gsl/include"
gsl_lib = "/opt/homebrew/opt/gsl/lib"
else:
os.environ["CC"] = "gcc-11"
os.environ["CXX"] = "g++-11"
gsl_inc = "/usr/local/include"
gsl_lib = "/usr/local/lib"
elif platform.system() == "Linux":
pass
elif platform.system() == "Windows":
gsl_inc = "C:\\gsl\\include"
gsl_lib = "C:\\gsl\\lib"
else:
raise ValueError("Cannot build wheel for OS: {}".format(platform.system()))
def get_extension(module_name, src_name, current_os):
sources = [src_name, os.path.join("fathon", "cLoops.c")]
if current_os == "Darwin":
return Extension(module_name,
sources=sources,
include_dirs=[numpy.get_include(), gsl_inc],
library_dirs=[gsl_lib],
libraries=["gsl", "gslcblas", "m"],
extra_compile_args=["-O2", "-fopenmp"],
extra_link_args=["-fopenmp"])
elif current_os == "Linux":
return Extension(module_name,
sources=sources,
include_dirs=[numpy.get_include()],
libraries=["gsl", "gslcblas", "m"],
extra_compile_args=["-O2", "-fopenmp"],
extra_link_args=["-fopenmp"])
elif current_os == "Windows":
return Extension(module_name,
sources=sources,
include_dirs=[numpy.get_include(), gsl_inc],
library_dirs=[gsl_lib],
libraries=["gsl", "gslcblas"],
extra_compile_args=["/O2", "-openmp"],
extra_link_args=[])
if __name__ == "__main__":
if sys.version_info[0] == 3:
running_os = platform.system()
extensions = [get_extension("fathon.dfa", os.path.join("fathon", "dfa.pyx"), running_os),
get_extension("fathon.dcca", os.path.join("fathon", "dcca.pyx"), running_os),
get_extension("fathon.mfdfa", os.path.join("fathon", "mfdfa.pyx"), running_os),
get_extension("fathon.mfdcca", os.path.join("fathon", "mfdcca.pyx"), running_os),
get_extension("fathon.ht", os.path.join("fathon", "ht.pyx"), running_os)]
README = ""
chk = 0
readme_file = open(os.path.join("docs", "index.rst"), "r", encoding="utf8")
for line in readme_file:
if line[:6] == "fathon":
chk = 1
if line[:13] == "Documentation":
chk = 0
if chk == 1:
README += re.sub(":code:", "", line)
readme_file.close()
setup(name="fathon",
version="1.3.3.post1",
author="Stefano Bianchi",
author_email="[email protected]",
url="https://github.com/stfbnc/fathon.git",
license="GPLv3.0",
description="A python package for detrended fluctuation analysis (DFA) and related algorithms.",
long_description_content_type="text/markdown",
long_description=README,
packages=find_packages(),
classifiers=["License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: MacOS",
"Operating System :: Unix",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Cython",
"Programming Language :: C",
"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",
"Topic :: Scientific/Engineering"],
python_requires=">=3.8",
install_requires=["numpy>=1.24.4"],
project_urls={"Documentation": "https://fathon.readthedocs.io/",
"Bug Reports": "https://github.com/stfbnc/fathon/issues",
"Source": "https://github.com/stfbnc/fathon/"},
ext_modules=cythonize(extensions),
package_data={"fathon": ["LICENSE"]},
include_package_data=True)
else:
sys.exit("fathon requires python 3.")