From 9d6cdc1946073dd6fc5195a18f77785800d71db2 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Thu, 11 Feb 2016 13:24:41 -0800 Subject: [PATCH 1/2] ENH: platform-specific install hook to change init Give hook to allow platform-specific installs to modify the initialization of numpy. Particular use-case is to allow check for SSE2 on Windows when shipping with ATLAS wheel. --- numpy/__init__.py | 3 +++ numpy/_distributor_init.py | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 numpy/_distributor_init.py diff --git a/numpy/__init__.py b/numpy/__init__.py index 0fcd5097d2d1..b05157c4a017 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -190,6 +190,9 @@ def pkgload(*packages, **options): test = testing.nosetester._numpy_tester().test bench = testing.nosetester._numpy_tester().bench + # Allow distributors to run custom init code + from . import _distributor_init + from . import core from .core import * from . import compat diff --git a/numpy/_distributor_init.py b/numpy/_distributor_init.py new file mode 100644 index 000000000000..d893ba37719b --- /dev/null +++ b/numpy/_distributor_init.py @@ -0,0 +1,10 @@ +""" Distributor init file + +Distributors: you can add custom code here to support particular distributions +of numpy. + +For example, this is a good place to put any checks for hardware requirements. + +The numpy standard source distribution will not put code in this file, so you +can safely replace this file with your own version. +""" From 2932da9766ebb253d8a83b6633137c8b91c2b5e3 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Sat, 13 Feb 2016 15:15:59 -0800 Subject: [PATCH 2/2] DOC: description of _distribution_init for release Add description of ``numpy/_distribution_init.py`` file and init hook to release notes for 1.12.0. --- doc/release/1.12.0-notes.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/release/1.12.0-notes.rst b/doc/release/1.12.0-notes.rst index 62c056c55315..7544273704d7 100644 --- a/doc/release/1.12.0-notes.rst +++ b/doc/release/1.12.0-notes.rst @@ -106,6 +106,18 @@ Building against the BLAS implementation provided by the BLIS library is now supported. See the ``[blis]`` section in ``site.cfg.example`` (in the root of the numpy repo or source distribution). +Hook in ``numpy/__init__.py`` to run distribution-specific checks +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Binary distributions of numpy may need to run specific hardware checks or load +specific libraries during numpy initialization. For example, if we are +distributing numpy with a BLAS library that requires SSE2 instructions, we +would like to check the machine on which numpy is running does have SSE2 in +order to give an informative error. + +Add a hook in ``numpy/__init__.py`` to import a ``numpy/_distributor_init.py`` +file that will remain empty (bar a docstring) in the standard numpy source, +but that can be overwritten by people making binary distributions of numpy. Improvements ============