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

Modified Files:
        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.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Jamfile.v2  1 Mar 2007 15:17:29 -0000       1.23
+++ Jamfile.v2  5 Mar 2007 18:51:04 -0000       1.24
@@ -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
  
@@ -151,7 +151,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
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- import_.cpp 1 Mar 2007 15:17:29 -0000       1.1
+++ import_.cpp 5 Mar 2007 18:51:04 -0000       1.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