]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/tools/build/src/tools/python.jam
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / src / tools / python.jam
index cc13385cac9bf7530b1c184b8d232320916ed3a0..ef5e16ab1728497725b1523f512739c86c354bad 100644 (file)
@@ -34,6 +34,7 @@ import path ;
 import feature ;
 import set ;
 import builtin ;
+import property-set ;
 
 
 # Make this module a project.
@@ -60,6 +61,10 @@ lib rt ;
 # 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,
@@ -556,7 +561,7 @@ toolset.flags python.capture-output PYTHON : <python.interpreter> ;
 # 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
@@ -701,14 +706,6 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
     }
     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) : * ]
@@ -841,18 +838,28 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
     {
         .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.
@@ -861,6 +868,11 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
         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) ;
     }
@@ -916,6 +928,9 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
         }
     }
 
+    # 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
@@ -934,19 +949,6 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
         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) ;
 
@@ -1038,6 +1040,22 @@ local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
             : $(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 ;
+    }
 }
 
 
@@ -1298,5 +1316,11 @@ rule numpy-test ( name : sources * : requirements * )
         : $(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 ;