summaryrefslogtreecommitdiff
path: root/numpy/_build_utils/__init__.py
blob: ac4908957ad1218fff29fd0e79ac45308455c4c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Don't use the deprecated NumPy C API. Define this to a fixed version
# instead of NPY_API_VERSION in order not to break compilation for
# released SciPy versions when NumPy introduces a new deprecation. Use
# in setup.py::
#
#   config.add_extension('_name', sources=['source_fname'], **numpy_nodepr_api)
#
numpy_nodepr_api = dict(
    define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_9_API_VERSION")]
)


def import_file(folder, module_name):
    """Import a file directly, avoiding importing scipy"""
    import importlib
    import pathlib

    fname = pathlib.Path(folder) / f'{module_name}.py'
    spec = importlib.util.spec_from_file_location(module_name, str(fname))
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module