mirror of
https://github.com/boostorg/build.git
synced 2026-02-17 13:42:14 +00:00
Add support for NumPy extension.
This commit is contained in:
@@ -829,6 +829,25 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
|
||||
debug-message " DLL search path:" \"$(exec-prefix:E=<empty>)\" ;
|
||||
}
|
||||
|
||||
#
|
||||
# Discover the presence of NumPy
|
||||
#
|
||||
local full-cmd = "import sys; sys.stderr = sys.stdout; import numpy; print(numpy.get_include())" ;
|
||||
local full-cmd = $(interpreter-cmd)" -c \"$(full-cmd)\"" ;
|
||||
local result = [ SHELL $(full-cmd) : strip-eol : exit-status ] ;
|
||||
if $(result[2]) = 0
|
||||
{
|
||||
.numpy = true ;
|
||||
numpy-include = $(result[1]) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
.numpy = false ;
|
||||
debug-message "NumPy not configured. Reason:" ;
|
||||
debug-message " $(full-cmd) aborted with " ;
|
||||
debug-message " $(result[1])" ;
|
||||
}
|
||||
|
||||
#
|
||||
# End autoconfiguration sequence.
|
||||
#
|
||||
@@ -1012,6 +1031,11 @@ rule configured ( )
|
||||
return $(.configured) ;
|
||||
}
|
||||
|
||||
rule numpy ( )
|
||||
{
|
||||
return $(.numpy) ;
|
||||
}
|
||||
|
||||
|
||||
type.register PYTHON_EXTENSION : : SHARED_LIB ;
|
||||
|
||||
@@ -1268,5 +1292,20 @@ rule bpl-test ( name : sources * : requirements * )
|
||||
: $(requirements) : $(name) ] ;
|
||||
}
|
||||
|
||||
# The same as bpl-test but additionally require (and link to) boost_numpy.
|
||||
# Masked whenever NumPy is not enabled.
|
||||
rule numpy-test ( name : sources * : requirements * )
|
||||
{
|
||||
# yuk !
|
||||
if $(.numpy) = false
|
||||
{
|
||||
requirements += <build>no ;
|
||||
}
|
||||
sources ?= $(name).py $(name).cpp ;
|
||||
return [ testing.make-test run-pyd
|
||||
: $(sources) /boost/python//boost_numpy /boost/python//boost_python
|
||||
: $(requirements) : $(name) ] ;
|
||||
}
|
||||
|
||||
IMPORT $(__name__) : bpl-test : : bpl-test ;
|
||||
IMPORT $(__name__) : numpy-test : : numpy-test ;
|
||||
|
||||
Reference in New Issue
Block a user