Update of /cvsroot/boost/boost/libs/python/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11282/libs/python/test

Modified Files:
      Tag: RC_1_34_0
        Jamfile.v2 import_.cpp 
Log Message:
Fix import_ failure.

Index: Jamfile.v2
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/test/Jamfile.v2,v
retrieving revision 1.13.2.10
retrieving revision 1.13.2.11
diff -u -d -r1.13.2.10 -r1.13.2.11
--- Jamfile.v2  1 Mar 2007 18:31:10 -0000       1.13.2.10
+++ Jamfile.v2  5 Mar 2007 18:44:45 -0000       1.13.2.11
@@ -5,11 +5,11 @@
 use-project /boost/python : ../build ;
 project /boost/python/test ;
 
-rule py-run ( sources * )
+rule py-run ( sources * : input-file ? )
 {
     return [ run $(sources) /boost/python//boost_python /python//python
       : # args
-      : # input files
+      : $(input-file)
       : #requirements
         <define>BOOST_PYTHON_SUPPRESS_REGISTRY_INITIALIZATION
  
@@ -150,7 +150,7 @@
     /boost/python//boost_python ]
 [ bpl-test  
     map_indexing_suite : map_indexing_suite.py map_indexing_suite_ext ]
-[ py-run import_.cpp ]
+[ py-run import_.cpp : import_.py ]
 
 # if $(TEST_BIENSTMAN_NON_BUGS)
 # {

Index: import_.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/python/test/import_.cpp,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- import_.cpp 1 Mar 2007 18:31:10 -0000       1.1.2.1
+++ import_.cpp 5 Mar 2007 18:44:45 -0000       1.1.2.2
@@ -7,7 +7,7 @@
 
 #include <boost/detail/lightweight_test.hpp>
 #include <iostream>
-
+#include <sstream>
 
 namespace bpl = boost::python;
 
@@ -22,9 +22,23 @@
 
 int main(int argc, char **argv)
 {
+  BOOST_TEST(argc == 2);
+
   // Initialize the interpreter
   Py_Initialize();
+  
+  // Retrieve the main module
+  bpl::object main = bpl::import("__main__");
+  
+  // Retrieve the main module's namespace
+  bpl::object global(main.attr("__dict__"));
 
+  // Inject search path for import_ module
+  std::ostringstream script;
+  script << "import sys, os.path\n"
+         << "path = os.path.dirname('" << argv[1] << "')\n"
+         << "sys.path.insert(0, path)\n";
+  bpl::object result = bpl::exec(bpl::str(script.str()), global, global);
   if (bpl::handle_exception(import_test))
   {
     if (PyErr_Occurred())


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to