Skip to content

Commit

Permalink
Add NumPy support to the BB-based build logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseefeld committed Oct 18, 2016
1 parent dc8d68d commit 84c9644
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 18 deletions.
41 changes: 38 additions & 3 deletions build/Jamfile
Expand Up @@ -138,14 +138,49 @@ rule lib_boost_python ( is-py3 ? )
<link>static:<define>BOOST_PYTHON_STATIC_LIB
<python-debugging>on:<define>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 ] : <library>/python//python_for_extensions ]
[ unless [ python.numpy ] : <build>no ]
<library>boost_python
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
[ cond $(is-py3) : <python>$(py3-version) ]
: # default build
<link>shared
: # usage requirements
<python-debugging>on:<define>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) ;
}
21 changes: 16 additions & 5 deletions doc/Jamfile
Expand Up @@ -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
-<xsl:param>boost.defaults=Boost
Expand All @@ -17,9 +21,16 @@ project python/doc
<format>html:<xsl:param>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}

This comment has been minimized.

Copy link
@grafikrobot

grafikrobot Oct 19, 2016

Member

You are assuming the CWD is root/libs/python/doc. It isn't when building the general docs. Which is why in my example I had a more complicated action. Try running: cd boost-root ; b2 libs/python/doc to replicate. Same applies to the non-NT case below.

This comment has been minimized.

Copy link
@grafikrobot

grafikrobot Oct 19, 2016

Member

You also need to have the action create a real file. Relying on directories is not reliable as directory timestamps change for various reasons. And b2 does not track timestamps for dirs.

This comment has been minimized.

Copy link
@stefanseefeld

stefanseefeld Oct 19, 2016

Author Member

This is fixed in ac39d2e. I'm not sure what to put as target (file) as I don't want to refer to anything in the build tree (where I'm not building anything). I suppose as I'm doing real development with SCons, not Boost.Build, that this is less of an issue given that BB is only used to do integrated builds.

}
else
{
actions sphinx-build { make -C numpy clean html}
}

boostbook python : python.qbk
: <format>html:<name>$(here)/html
Expand Down Expand Up @@ -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 ;
5 changes: 3 additions & 2 deletions doc/numpy/Makefile
Expand Up @@ -6,6 +6,7 @@ SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
HTMLDIR = ../numpy/html

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc/numpy/_static/style.css
Expand Up @@ -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;}

1 change: 0 additions & 1 deletion doc/numpy/index.rst
Expand Up @@ -7,7 +7,6 @@ Welcome to the documentation of the Boost.Python NumPy extension!
=================================================================

.. toctree::
:caption: Table of Contents
:name: mastertoc
:maxdepth: 2

Expand Down
5 changes: 3 additions & 2 deletions doc/numpy/make.bat
Expand Up @@ -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%
Expand Down Expand Up @@ -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
)

Expand Down
1 change: 0 additions & 1 deletion doc/numpy/reference/index.rst
Expand Up @@ -2,7 +2,6 @@ Boost.Python NumPy extension Reference
======================================

.. toctree::
:caption: Table of Contents
:name: reftoc
:maxdepth: 2

Expand Down
1 change: 0 additions & 1 deletion doc/numpy/tutorial/index.rst
Expand Up @@ -2,7 +2,6 @@ Boost.Python NumPy extension Tutorial
=====================================

.. toctree::
:caption: Table of Contents
:name: tuttoc
:maxdepth: 2

Expand Down
10 changes: 10 additions & 0 deletions test/Jamfile
Expand Up @@ -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 ]


;

0 comments on commit 84c9644

Please sign in to comment.