diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-25 21:27:56 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-25 21:27:56 -0400 |
commit | 9dadaebfeb461ba795124281018d0f7eac200cf4 (patch) | |
tree | 941243868b1dcacd68cbd52a2f96e40bf70a5d3b /src/pyinterp.h | |
parent | f35bc939c96c3a3bf09c5881d638b5ba60449c03 (diff) | |
parent | e696bfd913a10edd19f9e35eb1aee2c97b11e7f6 (diff) | |
download | fork-ledger-9dadaebfeb461ba795124281018d0f7eac200cf4.tar.gz fork-ledger-9dadaebfeb461ba795124281018d0f7eac200cf4.tar.bz2 fork-ledger-9dadaebfeb461ba795124281018d0f7eac200cf4.zip |
Merge branch 'next'
Diffstat (limited to 'src/pyinterp.h')
-rw-r--r-- | src/pyinterp.h | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/pyinterp.h b/src/pyinterp.h index dd9ca64c..4943eb2f 100644 --- a/src/pyinterp.h +++ b/src/pyinterp.h @@ -105,6 +105,7 @@ public: virtual expr_t::ptr_op_t lookup(const string& name); +#if BOOST_VERSION >= 103700 OPTION_(python_interpreter_t, import_, DO_(scope) { interactive_t args(scope, "s"); @@ -114,23 +115,31 @@ public: python::object sys_dict = module_sys.attr("__dict__"); python::list paths(sys_dict["path"]); -#if BOOST_VERSION >= 103700 paths.insert(0, file.parent_path().string()); -#else - paths.insert(0, file.branch_path().string()); -#endif sys_dict["path"] = paths; -#if BOOST_VERSION >= 103700 string name = file.filename(); if (contains(name, ".py")) parent->import(file.stem()); else parent->import(name); -#else + }); +#else // BOOST_VERSION >= 103700 + OPTION_(python_interpreter_t, import_, DO_(scope) { + interactive_t args(scope, "s"); + + path file(args.get<string>(0)); + + python::object module_sys = parent->import("sys"); + python::object sys_dict = module_sys.attr("__dict__"); + + python::list paths(sys_dict["path"]); + paths.insert(0, file.branch_path().string()); + sys_dict["path"] = paths; + parent->import(file.leaf()); -#endif }); +#endif // BOOST_VERSION >= 103700 }; extern shared_ptr<python_interpreter_t> python_session; |