This commit is contained in:
Keith Battocchi 2021-02-17 01:16:11 -05:00 коммит произвёл Keith Battocchi
Родитель 77e7216991
Коммит fc600501fd
5 изменённых файлов: 32 добавлений и 52 удалений

Просмотреть файл

@ -69,6 +69,9 @@ jobs:
- script: 'pip install git+https://github.com/slundberg/shap.git@d1d2700acc0259f211934373826d5ff71ad514de'
displayName: 'Install specific version of shap'
- script: 'pip install "sphinx < 3.2" sphinx_rtd_theme'
displayName: 'Install sphinx'
- script: 'python setup.py build_sphinx -W'
displayName: 'Build documentation'
@ -95,7 +98,7 @@ jobs:
- script: 'pip install -U numpy'
displayName: 'Upgrade numpy'
- script: 'python setup.py pytest'
- script: 'pip install pytest-runner && python setup.py pytest'
displayName: 'Unit tests'
env:
PYTEST_ADDOPTS: '-m "notebook"'
@ -200,7 +203,7 @@ jobs:
- template: azure-pipelines-steps.yml
parameters:
body:
- script: 'python setup.py pytest'
- script: 'pip install pytest-runner && python setup.py pytest'
displayName: 'Unit tests'
env:
PYTEST_ADDOPTS: '-m "not (notebook or automl)"'

Просмотреть файл

@ -1,37 +0,0 @@
"""
Utilities useful during the build.
"""
import os
import sklearn
import contextlib
from distutils.version import LooseVersion
CYTHON_MIN_VERSION = '0.28.5'
def _check_cython_version():
message = ('Please install Cython with a version >= {0} in order '
'to build a scikit-learn from source.').format(
CYTHON_MIN_VERSION)
try:
import Cython
except ModuleNotFoundError:
# Re-raise with more informative error message instead:
raise ModuleNotFoundError(message)
if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
message += (' The current version of Cython is {} installed in {}.'
.format(Cython.__version__, Cython.__path__))
raise ValueError(message)
def cythonize_extensions(top_path, config):
"""Check that a recent Cython is available and cythonize extensions"""
_check_cython_version()
from Cython.Build import cythonize
config.ext_modules = cythonize(
config.ext_modules,
compiler_directives={'language_level': 3})

Просмотреть файл

@ -2,9 +2,9 @@
requires = [
"setuptools",
"wheel",
"Cython",
"numpy == 1.19.3",
"scipy"
"oldest-supported-numpy",
"scipy",
"cython"
]
build-backend = "setuptools.build_meta"

Просмотреть файл

@ -30,11 +30,6 @@ classifiers =
[options]
packages = find_namespace:
setup_requires =
pytest-runner
sphinx < 3.2
sphinx_rtd_theme
Cython
install_requires =
numpy
scipy > 1.4.0
@ -75,11 +70,12 @@ all =
tensorflow > 1.10, < 2.3
matplotlib
; TODO: exclude tests?
[options.packages.find]
include =
econml
econml.*
exclude =
econml.tests
[options.package_data]
; include all CSV files as data

Просмотреть файл

@ -1,9 +1,10 @@
from setuptools import setup
from setuptools.extension import Extension
from Cython.Build import cythonize
import numpy as np
import os
import re
from glob import glob
from pathlib import Path
with open(os.path.join(os.path.dirname(__file__), "econml", "__init__.py")) as file:
for line in file:
@ -11,9 +12,26 @@ with open(os.path.join(os.path.dirname(__file__), "econml", "__init__.py")) as f
if m:
version = m.group(1)
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 = []
# configuration is all pulled from setup.cfg
setup(ext_modules=cythonize([Extension("*", ["**/*.pyx"],
include_dirs=[np.get_include()])],
language_level="3"),
setup(ext_modules=c_extensions + pyx_extensions,
zip_safe=False,
version=version)