[Numpy-discussion] Hook in __init__.py to let distributors patch numpy

Michael Sarahan msarahan at gmail.com
Thu Feb 11 20:24:02 EST 2016


+1.  This seems nicer than patching __init__.py itself, in that it is much
more transparent.

Good idea.
Michael

On Thu, Feb 11, 2016 at 7:19 PM Matthew Brett <matthew.brett at gmail.com>
wrote:

> Hi,
>
> Over at https://github.com/numpy/numpy/issues/5479 we're discussing
> Windows wheels.
>
> On thing that we would like to be able to ship Windows wheels, is to
> be able to put some custom checks into numpy when you build the
> wheels.
>
> Specifically, for Windows, we're building on top of ATLAS BLAS /
> LAPACK, and we need to check that the system on which the wheel is
> running, has SSE2 instructions, otherwise we know ATLAS will crash
> (almost everybody does have SSE2 these days).
>
> The way I propose we do that, is this patch here:
>
> https://github.com/numpy/numpy/pull/7231
>
> diff --git a/numpy/__init__.py b/numpy/__init__.py
> index 0fcd509..ba3ba16 100644
> --- a/numpy/__init__.py
> +++ b/numpy/__init__.py
> @@ -190,6 +190,12 @@ def pkgload(*packages, **options):
>      test = testing.nosetester._numpy_tester().test
>      bench = testing.nosetester._numpy_tester().bench
>
> +    # Allow platform-specific build to intervene in numpy init
> +    try:
> +        from . import _distributor_init
> +    except ImportError:
> +        pass
> +
>      from . import core
>      from .core import *
>      from . import compat
>
> So, numpy __init__.py looks for a module `_distributor_init`, in which
> the distributor might have put custom code to do any checks and
> initialization needed for the particular platform.  We don't by
> default ship a `_distributor_init.py` but leave it up to packagers to
> generate this when building binaries.
>
> Does that sound like a sensible approach to y'all?
>
> Cheers,
>
> Matthew
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160212/cc5207f0/attachment.html>


More information about the NumPy-Discussion mailing list