Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55359 - sandbox-branches/bhy/py3k/tools/build/v2/tools
From: divinekid_at_[hidden]
Date: 2009-08-02 02:11:03


Author: bhy
Date: 2009-08-02 02:11:02 EDT (Sun, 02 Aug 2009)
New Revision: 55359
URL: http://svn.boost.org/trac/boost/changeset/55359

Log:
add 2to3 support for bpl-test
Text files modified:
   sandbox-branches/bhy/py3k/tools/build/v2/tools/python.jam | 43 +++++++++++++++++++++++++++++++++++++--
   1 files changed, 40 insertions(+), 3 deletions(-)

Modified: sandbox-branches/bhy/py3k/tools/build/v2/tools/python.jam
==============================================================================
--- sandbox-branches/bhy/py3k/tools/build/v2/tools/python.jam (original)
+++ sandbox-branches/bhy/py3k/tools/build/v2/tools/python.jam 2009-08-02 02:11:02 EDT (Sun, 02 Aug 2009)
@@ -855,7 +855,7 @@
         }
         target-requirements += <python>$(version:E=default) ;
     }
-
+
     target-requirements += <target-os>$(target-os) ;
 
     # See if we can find a framework directory on darwin.
@@ -1064,6 +1064,32 @@
 
 IMPORT python : python-extension : : python-extension ;
 
+rule is-py3
+{
+ #TODO(bhy) this may not the correct way to get Python verison,
+ # since it seems the 'python' feature can have other values. Should be checked with volodya
+ local version = [ feature.values python ] ;
+ if $(version) >= 3.0
+ {
+ return true ;
+ }
+}
+
+rule py2to3
+{
+ common.copy $(>) $(<) ;
+ if [ is-py3 ]
+ {
+ 2to3 $(<) ;
+ }
+}
+
+actions 2to3
+{
+ 2to3 -wn "$(<)"
+ 2to3 -dwn "$(<)"
+}
+
 
 # Support for testing.
 type.register PY : py ;
@@ -1085,6 +1111,16 @@
     {
         local python ;
         local other-pythons ;
+
+ # Make new target that converting Python source by 2to3 when running with Python 3.
+ local rule make-2to3-source ( source )
+ {
+ local a = [ new action $(source) : python.py2to3 : $(property-set) ] ;
+ local t = [ utility.basename [ $(s).name ] ] ;
+ local p = [ new file-target $(t) : PY : $(project) : $(a) ] ;
+ return $(p) ;
+ }
+
         for local s in $(sources)
         {
             if [ $(s).type ] = PY
@@ -1092,12 +1128,13 @@
                 if ! $(python)
                 {
                     # First Python source ends up on command line.
- python = $(s) ;
+ python = [ make-2to3-source $(s) ] ;
+
                 }
                 else
                 {
                     # Other Python sources become dependencies.
- other-pythons += $(s) ;
+ other-pythons += [ make-2to3-source $(s) ] ;
                 }
             }
         }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk