From stefanrin at gmail.com Tue Mar 5 15:03:30 2019 From: stefanrin at gmail.com (Stefan Ring) Date: Tue, 5 Mar 2019 21:03:30 +0100 Subject: [C++-sig] Calling python function repr from C++ using boost.python (possible?) In-Reply-To: <449WC52LTNzndTf@mail.python.org> References: <449WC52LTNzndTf@mail.python.org> Message-ID: On Sat, Mar 2, 2019 at 6:12 PM Jones, Torrin A (US) wrote: > > Is it possible to call repr from C++ on a C++ object that can be converted to python? Let me explain. > > > > I have an enum that I converted to python using boost::python::enum_(). That class already provides a good repr() to python (thanks to the boost::python developers for that). However that enum is used as a type on a member in another C++ class that I have where boost::python does not provide a good repr(). So I?m trying to provide one and thought, it sure would be nice if I could just call repr() on the member. I assume I have to convert the value on that member to python first, some kind of way then call repr? Is that possible? Or is there a better way? > > > > Example: > > > > Typedef enum > > { > > V1 = 0, > > V2 = 5, > > V3 = 6 > > } values; > > > > Class ValueExample > > { > > Public: > > ValueExample(const values& v) {m_value = v}; > > Values getValue() const { return m_value }; > > Private: > > Values m_value; > > } > > > > Std::string > > ValueExampleRepr(const ValueExample& object) > > { > > Std::stringstream ss; > > > > // What do I put here? > > // Ss << repr(object.getValue()); > > > > Return ss::str(); > > } > > > > Boost::python::enum_ values(?values?); > > Values.value(?V1?, V1); > > Values.value(?V2?, V2); > > Values.value(?V3?, V3); > > > > Boost::python::class_ ValueExample(?ValueExample?); > > > > ValueExample(?__repr__?, ValueExampleRepr); I can only come up with this: Ss << extract(boost::python::object(object.getValue()).attr("__repr__")())(); From torrin.jones at baesystems.com Sun Mar 10 13:47:38 2019 From: torrin.jones at baesystems.com (Jones, Torrin A (US)) Date: Sun, 10 Mar 2019 17:47:38 +0000 Subject: [C++-sig] Calling python function repr from C++ using boost.python (possible?) In-Reply-To: Message-ID: <44HTHj2r7CzpCdD@mail.python.org> This worked very well thanks. -----Original Message----- From: Stefan Ring [mailto:stefanrin at gmail.com] Sent: Tuesday, March 05, 2019 12:04 PM To: Development of Python/C++ integration Cc: Jones, Torrin A (US) Subject: Re: [C++-sig] Calling python function repr from C++ using boost.python (possible?) *** WARNING *** EXTERNAL EMAIL -- This message originates from outside our organization. On Sat, Mar 2, 2019 at 6:12 PM Jones, Torrin A (US) wrote: > > Is it possible to call repr from C++ on a C++ object that can be converted to python? Let me explain. > > > > I have an enum that I converted to python using boost::python::enum_(). That class already provides a good repr() to python (thanks to the boost::python developers for that). However that enum is used as a type on a member in another C++ class that I have where boost::python does not provide a good repr(). So I?m trying to provide one and thought, it sure would be nice if I could just call repr() on the member. I assume I have to convert the value on that member to python first, some kind of way then call repr? Is that possible? Or is there a better way? > > > > Example: > > > > Typedef enum > > { > > V1 = 0, > > V2 = 5, > > V3 = 6 > > } values; > > > > Class ValueExample > > { > > Public: > > ValueExample(const values& v) {m_value = v}; > > Values getValue() const { return m_value }; > > Private: > > Values m_value; > > } > > > > Std::string > > ValueExampleRepr(const ValueExample& object) > > { > > Std::stringstream ss; > > > > // What do I put here? > > // Ss << repr(object.getValue()); > > > > Return ss::str(); > > } > > > > Boost::python::enum_ values(?values?); > > Values.value(?V1?, V1); > > Values.value(?V2?, V2); > > Values.value(?V3?, V3); > > > > Boost::python::class_ ValueExample(?ValueExample?); > > > > ValueExample(?__repr__?, ValueExampleRepr); I can only come up with this: Ss << extract(boost::python::object(object.getValue()).attr("__repr__")())(); From schmmark at ethz.ch Mon Mar 18 11:07:15 2019 From: schmmark at ethz.ch (Markus Johann Schmidt) Date: Mon, 18 Mar 2019 16:07:15 +0100 Subject: [C++-sig] Fail to build Boost Python Tutorial: LNK1120: 55 unresolved externals Message-ID: Dear all, I try to learn boost and in particular the Python extension part. But I am already failing with building the tutorial. I am quite a beginner with compiling in C++ I use a Win10 64bit System. I have to use VS2015, because for a proprietary library I have to compile later in msvc120 (64bit). VS2017 is installed on the computer as well. I tried to following for compilation 1. ?Launch the "Developer Command Prompt for VS2015" 2. Setting Python environment: "C:\Users\schmmark\Anaconda3\Scripts\activate.bat" "C:\Users\schmmark\Anaconda3\envs\py36" 3. cd C:\Users\schmmark\Downloads\boost_1_69_0\boost_1_69_0 4. bootstrap.bat (successful) 5. b2.exe toolset=msvc-14.0 address-model=64 (successful) 6. cd libs\python\example\tutorial 7. ..\..\..\..\bjam.exe toolset=msvc-14.0 address-model=64 --debug-configuration I modified the Jamfile from tutorial folder and Jamroot from example folder as can be found in the attachment. I get the error `hello_ext.pyd : fatal error LNK1120: 55 unresolved externals` ?A complete output of my command prompt is attached as well. May my problem be * wrong import of python library? I try to use a wildcard in lib boost_python instead of `boost_python36-vc140-mt-x64-1_69` But the error stays the same when I rename it * Some issues with 32bit and 64bit detection? * Am I missing some imports? Thanks in advance for your support Markus -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: compile.log Type: application/octet-stream Size: 20583 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Jamroot Type: application/octet-stream Size: 902 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Jamfile Type: application/octet-stream Size: 399 bytes Desc: not available URL: From stefanrin at gmail.com Tue Mar 19 12:20:03 2019 From: stefanrin at gmail.com (Stefan Ring) Date: Tue, 19 Mar 2019 17:20:03 +0100 Subject: [C++-sig] Fail to build Boost Python Tutorial: LNK1120: 55 unresolved externals In-Reply-To: References: Message-ID: On Tue, Mar 19, 2019 at 3:52 PM Markus Johann Schmidt wrote: > A complete output of my command prompt is attached as well. > > May my problem be > > wrong import of python library? I try to use a wildcard in lib boost_python instead of `boost_python36-vc140-mt-x64-1_69` But the error stays the same when I rename it > Some issues with 32bit and 64bit detection? > Am I missing some imports? Looks like issues with MSVC's runtime libraries. Maybe rename the other Visual Studio version's installation directories temporarily to avoid wrong versions being picked up? I have not tried following the tutorial myself, though. Have not used Boost on Windows in a decade. From virali.vora2010 at gmail.com Thu Mar 21 15:04:04 2019 From: virali.vora2010 at gmail.com (virali vora) Date: Fri, 22 Mar 2019 00:34:04 +0530 Subject: [C++-sig] GSOC Message-ID: Hi, I went through the project details of Boost Python-C++ integeration and found them quite interesting. I would like to contribute to the project. The project says that we need to implement a c++ interface for Python' set type. So, should that include all the set methods of Python? Also, is there any discussion channel where I can communicate with you? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From schmidt at ifd.mavt.ethz.ch Wed Mar 20 08:19:33 2019 From: schmidt at ifd.mavt.ethz.ch (Schmidt Markus Johann) Date: Wed, 20 Mar 2019 12:19:33 +0000 Subject: [C++-sig] Fail to build Boost Python Tutorial: LNK1120: 55 unresolved externals In-Reply-To: References: , Message-ID: Dear Stefan, might indeed be the case. Now I compiled the sources again with the VS2017 command prompt. When I then try to compile the tutorial, I get the strange output C:\Users\schmmark\user-config.jam:3: Unescaped special character in argument 'C:Program notice: [msvc-cfg] msvc-14.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' notice: [msvc-cfg] msvc-12.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe' notice: [msvc-cfg] msvc-11.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe' notice: [msvc-cfg] msvc-14.1 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe' notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe' ''C:Program' 'Files' '(x86)Microsoft' 'Visual' 'Studio' '12.0VCbincl.exe'' for msvc, condition msvc-12.0 [...] notice: Loading project-config configuration file 'project-config.jam' from '../../../..'. notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe' for msvc, condition msvc-14.1 And finally LINK : fatal error LNK1181: cannot open input file 'boost_python36-vc141-mt-x64-1_69.lib' When I change the entry in the project-config.jam to `msvc : 12.0` the notice of using msvc-14.1 vanishes, but the LNK error still comes up. ________________________________ From: Stefan Ring Sent: 19 March 2019 17:20:03 To: Development of Python/C++ integration Cc: Schmidt Markus Johann Subject: Re: [C++-sig] Fail to build Boost Python Tutorial: LNK1120: 55 unresolved externals On Tue, Mar 19, 2019 at 3:52 PM Markus Johann Schmidt wrote: > A complete output of my command prompt is attached as well. > > May my problem be > > wrong import of python library? I try to use a wildcard in lib boost_python instead of `boost_python36-vc140-mt-x64-1_69` But the error stays the same when I rename it > Some issues with 32bit and 64bit detection? > Am I missing some imports? Looks like issues with MSVC's runtime libraries. Maybe rename the other Visual Studio version's installation directories temporarily to avoid wrong versions being picked up? I have not tried following the tutorial myself, though. Have not used Boost on Windows in a decade. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan at seefeld.name Thu Mar 21 15:13:16 2019 From: stefan at seefeld.name (stefan) Date: Thu, 21 Mar 2019 15:13:16 -0400 Subject: [C++-sig] GSOC In-Reply-To: References: Message-ID: <7e696f5d-86b8-9140-8757-aa27707f836d@seefeld.name> Hi Virali, On 2019-03-21 3:04 p.m., virali vora wrote: > Hi, > I went through the project details of Boost Python-C++ integeration > and found them quite interesting. > I would like to contribute to the project. > The project says that we need to implement a c++ interface for Python' > set type. > So, should that include all the set methods of Python? Yes. > Also, is there any discussion channel where I can communicate with you? I'd suggest https://gitter.im/boostorg/python Stefan -- ...ich hab' noch einen Koffer in Berlin... -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.png Type: image/png Size: 1478 bytes Desc: not available URL: From sarah.rust at roosterteeth.com Mon Mar 25 10:38:09 2019 From: sarah.rust at roosterteeth.com (Sarah Rust) Date: Mon, 25 Mar 2019 09:38:09 -0500 Subject: [C++-sig] Linking issues with Boost.Python 1.69.0, Python 2.7, MSVC 14.0 Message-ID: Hello! I have been trying to build and link the latest Boost.Python to work with Python 2.7 and my Visual Studio 2015 project (MSVC 14.0) with x64 configuration. I've added the Boost library and Boost include directory to my project's properties, but I am getting the following error when I create a BOOST_PYTHON_MODULE: error LNK2001: unresolved external symbol "__declspec(dllimport) struct _object * __cdecl boost::python::detail::init_module(char const *,void (__cdecl*)(void))" (__imp_?init_module at detail@python at boost@@YAPEAU_object@ @PEBDP6AXXZ at Z) Please let me know how others are doing this. Thanks, Sarah -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefanrin at gmail.com Wed Mar 27 05:09:41 2019 From: stefanrin at gmail.com (Stefan Ring) Date: Wed, 27 Mar 2019 10:09:41 +0100 Subject: [C++-sig] Linking issues with Boost.Python 1.69.0, Python 2.7, MSVC 14.0 In-Reply-To: References: Message-ID: On Tue, Mar 26, 2019 at 3:27 PM Sarah Rust wrote: > > Hello! > > I have been trying to build and link the latest Boost.Python to work with Python 2.7 and my Visual Studio 2015 project (MSVC 14.0) with x64 configuration. I've added the Boost library and Boost include directory to my project's properties, but I am getting the following error when I create a BOOST_PYTHON_MODULE: > > error LNK2001: unresolved external symbol "__declspec(dllimport) struct _object * __cdecl boost::python::detail::init_module(char const *,void (__cdecl*)(void))" (__imp_?init_module at detail@python at boost@@YAPEAU_object@@PEBDP6AXXZ at Z) Have you built Python yourself? With which compiler? Are you linking against its import lib (for DLL use at run time)? Could you maybe use the static version of Boost? Actually while writing this, a though came up: Are you even linking against the Boost Python library? > Please let me know how others are doing this. Probably not at all ;). From pavol.juhas at gmail.com Tue Mar 26 14:34:57 2019 From: pavol.juhas at gmail.com (Pavol Juhas) Date: Tue, 26 Mar 2019 14:34:57 -0400 Subject: [C++-sig] argument conversion of numpy.int64 to double Message-ID: Hello, After wrapping a simple C++ function of a double argument with boost python, I have noticed it crashes when called from Python with a numpy.int64 value. This is a likely situation, for example when evaluated for values from numpy.arange. Please see below for a minimum example. Is there some simple way of telling the wrapper how to handle numpy.int64 arguments? BTW, I have noticed that the boost/numpy library sets up several scalar converters on its initialization - this happens in boost/python/numpy.hpp and then in the register_scalar_converters function. However, adding a call to boost::python::numpy::initialize did not make a difference in my example. Thank you for any advice. Best, Pavol // dbfunction.cpp ------------------------------------------------------------ #include #include #include double duplicate(double x) { return 2 * x; } BOOST_PYTHON_MODULE(dbfunction) { using boost::python::def; // no difference with line below // boost::python::numpy::initialize(); def("duplicate", duplicate); } // --------------------------------------------------------------------------- # TEST $ python -c 'import dbfunction, numpy; dbfunction.duplicate(numpy.int64(0))' Traceback (most recent call last): File "", line 1, in Boost.Python.ArgumentError: Python argument types in dbfunction.duplicate(numpy.int64) did not match C++ signature: duplicate(double) -------------- next part -------------- An HTML attachment was scrubbed... URL: From damika97.10 at gmail.com Wed Mar 27 13:11:22 2019 From: damika97.10 at gmail.com (Damika Gamlath) Date: Wed, 27 Mar 2019 22:41:22 +0530 Subject: [C++-sig] GSOC 2019 Boost.Python Message-ID: Hi, I am Damika Gamlath an undergraduate from Department of Computer Science & Engineering, University of Moratuwa, Sri Lanka. I am interested to participate in GSOC 2019. I would like to know about project ideas under Boost.Python. Further I would like to be guided about next steps. Thank you! Best regards, Damika Gamlath -------------- next part -------------- An HTML attachment was scrubbed... URL: