import feature ;
import set ;
import builtin ;
+import property-set ;
# Make this module a project.
# installed in the development system's default paths.
feature.feature pythonpath : : free optional path ;
+# The best configured version of Python 2 and 3.
+py2-version = ;
+py3-version = ;
+
# Initializes the Python toolset. Note that all parameters are optional.
#
# - version -- the version of Python to use. Should be in Major.Minor format,
# Support for Python configured --with-pydebug
#
feature.feature python-debugging : off on : propagated ;
-builtin.variant debug-python : debug : <python-debugging>on ;
+variant debug-python : debug : <python-debugging>on ;
# Return a list of candidate commands to try when looking for a Python
}
extension-suffix ?= "" ;
- # Normalize and dissect any version number.
- local major-minor ;
- if $(version)
- {
- major-minor = [ split-version $(version) ] ;
- version = $(major-minor:J=.) ;
- }
-
local cmds-to-try ;
if ! $(cmd-or-prefix) || [ GLOB $(cmd-or-prefix) : * ]
{
.numpy = true ;
.numpy-include = $(result[1]) ;
- debug-message "NumPy enabled" ;
+ debug-message "NumPy enabled" ;
}
else
{
- debug-message "NumPy disabled. Reason:" ;
- debug-message " $(full-cmd) aborted with " ;
- debug-message " $(result[1])" ;
+ debug-message "NumPy disabled. Reason:" ;
+ debug-message " $(full-cmd) aborted with " ;
+ debug-message " $(result[1])" ;
}
#
# End autoconfiguration sequence.
#
+
+ # Normalize and dissect any version number.
+ local major-minor ;
+ if $(version)
+ {
+ major-minor = [ split-version $(version) ] ;
+ version = $(major-minor:J=.) ;
+ }
+
+
local target-requirements = $(condition) ;
# Add the version, if any, to the target requirements.
if ! $(version) in [ feature.values python ]
{
feature.extend python : $(version) ;
+ py$(major-minor[1])-version ?= $(version) ;
+ if $(py$(major-minor[1])-version) < $(version)
+ {
+ py$(major-minor[1])-version = $(version) ;
+ }
}
target-requirements += <python>$(version:E=default) ;
}
}
}
+ # In case we added duplicate requirements from what the user specified.
+ target-requirements = [ sequence.unique $(target-requirements) ] ;
+
# Global, but conditional, requirements to give access to the interpreter
# for general utilities, like other toolsets, that run Python scripts.
toolset.add-requirements
toolset.add-requirements <target-os>$(target-os):<python>$(version:E=default) ;
}
- # We also set a default requirement that assigns the first python configured
- # for a particular target OS as the default. This makes it so that we can
- # select a python interpreter with only knowledge of the target OS. And hence
- # can configure different Pythons based on the target OS only.
- local toolset-requirements = [ toolset.requirements ] ;
- local toolset-target-os-requirements
- = [ property.evaluate-conditionals-in-context
- [ $(toolset-requirements).raw ] : <target-os>$(target-os) ] ;
- if ! <python> in $(toolset-target-os-requirements:G)
- {
- toolset.add-requirements <target-os>$(target-os):<python>$(version:E=default) ;
- }
-
# Register the right suffix for extensions.
register-extension-suffix $(extension-suffix) : $(target-requirements) ;
: $(usage-requirements)
;
}
+
+}
+
+# Conditional rule specification that will prevent building of a target
+# if there is no matching python configuration available with the given
+# required properties.
+rule require-py ( properties * )
+{
+ local py-ext-target = [ $(.project).find python_for_extensions ] ;
+ local property-set = [ property-set.create $(properties) ] ;
+ property-set = [ $(property-set).expand ] ;
+ local py-ext-alternative = [ $(py-ext-target).select-alternatives $(property-set) ] ;
+ if ! $(py-ext-alternative)
+ {
+ return <build>no ;
+ }
}
: $(name) ] ;
}
+rule py-version ( n )
+{
+ return $(py$(n)-version) ;
+}
+
IMPORT $(__name__) : bpl-test : : bpl-test ;
IMPORT $(__name__) : numpy-test : : numpy-test ;
+IMPORT $(__name__) : py-version : : py-version ;