2021-01-09 06:29:56 +03:00
|
|
|
from setuptools import setup
|
|
|
|
from setuptools.extension import Extension
|
|
|
|
import numpy as np
|
2021-02-04 17:39:21 +03:00
|
|
|
import os
|
|
|
|
import re
|
2021-02-17 09:16:11 +03:00
|
|
|
from glob import glob
|
2021-01-09 06:29:56 +03:00
|
|
|
|
2021-08-04 19:42:30 +03:00
|
|
|
with open(os.path.join(os.path.dirname(__file__), "econml", "_version.py")) as file:
|
2021-02-04 17:39:21 +03:00
|
|
|
for line in file:
|
|
|
|
m = re.fullmatch("__version__ = '([^']+)'\n", line)
|
|
|
|
if m:
|
|
|
|
version = m.group(1)
|
2019-03-06 23:44:17 +03:00
|
|
|
|
2021-02-17 09:16:11 +03:00
|
|
|
pyx_files = glob("econml/**/*.pyx", recursive=True)
|
|
|
|
c_files = glob("econml/**/*.c", recursive=True)
|
|
|
|
|
|
|
|
# If both a .pyx and a .c file exist, we assume the .c file is up to date and don't force a recompile
|
|
|
|
pyx_files = [file for file in pyx_files if (os.path.splitext(file)[0] + ".c") not in c_files]
|
|
|
|
|
|
|
|
c_extensions = [Extension(os.path.splitext(file)[0].replace(os.sep, '.'),
|
|
|
|
[file],
|
|
|
|
include_dirs=[np.get_include()])
|
|
|
|
for file in c_files]
|
|
|
|
|
|
|
|
if pyx_files:
|
|
|
|
from Cython.Build import cythonize
|
|
|
|
pyx_extensions = cythonize([Extension("*",
|
|
|
|
pyx_files,
|
|
|
|
include_dirs=[np.get_include()])],
|
|
|
|
language_level="3")
|
|
|
|
else:
|
|
|
|
pyx_extensions = []
|
2019-03-06 23:44:17 +03:00
|
|
|
# configuration is all pulled from setup.cfg
|
2021-02-17 09:16:11 +03:00
|
|
|
setup(ext_modules=c_extensions + pyx_extensions,
|
2021-02-04 17:39:21 +03:00
|
|
|
zip_safe=False,
|
|
|
|
version=version)
|