8000 MRG: allow distributors to run custom init by matthew-brett · Pull Request #7231 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MRG: allow distributors to run custom init #7231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/release/1.12.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
============
Expand Down
3 changes: 3 additions & 0 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions numpy/_distributor_init.py
Original file line number Diff line number Diff line change
@@ -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.
"""
0