From 84c96447e2521fc0092069eac69bc308a6b2f66f Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Tue, 18 Oct 2016 16:32:05 -0400 Subject: [PATCH] Add NumPy support to the BB-based build logic. --- build/Jamfile | 41 ++++++++++++++++++++++++++++++++--- doc/Jamfile | 21 +++++++++++++----- doc/numpy/Makefile | 5 +++-- doc/numpy/_static/style.css | 6 ++--- doc/numpy/index.rst | 1 - doc/numpy/make.bat | 5 +++-- doc/numpy/reference/index.rst | 1 - doc/numpy/tutorial/index.rst | 1 - test/Jamfile | 10 +++++++++ 9 files changed, 73 insertions(+), 18 deletions(-) diff --git a/build/Jamfile b/build/Jamfile index 32bffb0f..b1ec5784 100644 --- a/build/Jamfile +++ b/build/Jamfile @@ -138,14 +138,49 @@ rule lib_boost_python ( is-py3 ? ) static:BOOST_PYTHON_STATIC_LIB on:BOOST_DEBUG_PYTHON ; +} +rule lib_boost_numpy ( is-py3 ? ) +{ + lib [ cond $(is-py3) : boost_numpy3 : boost_numpy ] + : # sources + numpy/dtype.cpp + numpy/matrix.cpp + numpy/ndarray.cpp + numpy/numpy.cpp + numpy/scalars.cpp + numpy/ufunc.cpp + : # requirements + [ cond [ python.numpy ] : /python//python_for_extensions ] + [ unless [ python.numpy ] : no ] + boost_python + on:BOOST_DEBUG_PYTHON + [ cond $(is-py3) : $(py3-version) ] + : # default build + shared + : # usage requirements + on:BOOST_DEBUG_PYTHON + ; } lib_boost_python ; -boost-install boost_python ; - +lib_boost_numpy ; if $(py3-version) { lib_boost_python yes ; - boost-install boost_python3 ; + lib_boost_numpy yes ; +} + +libraries = boost_python ; +libraries3 = boost_python3 ; +if [ python.numpy ] +{ + libraries += boost_numpy ; + libraries3 += boost_numpy3 ; +} + +boost-install $(libraries) ; +if $(py3-version) +{ + boost-install $(libraries3) ; } diff --git a/doc/Jamfile b/doc/Jamfile index a68555ad..fe69cd7b 100644 --- a/doc/Jamfile +++ b/doc/Jamfile @@ -4,10 +4,14 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +import boostbook ; +import quickbook ; +import docutils ; +import os ; + path-constant here : . ; path-constant images : html/images ; - project python/doc : requirements -boost.defaults=Boost @@ -17,9 +21,16 @@ project python/doc html:chunk.section.depth=1 ; -import boostbook ; -import quickbook ; -import docutils ; +make numpy : numpy/index.rst : @sphinx-build ; + +if [ os.name ] = NT +{ + actions sphinx-build { chdir numpy && make clean && make html} +} +else +{ + actions sphinx-build { make -C numpy clean html} +} boostbook python : python.qbk : html:$(here)/html @@ -51,5 +62,5 @@ html article : article.rst ############################################################################### alias boostdoc ; explicit boostdoc ; -alias boostrelease : python tutorial reference article ; +alias boostrelease : python tutorial reference numpy article ; explicit boostrelease ; diff --git a/doc/numpy/Makefile b/doc/numpy/Makefile index 92112a24..c23efca2 100644 --- a/doc/numpy/Makefile +++ b/doc/numpy/Makefile @@ -6,6 +6,7 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build +HTMLDIR = ../numpy/html # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 @@ -39,9 +40,9 @@ clean: -rm -rf $(BUILDDIR)/* html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(HTMLDIR) @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + @echo "Build finished. The HTML pages are in $(HTMLDIR)." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml diff --git a/doc/numpy/_static/style.css b/doc/numpy/_static/style.css index bc90e8ec..65277d0e 100644 --- a/doc/numpy/_static/style.css +++ b/doc/numpy/_static/style.css @@ -27,12 +27,12 @@ } .admonition-title { font-weight: bold;} -#table-of-contents +.toctree-wrapper { border: 1px solid #dcdcdc; padding: 1em; margin: 0 2em; } -#table-of-contents .caption, -#table-of-contents .topic-title { font-weight: bold;} +.toctree-wrapper .caption, +.toctree-wrapper .topic-title { font-weight: bold;} diff --git a/doc/numpy/index.rst b/doc/numpy/index.rst index 776b3527..280acd41 100644 --- a/doc/numpy/index.rst +++ b/doc/numpy/index.rst @@ -7,7 +7,6 @@ Welcome to the documentation of the Boost.Python NumPy extension! ================================================================= .. toctree:: - :caption: Table of Contents :name: mastertoc :maxdepth: 2 diff --git a/doc/numpy/make.bat b/doc/numpy/make.bat index fbf68af6..7dc41fc3 100644 --- a/doc/numpy/make.bat +++ b/doc/numpy/make.bat @@ -6,6 +6,7 @@ if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build +set HTMLDIR=../html/numpy set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% @@ -41,10 +42,10 @@ if "%1" == "clean" ( ) if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %HTMLDIR% if errorlevel 1 exit /b 1 echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. + echo.Build finished. The HTML pages are in %HTMLDIR%. goto end ) diff --git a/doc/numpy/reference/index.rst b/doc/numpy/reference/index.rst index 8e39f1c8..6e8f65c8 100644 --- a/doc/numpy/reference/index.rst +++ b/doc/numpy/reference/index.rst @@ -2,7 +2,6 @@ Boost.Python NumPy extension Reference ====================================== .. toctree:: - :caption: Table of Contents :name: reftoc :maxdepth: 2 diff --git a/doc/numpy/tutorial/index.rst b/doc/numpy/tutorial/index.rst index d2d3bd94..2a07b45a 100644 --- a/doc/numpy/tutorial/index.rst +++ b/doc/numpy/tutorial/index.rst @@ -2,7 +2,6 @@ Boost.Python NumPy extension Tutorial ===================================== .. toctree:: - :caption: Table of Contents :name: tuttoc :maxdepth: 2 diff --git a/test/Jamfile b/test/Jamfile index f34066c8..72d60d37 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -237,4 +237,14 @@ bpl-test crossmod_opaque [ py-compile-fail ./as_to_python_function.cpp ] [ py-compile-fail ./object_fail1.cpp ] +# --- NumPy tests --- + +[ numpy-test numpy/dtype ] +[ numpy-test numpy/ufunc ] +[ numpy-test numpy/templates ] +[ numpy-test numpy/ndarray ] +[ numpy-test numpy/indexing ] +[ numpy-test numpy/shapes ] + + ;