From eed8f56c787a251a6cad0f4291ca8f4055e463cf Mon Sep 17 00:00:00 2001 From: Jack Mitchell Date: Fri, 22 Jan 2021 10:16:08 +0000 Subject: [PATCH] hack around numpy get_include to force looking in target sysroot --- sklearn/__check_build/setup.py | 4 ++-- sklearn/cluster/setup.py | 12 ++++++------ sklearn/datasets/setup.py | 4 ++-- sklearn/decomposition/setup.py | 6 +++--- sklearn/ensemble/setup.py | 22 +++++++++++----------- sklearn/feature_extraction/setup.py | 4 ++-- sklearn/linear_model/setup.py | 8 ++++---- sklearn/manifold/setup.py | 6 +++--- sklearn/metrics/cluster/setup.py | 4 ++-- sklearn/neighbors/setup.py | 15 +++++++-------- sklearn/preprocessing/setup.py | 4 ++-- sklearn/setup.py | 4 ++-- sklearn/svm/setup.py | 11 ++++++----- sklearn/tree/setup.py | 10 +++++----- sklearn/utils/setup.py | 16 ++++++++-------- 15 files changed, 65 insertions(+), 65 deletions(-) diff --git a/sklearn/__check_build/setup.py b/sklearn/__check_build/setup.py index b8c30d9c8..e2bfc90ee 100644 --- a/sklearn/__check_build/setup.py +++ b/sklearn/__check_build/setup.py @@ -1,7 +1,7 @@ # Author: Virgile Fritsch # License: BSD 3 clause -import numpy +import numpy, os def configuration(parent_package='', top_path=None): @@ -9,7 +9,7 @@ def configuration(parent_package='', top_path=None): config = Configuration('__check_build', parent_package, top_path) config.add_extension('_check_build', sources=['_check_build.pyx'], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) return config diff --git a/sklearn/cluster/setup.py b/sklearn/cluster/setup.py index 48ed25c5c..bd395e3aa 100644 --- a/sklearn/cluster/setup.py +++ b/sklearn/cluster/setup.py @@ -2,7 +2,7 @@ # License: BSD 3 clause import os -import numpy +import numpy, os def configuration(parent_package='', top_path=None): @@ -16,28 +16,28 @@ def configuration(parent_package='', top_path=None): config.add_extension('_dbscan_inner', sources=['_dbscan_inner.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], language="c++") config.add_extension('_hierarchical_fast', sources=['_hierarchical_fast.pyx'], language="c++", - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('_k_means_fast', sources=['_k_means_fast.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('_k_means_lloyd', sources=['_k_means_lloyd.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('_k_means_elkan', sources=['_k_means_elkan.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_subpackage('tests') diff --git a/sklearn/datasets/setup.py b/sklearn/datasets/setup.py index 1107505d4..de4ac3c87 100644 --- a/sklearn/datasets/setup.py +++ b/sklearn/datasets/setup.py @@ -1,5 +1,5 @@ -import numpy +import numpy, os import os import platform @@ -14,7 +14,7 @@ def configuration(parent_package='', top_path=None): if platform.python_implementation() != 'PyPy': config.add_extension('_svmlight_format_fast', sources=['_svmlight_format_fast.pyx'], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_subpackage('tests') return config diff --git a/sklearn/decomposition/setup.py b/sklearn/decomposition/setup.py index f915d6d78..26799c0af 100644 --- a/sklearn/decomposition/setup.py +++ b/sklearn/decomposition/setup.py @@ -1,5 +1,5 @@ import os -import numpy +import numpy, os from numpy.distutils.misc_util import Configuration @@ -12,12 +12,12 @@ def configuration(parent_package="", top_path=None): config.add_extension("_online_lda_fast", sources=["_online_lda_fast.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('_cdnmf_fast', sources=['_cdnmf_fast.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_subpackage("tests") diff --git a/sklearn/ensemble/setup.py b/sklearn/ensemble/setup.py index 05d71cf31..c12382220 100644 --- a/sklearn/ensemble/setup.py +++ b/sklearn/ensemble/setup.py @@ -1,4 +1,4 @@ -import numpy +import numpy, os from numpy.distutils.misc_util import Configuration @@ -7,7 +7,7 @@ def configuration(parent_package="", top_path=None): config.add_extension("_gradient_boosting", sources=["_gradient_boosting.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_subpackage("tests") @@ -15,39 +15,39 @@ def configuration(parent_package="", top_path=None): config.add_extension( "_hist_gradient_boosting._gradient_boosting", sources=["_hist_gradient_boosting/_gradient_boosting.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting.histogram", sources=["_hist_gradient_boosting/histogram.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting.splitting", sources=["_hist_gradient_boosting/splitting.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting._binning", sources=["_hist_gradient_boosting/_binning.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting._predictor", sources=["_hist_gradient_boosting/_predictor.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting._loss", sources=["_hist_gradient_boosting/_loss.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting._bitset", sources=["_hist_gradient_boosting/_bitset.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting.common", sources=["_hist_gradient_boosting/common.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension("_hist_gradient_boosting.utils", sources=["_hist_gradient_boosting/utils.pyx"], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_subpackage("_hist_gradient_boosting.tests") diff --git a/sklearn/feature_extraction/setup.py b/sklearn/feature_extraction/setup.py index 8c3bbb100..a872c7603 100644 --- a/sklearn/feature_extraction/setup.py +++ b/sklearn/feature_extraction/setup.py @@ -3,7 +3,7 @@ import platform def configuration(parent_package='', top_path=None): - import numpy + import numpy, os from numpy.distutils.misc_util import Configuration config = Configuration('feature_extraction', parent_package, top_path) @@ -14,7 +14,7 @@ def configuration(parent_package='', top_path=None): if platform.python_implementation() != 'PyPy': config.add_extension('_hashing_fast', sources=['_hashing_fast.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_subpackage("tests") diff --git a/sklearn/linear_model/setup.py b/sklearn/linear_model/setup.py index d0c9e8c04..962340210 100644 --- a/sklearn/linear_model/setup.py +++ b/sklearn/linear_model/setup.py @@ -1,5 +1,5 @@ import os -import numpy +import numpy, os from sklearn._build_utils import gen_from_templates @@ -15,12 +15,12 @@ def configuration(parent_package='', top_path=None): config.add_extension('_cd_fast', sources=['_cd_fast.pyx'], - include_dirs=numpy.get_include(), + include_dirs=os.environ["NUMPY_INCLUDE_PATH"], libraries=libraries) config.add_extension('_sgd_fast', sources=['_sgd_fast.pyx'], - include_dirs=numpy.get_include(), + include_dirs=os.environ["NUMPY_INCLUDE_PATH"], libraries=libraries) # generate sag_fast from template @@ -29,7 +29,7 @@ def configuration(parent_package='', top_path=None): config.add_extension('_sag_fast', sources=['_sag_fast.pyx'], - include_dirs=numpy.get_include()) + include_dirs=os.environ["NUMPY_INCLUDE_PATH"]) # add other directories config.add_subpackage('tests') diff --git a/sklearn/manifold/setup.py b/sklearn/manifold/setup.py index 0db2d5d04..959a4996a 100644 --- a/sklearn/manifold/setup.py +++ b/sklearn/manifold/setup.py @@ -1,6 +1,6 @@ import os -import numpy +import numpy, os def configuration(parent_package="", top_path=None): @@ -14,13 +14,13 @@ def configuration(parent_package="", top_path=None): config.add_extension("_utils", sources=["_utils.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries, extra_compile_args=["-O3"]) config.add_extension("_barnes_hut_tsne", sources=["_barnes_hut_tsne.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries, extra_compile_args=['-O3']) diff --git a/sklearn/metrics/cluster/setup.py b/sklearn/metrics/cluster/setup.py index c39e414d9..98640b5f3 100644 --- a/sklearn/metrics/cluster/setup.py +++ b/sklearn/metrics/cluster/setup.py @@ -1,6 +1,6 @@ import os -import numpy +import numpy, os from numpy.distutils.misc_util import Configuration @@ -11,7 +11,7 @@ def configuration(parent_package="", top_path=None): libraries.append('m') config.add_extension("_expected_mutual_info_fast", sources=["_expected_mutual_info_fast.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_subpackage("tests") diff --git a/sklearn/neighbors/setup.py b/sklearn/neighbors/setup.py index 926404467..aeedcb940 100644 --- a/sklearn/neighbors/setup.py +++ b/sklearn/neighbors/setup.py @@ -2,7 +2,7 @@ import os def configuration(parent_package='', top_path=None): - import numpy + import numpy, os from numpy.distutils.misc_util import Configuration config = Configuration('neighbors', parent_package, top_path) @@ -12,28 +12,27 @@ def configuration(parent_package='', top_path=None): config.add_extension('_ball_tree', sources=['_ball_tree.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('_kd_tree', sources=['_kd_tree.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('_dist_metrics', sources=['_dist_metrics.pyx'], - include_dirs=[numpy.get_include(), - os.path.join(numpy.get_include(), - 'numpy')], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"], + os.path.join(os.environ["NUMPY_INCLUDE_PATH"], 'numpy')], libraries=libraries) config.add_extension('_typedefs', sources=['_typedefs.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension("_quad_tree", sources=["_quad_tree.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_subpackage('tests') diff --git a/sklearn/preprocessing/setup.py b/sklearn/preprocessing/setup.py index 29dae9b8f..7c059d90f 100644 --- a/sklearn/preprocessing/setup.py +++ b/sklearn/preprocessing/setup.py @@ -2,7 +2,7 @@ import os def configuration(parent_package='', top_path=None): - import numpy + import numpy, os from numpy.distutils.misc_util import Configuration config = Configuration('preprocessing', parent_package, top_path) @@ -12,7 +12,7 @@ def configuration(parent_package='', top_path=None): config.add_extension('_csr_polynomial_expansion', sources=['_csr_polynomial_expansion.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_subpackage('tests') diff --git a/sklearn/setup.py b/sklearn/setup.py index e5d7e6e26..a814bca87 100644 --- a/sklearn/setup.py +++ b/sklearn/setup.py @@ -6,7 +6,7 @@ from sklearn._build_utils import cythonize_extensions def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration - import numpy + import numpy, os libraries = [] if os.name == 'posix': @@ -69,7 +69,7 @@ def configuration(parent_package='', top_path=None): # add cython extension module for isotonic regression config.add_extension('_isotonic', sources=['_isotonic.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries, ) diff --git a/sklearn/svm/setup.py b/sklearn/svm/setup.py index dffcff8eb..d01614780 100644 --- a/sklearn/svm/setup.py +++ b/sklearn/svm/setup.py @@ -1,6 +1,6 @@ import os from os.path import join -import numpy +import numpy, os def configuration(parent_package='', top_path=None): @@ -13,7 +13,7 @@ def configuration(parent_package='', top_path=None): # newrand wrappers config.add_extension('_newrand', sources=['_newrand.pyx'], - include_dirs=[numpy.get_include(), + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"], join('src', 'newrand')], depends=[join('src', 'newrand', 'newrand.h')], language='c++', @@ -34,6 +34,7 @@ def configuration(parent_package='', top_path=None): extra_link_args=['-lstdc++'], # Use C++11 to use the random number generator fix extra_compiler_args=['-std=c++11'], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], ) libsvm_sources = ['_libsvm.pyx'] @@ -45,7 +46,7 @@ def configuration(parent_package='', top_path=None): config.add_extension('_libsvm', sources=libsvm_sources, - include_dirs=[numpy.get_include(), + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"], join('src', 'libsvm'), join('src', 'newrand')], libraries=['libsvm-skl'], @@ -82,7 +83,7 @@ def configuration(parent_package='', top_path=None): include_dirs=[join('.', 'src', 'liblinear'), join('.', 'src', 'newrand'), join('..', 'utils'), - numpy.get_include()], + os.environ["NUMPY_INCLUDE_PATH"]], depends=liblinear_depends, # extra_compile_args=['-O0 -fno-inline'], ) @@ -93,7 +94,7 @@ def configuration(parent_package='', top_path=None): libsvm_sparse_sources = ['_libsvm_sparse.pyx'] config.add_extension('_libsvm_sparse', libraries=['libsvm-skl'], sources=libsvm_sparse_sources, - include_dirs=[numpy.get_include(), + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"], join("src", "libsvm"), join("src", "newrand")], depends=[join("src", "libsvm", "svm.h"), diff --git a/sklearn/tree/setup.py b/sklearn/tree/setup.py index 079ae9d86..0308a5cf9 100644 --- a/sklearn/tree/setup.py +++ b/sklearn/tree/setup.py @@ -1,6 +1,6 @@ import os -import numpy +import numpy, os from numpy.distutils.misc_util import Configuration @@ -11,22 +11,22 @@ def configuration(parent_package="", top_path=None): libraries.append('m') config.add_extension("_tree", sources=["_tree.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries, extra_compile_args=["-O3"]) config.add_extension("_splitter", sources=["_splitter.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries, extra_compile_args=["-O3"]) config.add_extension("_criterion", sources=["_criterion.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries, extra_compile_args=["-O3"]) config.add_extension("_utils", sources=["_utils.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries, extra_compile_args=["-O3"]) diff --git a/sklearn/utils/setup.py b/sklearn/utils/setup.py index 098adeecc..d24e1b1c8 100644 --- a/sklearn/utils/setup.py +++ b/sklearn/utils/setup.py @@ -5,7 +5,7 @@ from sklearn._build_utils import gen_from_templates def configuration(parent_package='', top_path=None): - import numpy + import numpy, os from numpy.distutils.misc_util import Configuration config = Configuration('utils', parent_package, top_path) @@ -24,7 +24,7 @@ def configuration(parent_package='', top_path=None): config.add_extension('arrayfuncs', sources=['arrayfuncs.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('murmurhash', @@ -34,12 +34,12 @@ def configuration(parent_package='', top_path=None): config.add_extension('graph_shortest_path', sources=['graph_shortest_path.pyx'], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension('_fast_dict', sources=['_fast_dict.pyx'], language="c++", - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension('_openmp_helpers', @@ -53,21 +53,21 @@ def configuration(parent_package='', top_path=None): config.add_extension('_seq_dataset', sources=['_seq_dataset.pyx'], - include_dirs=[numpy.get_include()]) + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]]) config.add_extension('_weight_vector', sources=['_weight_vector.pyx'], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension("_random", sources=["_random.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_extension("_logistic_sigmoid", sources=["_logistic_sigmoid.pyx"], - include_dirs=[numpy.get_include()], + include_dirs=[os.environ["NUMPY_INCLUDE_PATH"]], libraries=libraries) config.add_subpackage('tests')