From kovas at uw.edu Tue Jul 5 15:28:37 2016 From: kovas at uw.edu (Kovas Palunas) Date: Tue, 5 Jul 2016 12:28:37 -0700 Subject: [C++-sig] building boost with custom python 3.5 installation Message-ID: Hi all, I'm trying to build boost.python with a custom python 3.5 installation in a custom directory. So far, I've been using the following sequence of commands and have not gotten a successful build. Are there any other things I have to tell boost in order for it to find all it needs properly? I get errors along the lines of "cannot find Python.h", even though I think I'm telling boost where to find the python headers. python_root=`python3.5 -c "import sys; print(sys.prefix)?` ./bootstrap.sh --with-python-root=$python_root --prefix=/mnt/data/kpalunas/boost/boost_1_58_0 --with-python=/mnt/data/kpalunas/python3.5/bin/python3.5 ?with-libraries=python,regex,thread,serialization --with-python-version=3.5 (I add the following line to project-config.jam after running bootstrap.sh) using python : 3.5 : /mnt/data/kpalunas/python3.5/bin/python3.5m : /mnt/data/kpalunas/python3.5/include : /mnt/data/kpalunas/python3.5/lib ; ./b2 install Thanks! - Kovas -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan at seefeld.name Wed Jul 6 10:14:22 2016 From: stefan at seefeld.name (Stefan Seefeld) Date: Wed, 6 Jul 2016 10:14:22 -0400 Subject: [C++-sig] building boost with custom python 3.5 installation In-Reply-To: References: Message-ID: Hi Kovas, I suggest you send your question to the boost mailing list, where people with boost.build expertise may be able to help you. I have myself lost track of boost.build, and have therefore added a parallel build system using SCons. Using that you can build boost.python as a stand-alone library, against a pre-installed boost. With that you specify the python version to use via `scons config --python=` from which all other flags will be deduced. This is right now available in the 'develop' branch in https://github.com/boostorg/python, and should be merged into master in time for the next release. HTH, Stefan -- ...ich hab' noch einen Koffer in Berlin... From eric.frederich at siemens.com Wed Jul 6 10:23:05 2016 From: eric.frederich at siemens.com (Frederich, Eric) Date: Wed, 6 Jul 2016 14:23:05 +0000 Subject: [C++-sig] building boost with custom python 3.5 installation In-Reply-To: References: Message-ID: Not sure if it is the right thing to do, but when I have a custom build of Python 3.5 I have to go into the installation dir and create a symlink in the include directory from python3.5m to python3.5 -----Original Message----- From: Cplusplus-sig [mailto:cplusplus-sig-bounces+eric.frederich=siemens.com at python.org] On Behalf Of Stefan Seefeld Sent: Wednesday, July 06, 2016 10:14 AM To: cplusplus-sig at python.org Subject: Re: [C++-sig] building boost with custom python 3.5 installation Hi Kovas, I suggest you send your question to the boost mailing list, where people with boost.build expertise may be able to help you. I have myself lost track of boost.build, and have therefore added a parallel build system using SCons. Using that you can build boost.python as a stand-alone library, against a pre-installed boost. With that you specify the python version to use via `scons config --python=` from which all other flags will be deduced. This is right now available in the 'develop' branch in https://github.com/boostorg/python, and should be merged into master in time for the next release. HTH, Stefan -- ...ich hab' noch einen Koffer in Berlin... _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig at python.org https://mail.python.org/mailman/listinfo/cplusplus-sig This message and any attachments are solely for the use of intended recipients. The information contained herein may include trade secrets, protected health or personal information, privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you are not an intended recipient, you are hereby notified that you received this email in error, and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system. Thank you for your cooperation From herron at ELLINGTON.com Fri Jul 8 15:58:09 2016 From: herron at ELLINGTON.com (Liam Herron) Date: Fri, 8 Jul 2016 19:58:09 +0000 Subject: [C++-sig] Issue Overriding C++ virtual methods in boost python for use in other C++ functions Message-ID: <96426055F003C542B3FB8A0928736DF9023A6B756E@ex0.ELLINGTON.com> I followed the test examples that I found on the web, and I am able to replicate the examples. My issue occurs when I: 1) Write a C++ base class 2) Wrap this C++ base class in C++ 3) Inherit from this wrapped C++ class in python 4) Then try to use this python inherited class as an argument into a different C++ function expecting the C++ base class I created in step 1. I have attached the C++ and py code. My C++ code: #include #include #include #include #include #include using namespace boost::python; namespace // unnamed { struct Base { virtual ~Base() {}; virtual int f() const = 0; }; struct BaseWrap : Base, wrapper { virtual ~BaseWrap() {} int f() const { return this->get_override("f")(); } }; void functionWithBaseArgument(Base & baseObj) { std::cout << "You have successfully called 'functionWithBaseArgument'" << std::endl; std::cout << "Value: " << baseObj.f() << std::endl; } class classWithBaseMember { public: classWithBaseMember (const Base & baseObj) : baseObj_(baseObj) {} void test() const { std::cout << "You have successfully called 'classWithBaseMember::test': " << std::endl; int d = baseObj_.f(); std::cout << "Value: " << d << std::endl; } private: const Base & baseObj_; }; class DoubleVector // empty stub class { public: DoubleVector() {} DoubleVector(int s, double v) {} ~DoubleVector() {} }; class DoubleMatrix // empty stub class { public: DoubleMatrix() {} DoubleMatrix(int nr, int nc, double v) {} ~DoubleMatrix() {} }; class MathSmoothFunction { public: MathSmoothFunction() {} virtual ~MathSmoothFunction() {} virtual double value(const DoubleVector& currentPoint) const = 0; virtual DoubleVector gradient(const DoubleVector& currentPoint) const = 0; virtual DoubleMatrix hessian(const DoubleVector& currentPoint) const { return DoubleMatrix(); } private: }; class PyWrapSmoothFunction : public MathSmoothFunction, public wrapper { public: PyWrapSmoothFunction() {} virtual ~PyWrapSmoothFunction() {} virtual double value(const DoubleVector& currentPoint) const { return call(this->get_override("value").ptr(),currentPoint); } virtual DoubleVector gradient(const DoubleVector& currentPoint) const { return call(this->get_override("gradient").ptr(),currentPoint); } virtual DoubleMatrix hessian(const DoubleVector& currentPoint) const { return call(this->get_override("hessian").ptr(),currentPoint); } private: }; class classWithBaseMember2 { public: classWithBaseMember2 (const MathSmoothFunction& baseObj) : baseObj_(baseObj) {} void test() { std::cout << "You have successfully called 'classWithBaseMember2::test': " << std::endl; //std::cout << "Value: " << value( DoubleVector(1,-5.0) ) << std::endl; } private: const MathSmoothFunction& baseObj_; }; } // end namespace unnamed void init_pyivm() { class_ ("DoubleVector") .def(init<>()) .def(init()) ; class_ ("DoubleMatrix") .def(init<>()) .def(init()) ; class_ ("Base", "Base") .def("f", pure_virtual(&Base::f)) ; class_ ("classWithBaseMember", "classWithBaseMember", init() ) .def("test", &classWithBaseMember::test) ; def("functionWithBaseArgument", functionWithBaseArgument); class_ ("PyWrapSmoothFunction", "PyWrapSmoothFunction") .def("value", pure_virtual(&MathSmoothFunction::value) ) .def("gradient", pure_virtual(&MathSmoothFunction::gradient) ) .def("hessian", pure_virtual(&MathSmoothFunction::hessian) ) ; class_ ("classWithBaseMember2", "classWithBaseMember2", init() ) .def("test", &classWithBaseMember2::test) ; } BOOST_PYTHON_MODULE(_testPyInheritVM) { init_pyivm(); } ------------------------------------------------------------------------------------------- My python code is: ------------------------------------------------------------------------------------------- #!/usr/bin/python # # import os, sys import math from _testPyInheritVM import * ################################################## # THIS WORKS ################################################## class Dummy: def __init__(self): pass base = Base() dummy = Dummy() class Derived(Base): def f(self): return 42 derived = Derived() derived.f() functionWithBaseArgument(derived) cwbm = classWithBaseMember(derived) cwbm.test() ################################################## # THIS DOESN'T WORK ################################################## class MyPySmoothFunction(PyWrapSmoothFunction): def __init__(self): pass def value(self, point): return 0.0 def gradient(self, point): return DoubleVector() def hessian(self, point): return DoubleMatrix() myFn = MyPySmoothFunction() myClassHasAPyWrapSmoothFn = classWithBaseMember2(myFn) ------------------------------------------------------------------------------------------- The error I get when I run this is: Traceback (most recent call last): File "testPyInheritVM.py", line 49, in myClassHasAPyWrapSmoothFn = classWithBaseMember2(myFn) Boost.Python.ArgumentError: Python argument types in classWithBaseMember2.__init__(classWithBaseMember2, MyPySmoothFunction) did not match C++ signature: __init__(_object*, (anonymous namespace)::MathSmoothFunction) ------------------------------------------------------------------------------------------- I have tried various things but can't seem to get this to work. Any help would be hugely appreciated. --Liam ============================================================================================= Email transmissions can not be guaranteed to be secure or error-free, as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of email transmission. In addition, the information contained in this email message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution,or copying of this communication, disclosure of the parties to it, or any action taken or omitted to be taken in reliance on it, is strictly prohibited, and may be unlawful. If you are not the intended recipient please delete this email message. ============================================================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: _testPyInheritVM.cpp URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: testPyInheritVM.py Type: application/octet-stream Size: 917 bytes Desc: testPyInheritVM.py URL: From stefan at seefeld.name Fri Jul 8 16:33:39 2016 From: stefan at seefeld.name (Stefan Seefeld) Date: Fri, 8 Jul 2016 16:33:39 -0400 Subject: [C++-sig] Issue Overriding C++ virtual methods in boost python for use in other C++ functions In-Reply-To: <96426055F003C542B3FB8A0928736DF9023A6B756E@ex0.ELLINGTON.com> References: <96426055F003C542B3FB8A0928736DF9023A6B756E@ex0.ELLINGTON.com> Message-ID: <7bd4e257-dbd1-adaf-9894-ebd6795e1620@seefeld.name> Hi Liam, On 08.07.2016 15:58, Liam Herron wrote: > > ################################################## > > # THIS DOESN'T WORK > > ################################################## > > > > class MyPySmoothFunction(PyWrapSmoothFunction): > > def __init__(self): > > pass > You need to initialize the base class. For example: def __init__(self): super(MyPySmoothFunction, self).__init__() Stefan -- ...ich hab' noch einen Koffer in Berlin... From stephen.j.wang at live.com Fri Jul 15 16:18:23 2016 From: stephen.j.wang at live.com (Stephen Wang) Date: Fri, 15 Jul 2016 16:18:23 -0400 Subject: [C++-sig] Testing build of Boost.Python Message-ID: Hello all, I have built the Boost.Python libraries with the following options & configs: bjam ^ variant=debug,release ^ link=static,shared ^ runtime-link=shared --debug-configuration ^ architecture=x86 address-model=64 ^ runtime-debugging=on,off ^ --with-python I am testing the build. When I execute C:\Users\swang10\boost_1_61_0\libs\python\example\quickstart>bjam test --verbose-test I get a fatal link error that python35_d.lib cannot be found. Any ideas of a workaround? Best, Stephen J. Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan at seefeld.name Sat Jul 16 12:36:46 2016 From: stefan at seefeld.name (Stefan Seefeld) Date: Sat, 16 Jul 2016 12:36:46 -0400 Subject: [C++-sig] Testing build of Boost.Python In-Reply-To: References: Message-ID: <111ba155-d04e-1bba-f164-1437a0580786@seefeld.name> Hi Stephen, On 15.07.2016 16:18, Stephen Wang wrote: > Hello all, > > I have built the Boost.Python libraries with the following options & > configs: > > *bjam ^ > variant=debug,release ^ > link=static,shared ^ > runtime-link=shared --debug-configuration ^ > architecture=x86 address-model=64 ^ > runtime-debugging=on,off ^ > --with-python* > > I am testing the build. When I execute > * > C:\Users\swang10\boost_1_61_0\libs\python\example\quickstart>bjam test > --verbose-test* > > I get a fatal link error that python35_d.lib cannot be found. Any > ideas of a workaround? It sounds like you are missing a debug version of the Python library. http://stackoverflow.com/questions/35250175/i-cannot-find-python35-d-lib might be of help. Best, Stefan -- ...ich hab' noch einen Koffer in Berlin...