|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62539 - in sandbox/python_extensions: . libs/python/src libs/python/test
From: talljimbo_at_[hidden]
Date: 2010-06-07 21:44:20
Author: jbosch
Date: 2010-06-07 21:44:19 EDT (Mon, 07 Jun 2010)
New Revision: 62539
URL: http://svn.boost.org/trac/boost/changeset/62539
Log:
boost.python extensions - build system separates debug and standard builds
Added:
sandbox/python_extensions/libs/python/test/const_aware_mod.cpp
- copied, changed from r62516, /sandbox/python_extensions/libs/python/test/const_aware.cpp
Removed:
sandbox/python_extensions/libs/python/test/const_aware.cpp
Properties modified:
sandbox/python_extensions/ (props changed)
sandbox/python_extensions/libs/python/src/ (props changed)
sandbox/python_extensions/libs/python/test/ (props changed)
Text files modified:
sandbox/python_extensions/SConstruct | 14 ++++++++++----
sandbox/python_extensions/libs/python/test/SConscript | 2 +-
sandbox/python_extensions/libs/python/test/const_aware.py | 18 +++++++++---------
sandbox/python_extensions/libs/python/test/const_aware_mod.cpp | 2 +-
4 files changed, 21 insertions(+), 15 deletions(-)
Modified: sandbox/python_extensions/SConstruct
==============================================================================
--- sandbox/python_extensions/SConstruct (original)
+++ sandbox/python_extensions/SConstruct 2010-06-07 21:44:19 EDT (Mon, 07 Jun 2010)
@@ -4,13 +4,19 @@
bp_extensions_env.SetupPackages(["boost.python"])
bp_extensions_env.Append(CPPPATH = "#")
+if ARGUMENTS.get("debug", 0):
+ build_dir = "build.debug"
+else:
+ build_dir = "build"
+Export("build_dir")
+
Export("bp_extensions_env")
-lib = SConscript("libs/python/src/SConscript")
-libpath = os.path.abspath("libs/python/src")
+lib = SConscript("libs/python/src/SConscript", variant_dir="%s/python/src" % build_dir, duplicate=False)
+libpath = os.path.abspath("%s/python/src" % build_dir)
if os.environ.has_key("LD_LIBRARY_PATH"):
bp_extensions_env["ENV"]["LD_LIBRARY_PATH"] = "%s:%s" % (libpath, os.environ["LD_LIBRARY_PATH"])
else:
bp_extensions_env["ENV"]["LD_LIBRARY_PATH"] = libpath
-bp_extensions_env.Append(LIBPATH="#libs/python/src")
+bp_extensions_env.Append(LIBPATH=libpath)
-SConscript("libs/python/test/SConscript")
+SConscript("libs/python/test/SConscript", variant_dir="%s/python/test" % build_dir)
Modified: sandbox/python_extensions/libs/python/test/SConscript
==============================================================================
--- sandbox/python_extensions/libs/python/test/SConscript (original)
+++ sandbox/python_extensions/libs/python/test/SConscript 2010-06-07 21:44:19 EDT (Mon, 07 Jun 2010)
@@ -1,7 +1,7 @@
Import("bp_extensions_env")
test_mod = bp_extensions_env.SharedLibrary("test_mod", "test_mod.cpp", SHLIBPREFIX="")
-const_aware_mod = bp_extensions_env.SharedLibrary("const_aware", "const_aware.cpp", SHLIBPREFIX="",
+const_aware_mod = bp_extensions_env.SharedLibrary("const_aware_mod", "const_aware_mod.cpp", SHLIBPREFIX="",
LIBS="boost_python_extensions")
test = (
bp_extensions_env.PythonUnitTest("test_script.py", test_mod)
Deleted: sandbox/python_extensions/libs/python/test/const_aware.cpp
==============================================================================
--- sandbox/python_extensions/libs/python/test/const_aware.cpp 2010-06-07 21:44:19 EDT (Mon, 07 Jun 2010)
+++ (empty file)
@@ -1,79 +0,0 @@
-#include <boost/python.hpp>
-#include <boost/python/const_aware.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace bp = boost::python;
-
-class Example {
-public:
- Example() : value(0) {}
-
- Example(int v) : value(v) {}
-
- std::size_t get_address() const { return std::size_t(this); }
-
- bool non_const_method() { return true; }
- bool const_method() const { return true; }
-
- int value;
-
- int get_value() const { return value; }
- void set_value(int v) { value = v; }
-};
-
-class Owner {
-public:
- Example by_value() const { return *_example; }
- Example const by_const_value() const { return *_example; }
- Example & by_reference() { return *_example; }
- Example const & by_const_reference() const { return *_example; }
- boost::shared_ptr<Example> by_shared_ptr() { return _example; }
- boost::shared_ptr<Example const> by_const_shared_ptr() const { return _example; }
-
- bool accept_by_value(Example x) { return true; }
- bool accept_by_const_value(Example const x) { return true; }
- bool accept_by_reference(Example & x) { return true; }
- bool accept_by_const_reference(Example const & x) { return true; }
- bool accept_by_shared_ptr(boost::shared_ptr<Example> const & x) { return true; }
- bool accept_by_const_shared_ptr(boost::shared_ptr<Example const> const & x) { return true; }
-
- explicit Owner() : _example(new Example()) {}
-private:
- boost::shared_ptr<Example> _example;
-};
-
-static void export_module() {
-
- bp::const_aware::exposer<Example>("Example", bp::init<Example const &>())
- .add_property("address", &Example::get_address)
- .def("non_const_method", &Example::non_const_method)
- .def("const_method", &Example::const_method)
- .add_property("value_prop", &Example::get_value, &Example::set_value)
- .def_readonly("value_ro", &Example::value)
- .def_readwrite("value_rw", &Example::value)
- .enable_shared_ptr()
- .enable_pickling()
- .main_class().def(bp::init<int>((bp::arg("value")=0)))
- ;
-
- bp::class_<Owner>("Owner")
- .def("by_value", &Owner::by_value)
- .def("by_const_value", &Owner::by_const_value, bp::as_const<>())
- .def("by_reference", &Owner::by_reference, bp::return_internal_reference<>())
- .def("by_const_reference", &Owner::by_const_reference,
- bp::as_const< bp::return_internal_reference<> >())
- .def("by_shared_ptr", &Owner::by_shared_ptr)
- .def("by_const_shared_ptr", &Owner::by_const_shared_ptr)
- .def("accept_by_value", &Owner::accept_by_value)
- .def("accept_by_const_value", &Owner::accept_by_const_value)
- .def("accept_by_reference", &Owner::accept_by_reference)
- .def("accept_by_const_reference", &Owner::accept_by_const_reference)
- .def("accept_by_shared_ptr", &Owner::accept_by_shared_ptr)
- .def("accept_by_const_shared_ptr", &Owner::accept_by_const_shared_ptr)
- ;
-
-}
-
-BOOST_PYTHON_MODULE(const_aware) {
- export_module();
-}
Modified: sandbox/python_extensions/libs/python/test/const_aware.py
==============================================================================
--- sandbox/python_extensions/libs/python/test/const_aware.py (original)
+++ sandbox/python_extensions/libs/python/test/const_aware.py 2010-06-07 21:44:19 EDT (Mon, 07 Jun 2010)
@@ -1,16 +1,16 @@
-import const_aware
+import const_aware_mod
import unittest
import pickle
-const_aware.Example.__reduce__ = lambda self: (const_aware.Example, (self.value_prop,))
+const_aware_mod.Example.__reduce__ = lambda self: (const_aware_mod.Example, (self.value_prop,))
class TestConstAware(unittest.TestCase):
def setUp(self):
- self.owner = const_aware.Owner()
+ self.owner = const_aware_mod.Owner()
def checkNonConst(self, x):
- self.assertEqual(type(x), const_aware.Example)
+ self.assertEqual(type(x), const_aware_mod.Example)
self.assert_(x.const_method())
self.assert_(x.non_const_method())
self.assert_(self.owner.accept_by_value(x))
@@ -36,7 +36,7 @@
self.assertRaises(AttributeError, set_value_ro, 1)
def checkConst(self, x):
- self.assertEqual(type(x), const_aware.Example.__const_proxy__)
+ self.assertEqual(type(x), const_aware_mod.Example.__const_proxy__)
self.assert_(x.const_method())
self.assertFalse(hasattr(x,"non_const_method"))
self.assert_(self.owner.accept_by_value(x))
@@ -81,11 +81,11 @@
def testConstruction(self):
original = self.owner.by_value()
- proxy = const_aware.Example.__const_proxy__(original)
+ proxy = const_aware_mod.Example.__const_proxy__(original)
self.assertEqual(original.address, original.address)
self.checkConst(proxy)
- original_copy = const_aware.Example(original)
- proxy_copy = const_aware.Example(proxy)
+ original_copy = const_aware_mod.Example(original)
+ proxy_copy = const_aware_mod.Example(proxy)
self.assertNotEqual(original.address, original_copy.address)
self.assertNotEqual(proxy.address, proxy_copy.address)
self.checkNonConst(original_copy)
@@ -97,7 +97,7 @@
original_pickled = pickle.dumps(original)
original_loaded = pickle.loads(original_pickled)
self.assertEqual(original_loaded.value_prop, original.value_prop)
- proxy = const_aware.Example.__const_proxy__(original)
+ proxy = const_aware_mod.Example.__const_proxy__(original)
proxy_pickled = pickle.dumps(proxy)
proxy_loaded = pickle.loads(proxy_pickled)
self.assertEqual(proxy_loaded.value_prop, proxy.value_prop)
Copied: sandbox/python_extensions/libs/python/test/const_aware_mod.cpp (from r62516, /sandbox/python_extensions/libs/python/test/const_aware.cpp)
==============================================================================
--- /sandbox/python_extensions/libs/python/test/const_aware.cpp (original)
+++ sandbox/python_extensions/libs/python/test/const_aware_mod.cpp 2010-06-07 21:44:19 EDT (Mon, 07 Jun 2010)
@@ -74,6 +74,6 @@
}
-BOOST_PYTHON_MODULE(const_aware) {
+BOOST_PYTHON_MODULE(const_aware_mod) {
export_module();
}
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