From paul.bridger at paradise.net.nz Tue Jun 1 07:51:34 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Tue, 01 Jun 2004 17:51:34 +1200 Subject: [C++-sig] pyste defect: expanding typedefs in generated code In-Reply-To: <40BA6985.3020306@esss.com.br> References: <40B9B676.905@paradise.net.nz> <40BA6985.3020306@esss.com.br> Message-ID: <40BC1966.3010707@paradise.net.nz> Nicodemus wrote: > Actually, I believe that now GCCXML exports the declarated type of a > typedef, instead of the expanded name. If that's true, only the file > declarations.py must be changed, and little at that. I had a look at this, but didn't really understand what was going on sufficiently to fix the problem. From the looks of things I will be gradually becoming more acquainted with Pyste's inner child, hopefully at some point I will have an opportunity to fix this. However, I have a fix for another issue I encountered. :) What is annoying in this case is that I cannot work out the first cause of pystes failure. There is a class 'Vector3' that is fairly simple, and defines some static member data: /* Vector3.h */ class Vector3 { //... // special points static const Vector3 ZERO; static const Vector3 UNIT_X; static const Vector3 UNIT_Y; static const Vector3 UNIT_Z; //... }; /* Vector3.cpp */ const Vector3 Vector3::ZERO( 0, 0, 0 ); //... These are exported fine except for an additional 'empty' member. The generated code is: .def_readonly("", &Ogre::Vector3::) .def_readonly("ZERO", &Ogre::Vector3::ZERO) .def_readonly("UNIT_X", &Ogre::Vector3::UNIT_X) .def_readonly("UNIT_Y", &Ogre::Vector3::UNIT_Y) .def_readonly("UNIT_Z", &Ogre::Vector3::UNIT_Z) Which obviously fails to compile. I would guess the original error is in the use of GCCXML output, but the best I can do (without a hint or two as to where to look) for a fix is to change ClassExporter.py:288 (in ExportVariables) from this: if self.info[var.name].exclude: continue to this: if self.info[var.name].exclude or var.name == '': continue Paul Bridger From paul.bridger at paradise.net.nz Tue Jun 1 08:21:26 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Tue, 01 Jun 2004 18:21:26 +1200 Subject: [C++-sig] pyste defect: expanding typedefs in generated code In-Reply-To: <40BC1966.3010707@paradise.net.nz> References: <40B9B676.905@paradise.net.nz> <40BA6985.3020306@esss.com.br> <40BC1966.3010707@paradise.net.nz> Message-ID: <40BC2066.6030806@paradise.net.nz> paul.bridger wrote: > I would guess the original error is in the use of GCCXML output, but the > best I can do (without a hint or two as to where to look) for a fix is Here's my new best. IMO fixing the error while parsing GCCXML output is better, unless members without names have some special significance known at the class level. GCCXMLParser.py:280, in GetMembers: < if type(decl) in Class.ValidMemberTypes(): > if type(decl) in Class.ValidMemberTypes() and decl.name != '': Paul Bridger From rwgk at yahoo.com Tue Jun 1 10:29:55 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 1 Jun 2004 01:29:55 -0700 (PDT) Subject: [C++-sig] Boost.Python on MacOS X...at all... In-Reply-To: Message-ID: <20040601082955.34809.qmail@web20212.mail.yahoo.com> --- Nick Bastin wrote: > Has anybody succeeded on building Boost.Python on MacOS X at all? Yes, all the time, but you need Python 2.3 or higher. The Python that comes with OS 10.3 is fine. You also need the latest Apple compilers. Please look at the Boost.Python FAQ for details. > It > appears that the linker flags are wrong for creating the dylib (c++ > -shared is not correct on MacOS X). I am using a SCons-based build system. I am not sure if the bjam system is still in working condition under OS 10, but at one point not too long ago it was. Ralf __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From nbastin at opnet.com Tue Jun 1 10:42:57 2004 From: nbastin at opnet.com (Nick Bastin) Date: Tue, 1 Jun 2004 04:42:57 -0400 Subject: [C++-sig] Boost.Python on MacOS X...at all... In-Reply-To: <20040601082955.34809.qmail@web20212.mail.yahoo.com> References: <20040601082955.34809.qmail@web20212.mail.yahoo.com> Message-ID: On Jun 1, 2004, at 4:29 AM, Ralf W. Grosse-Kunstleve wrote: > --- Nick Bastin wrote: >> Has anybody succeeded on building Boost.Python on MacOS X at all? > > Yes, all the time, but you need Python 2.3 or higher. The Python that > comes > with OS 10.3 is fine. You also need the latest Apple compilers. Please > look at > the Boost.Python FAQ for details. Yes, I've done all of that. Basically, from what I'm hearing on this list, multiple people have it working on OS X, but nobody uses bjam. Hardly a ringing endorsement for the stock build system. I have been unable to make it build using the Python 2.3 that comes with MacOS X, or my 2.4 CVS tree, which is really what I'm shooting for. Unfortunately, I don't know a lot about jam, but it appears that the tools file for darwin requires that python be in a framework build, and can't work off of a standard unix-style installation. If anybody knows otherwise, or how to tweak it to be so, I'd really appreciate knowing how. I'm trying to stage the build, rather than an install, if that makes any difference. -- Nick From dave at boost-consulting.com Tue Jun 1 11:56:42 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 01 Jun 2004 05:56:42 -0400 Subject: [C++-sig] Re: std::string crash - SOLVED References: <012001c444ab$3be53530$6b0aa8c0@vladimirpc> <5.1.0.14.0.20040528160225.038c3ec0@mail.chello.be> <3432.129.186.232.105.1085762663.squirrel@mail.eng.iastate.edu> <003b01c446d4$65178db0$6b0aa8c0@vladimirpc> Message-ID: "Vladimir Ignatov" writes: > BTW I found that Boost.Python can't be compiled using my VC6 - some files > are fails to compile (sorry, don't have a log handy). Others library are > builds okay. (VC7 build Boost.Python just fine). Known problem; fixed in CVS lo these many months. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From paul.bridger at paradise.net.nz Wed Jun 2 02:24:13 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Wed, 02 Jun 2004 12:24:13 +1200 Subject: [C++-sig] Pyste patch to generate default policy for virtual methods Message-ID: <40BD1E2D.3060109@paradise.net.nz> Nicodemus, For virtual methods, Pyste doesn't a) complain when they aren't given a policy, and b) give them the default return_value_policy(copy_const_reference) Here's a patch for that. I also made Pyste insert comments in generated code to show where various elements are exported. I have found this useful in editing my pyste files, but I don't care if you don't want that for mainstream Pyste. Paul Bridger ClassExporter.py 275a276,277 > if constructors: > self.Add('inside', '// Additional constructors') 286a289,290 > if vars: > self.Add('inside', '// Class Variables') 288c292 < if self.info[var.name].exclude: --- > if self.info[var.name].exclude: 355a360,361 > if methods: > self.Add('inside', '// Methods') 365c371 < --- > 425a432 > self.Add('inside', '// Virtual Methods') 505a513,514 > if operators: > self.Add('inside', '// Operators') 778,779c787,792 < # Add policy to overloaded methods also < policy = self.info[method.name].policy or '' --- > # warn the user if this method needs a policy and doesn't have one > method_info = self.info[method.name] > method_info.policy = exporterutils.HandlePolicy(method, method_info.policy) > > # Add policy to overloaded methods also > policy = method_info.policy or '' From igor at pcigeomatics.com Wed Jun 2 17:39:58 2004 From: igor at pcigeomatics.com (Igor Lapshin) Date: Wed, 2 Jun 2004 11:39:58 -0400 Subject: [C++-sig] Linker errors with VC7.1 (.NET) and Python.Boost 1.31.0 Message-ID: Hi, I'm trying to compile the following code within MS Visual Studio IDE .NET 2003. I compiled Boost 1.31.0 usign bjam, but I have the requirement that all exposed into Python classes must be compiled within IDE. "no_init" was specified because the original class has pure virtual functions, but I get the same errors even without them. The original class links and works fine on Linux/gcc, so I suppose I have problems specific to VC7.1 and Windows. class myclass { const char* name; public: myclass(); const char* getName(); }; myclass::myclass(): name("I'm a class") {} const char *myclass::getName() { return name; } using namespace boost::python; BOOST_PYTHON_MODULE(testme) { class_("myclass", no_init) .def("getName", &myclass::getName) ; } I specified libboost_python-vc71-mt-gd.lib as link library. test_boost.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl boost::python::objects::register_dynamic_id_aux(struct boost::python::type_info,struct std::pair (__cdecl*)(void *))" (__imp_?register_dynamic_id_aux at objects@python at boost@@YAXUtype_info at 23@P 6A?AU?$pair at PAXUtype_info@python at boost@@@std@@PAX at Z@Z) referenced in function "void __cdecl boost::python::objects::register_dynamic_id(class myclass *)" (??$register_dynamic_id at Vmyclass@@@objects at python@boost@@YAXPAVmyclass@@ @Z) Am I missing something? Do I always need to write a wrapper class for "no_init"? Thanks, Igor -------------- next part -------------- An HTML attachment was scrubbed... URL: From igor at pcigeomatics.com Wed Jun 2 19:16:55 2004 From: igor at pcigeomatics.com (Igor Lapshin) Date: Wed, 2 Jun 2004 13:16:55 -0400 Subject: [C++-sig] Linker errors with VC7.1 (.NET) and Python.Boost 1.31.0 Message-ID: Hello all, I solved the problem: I added python_boost.lib library into the project. I am still wondering why this library was not put into Boost/lib directory and why my project worked on Linux without that library (I also used non-standard build mechanism and only a single boost_python-gcc-mt-d library) Regards, Igor -------------- next part -------------- An HTML attachment was scrubbed... URL: From rutt at 168-226-10-180.speedy.com.ar Fri Jun 4 16:16:17 2004 From: rutt at 168-226-10-180.speedy.com.ar (rutt at 168-226-10-180.speedy.com.ar) Date: Fri, 04 Jun 2004 14:16:17 +0000 Subject: [C++-sig] software In-Reply-To: <416AA6DCB8D1L6HC@python.org> References: <416AA6DCB8D1L6HC@python.org> Message-ID: Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://HEEHLM.biz/OE017/?affiliate_id=233763&campaign_id=601 uns * ub - scribe http://NANNEH.biz/diamondtron.php?affiliate_id=233763&campaign_id=601 vrnnhidj xwrrg vdjyunu vtfwj clctknd ddqj lvujrl cztf ihaxbvg hrqje trotwrln dyiy icjkbtq kaqibmo ifh tjal zitrvwv ugtdt e ojxhv From paul.bridger at paradise.net.nz Fri Jun 4 06:23:25 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Fri, 04 Jun 2004 16:23:25 +1200 Subject: [C++-sig] Pyste exception handlers Message-ID: <40BFF93D.7030506@paradise.net.nz> Nicodemus, How would you recommend exception handler registration be implemented in Pyste? A problem here would be what to do in the differing cases of: - building a single pyste file into a module : in this case specifying exception handlers in the pyste file is sufficient - building many pyste files into a single module : in this case you probably want exception handlers to be specified in a module-level file, or perhaps you could put them in an arbitrary pyste file I think Pyste has some deficiencies in organising modules from multiple files. It is wonderful that this can be done, but I don't like that so much has to be specified on the command-line (and that the meaning of command-line options changes depending on --multiple or not). I think a better organisation would involve a module-level file, which could then contain such things as exception handlers. This would also make building modules out of several pyste files cleaner. (A disadvantage is that it expands the scope of the tool into something of a build tool). What do others think? Paul Bridger From AnToine at alexion.nl Fri Jun 4 14:35:43 2004 From: AnToine at alexion.nl (AnToine van Maarle) Date: Fri, 4 Jun 2004 14:35:43 +0200 Subject: [C++-sig] (no subject) Message-ID: Hi folks, I don't realy kno if this is the correct mailinglist, but as far as I can see you work with c++ and this error message is a c++ something, maybe one of you can help, please? Thanx AnToine ====================== error message ==================================== C:\Program Files\Alexion Software\Relation Manager\program>arm.exe Extracting binaries C:\Program Files\Alexion Software\Relation Manager\program\python23.dll Manipulating evironment PYTHONPATH=C:/Program Files/Alexion Software/Relation Manager/program importing modules from CArchive iu archive Installing import hooks out1.pyz Running scripts bin\buildstdapp\out1.pyz/fcntl:7: DeprecationWarning: the FCNTL module is deprecated; please use fcntl Traceback (most recent call last): File "", line 90, in ? File "bin\buildstdapp\out1.pyz/wxPython.wx", line 1957, in __init__ File "", line 66, in OnInit File "bin\buildstdapp\out1.pyz/pynx.gui.frame", line 97, in __init__ File "bin\buildstdapp\out1.pyz/wxPython.stattool", line 227, in Realize wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in e:\Pr ojects\wx2.4\src\msw\tbar95.cpp(582): invalid tool button bitmap RC: -1 from main OK. 23:02:35: Debug: e:\Projects\wx2.4\src\msw\app.cpp(407): 'UnregisterClass(MDI parent)' failed with error 0x00000584 (de klasse heeft nog geopende vensters.). From grafik.list at redshift-software.com Fri Jun 4 16:53:58 2004 From: grafik.list at redshift-software.com (Rene Rivera) Date: Fri, 04 Jun 2004 09:53:58 -0500 Subject: [C++-sig] (no subject) In-Reply-To: References: Message-ID: <40C08D06.6000105@redshift-software.com> AnToine van Maarle wrote: > Hi folks, > > I don't realy kno if this is the correct mailinglist, but as far as I > can see you work with c++ and this error message is a c++ something, > maybe one of you can help, please? That looks like a wxWidgest error. Ask on the wx-users or wx-dev lists... See: wxwidgets.org for details. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq From AnToine at alexion.nl Fri Jun 4 18:38:15 2004 From: AnToine at alexion.nl (AnToine van Maarle) Date: Fri, 4 Jun 2004 18:38:15 +0200 Subject: [C++-sig] help Message-ID: ok -----Oorspronkelijk bericht----- Van: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]Namens c++-sig-request at python.org Verzonden: vrijdag 4 juni 2004 18:05 Aan: c++-sig at python.org Onderwerp: C++-sig Digest, Vol 11, Issue 4 Send C++-sig mailing list submissions to c++-sig at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/c++-sig or, via email, send a message with subject or body 'help' to c++-sig-request at python.org You can reach the person managing the list at c++-sig-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of C++-sig digest..." Today's Topics: 1. software (rutt at 168-226-10-180.speedy.com.ar) 2. Pyste exception handlers (paul.bridger) 3. (no subject) (AnToine van Maarle) 4. Re: (no subject) (Rene Rivera) ---------------------------------------------------------------------- Message: 1 Date: Fri, 04 Jun 2004 14:16:17 +0000 From: rutt at 168-226-10-180.speedy.com.ar Subject: [C++-sig] software To: C++-sig Message-ID: Content-Type: text/plain Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://HEEHLM.biz/OE017/?affiliate_id=233763&campaign_id=601 uns * ub - scribe http://NANNEH.biz/diamondtron.php?affiliate_id=233763&campaign_id=601 vrnnhidj xwrrg vdjyunu vtfwj clctknd ddqj lvujrl cztf ihaxbvg hrqje trotwrln dyiy icjkbtq kaqibmo ifh tjal zitrvwv ugtdt e ojxhv ------------------------------ Message: 2 Date: Fri, 04 Jun 2004 16:23:25 +1200 From: "paul.bridger" Subject: [C++-sig] Pyste exception handlers To: Development of Python/C++ integration Message-ID: <40BFF93D.7030506 at paradise.net.nz> Content-Type: text/plain; format=flowed; charset=us-ascii Nicodemus, How would you recommend exception handler registration be implemented in Pyste? A problem here would be what to do in the differing cases of: - building a single pyste file into a module : in this case specifying exception handlers in the pyste file is sufficient - building many pyste files into a single module : in this case you probably want exception handlers to be specified in a module-level file, or perhaps you could put them in an arbitrary pyste file I think Pyste has some deficiencies in organising modules from multiple files. It is wonderful that this can be done, but I don't like that so much has to be specified on the command-line (and that the meaning of command-line options changes depending on --multiple or not). I think a better organisation would involve a module-level file, which could then contain such things as exception handlers. This would also make building modules out of several pyste files cleaner. (A disadvantage is that it expands the scope of the tool into something of a build tool). What do others think? Paul Bridger ------------------------------ Message: 3 Date: Fri, 4 Jun 2004 14:35:43 +0200 From: "AnToine van Maarle" Subject: [C++-sig] (no subject) To: Message-ID: Content-Type: text/plain; charset="iso-8859-1" Hi folks, I don't realy kno if this is the correct mailinglist, but as far as I can see you work with c++ and this error message is a c++ something, maybe one of you can help, please? Thanx AnToine ====================== error message ==================================== C:\Program Files\Alexion Software\Relation Manager\program>arm.exe Extracting binaries C:\Program Files\Alexion Software\Relation Manager\program\python23.dll Manipulating evironment PYTHONPATH=C:/Program Files/Alexion Software/Relation Manager/program importing modules from CArchive iu archive Installing import hooks out1.pyz Running scripts bin\buildstdapp\out1.pyz/fcntl:7: DeprecationWarning: the FCNTL module is deprecated; please use fcntl Traceback (most recent call last): File "", line 90, in ? File "bin\buildstdapp\out1.pyz/wxPython.wx", line 1957, in __init__ File "", line 66, in OnInit File "bin\buildstdapp\out1.pyz/pynx.gui.frame", line 97, in __init__ File "bin\buildstdapp\out1.pyz/wxPython.stattool", line 227, in Realize wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in e:\Pr ojects\wx2.4\src\msw\tbar95.cpp(582): invalid tool button bitmap RC: -1 from main OK. 23:02:35: Debug: e:\Projects\wx2.4\src\msw\app.cpp(407): 'UnregisterClass(MDI parent)' failed with error 0x00000584 (de klasse heeft nog geopende vensters.). ------------------------------ Message: 4 Date: Fri, 04 Jun 2004 09:53:58 -0500 From: Rene Rivera Subject: Re: [C++-sig] (no subject) To: Development of Python/C++ integration Message-ID: <40C08D06.6000105 at redshift-software.com> Content-Type: text/plain; charset=us-ascii; format=flowed AnToine van Maarle wrote: > Hi folks, > > I don't realy kno if this is the correct mailinglist, but as far as I > can see you work with c++ and this error message is a c++ something, > maybe one of you can help, please? That looks like a wxWidgest error. Ask on the wx-users or wx-dev lists... See: wxwidgets.org for details. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq ------------------------------ _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig End of C++-sig Digest, Vol 11, Issue 4 ************************************** From nick at rockstarvancouver.com Sat Jun 5 02:02:39 2004 From: nick at rockstarvancouver.com (Nick Trout) Date: Fri, 4 Jun 2004 17:02:39 -0700 Subject: [C++-sig] Embedding in .NET architecture Message-ID: <911F8C8EB7A8084AAEDD55CEDC54D8F851FE2D@iggy.rockstarvancouver.com> Hello! I'm trying to embed Python into Windows Forms Application I'm working on. .NET is relatively new to me and having just got over the Managed objects vs unmanaged objects problems I'm now having trouble getting Boost working. My objective is to start up an application and then use Python scripts to customise the application and do various processing. I want to expose various features of the application to Python to enable this. Given what I am trying to do I think it's more appropriate to embed than to extend. I've been through the archives and looked at the embedding.cpp test example that is in the Boost source but I can't seem to find any information which fixes my problem. When I run the test suite the embedding.cpp example works when bjam compiles and runs it. However, when I copy the example into my code and run it throws and exception which crashes the application. I'm trying to get my application running using multithreaded DLL support. I've tried linking Boost against libboost statically linked libraries and against the boost_python dynamic libraries but I keep getting exceptions of various kinds (TEH, missing types etc). I know Boost works with MSVC 7.1 because other people seem to be using it and all the tests suite worked for me. What I haven't been able to do is get Boost.Python working in a MSVC app that uses managed objects. I'm therefore assuming that I don't have the correct settings, am missing some configuration #define or am just too much of a novice at the .NET framework to understand what the problem is. One thing I haven't tried, which is repeated on the mailing list is to build my application using bjam. I haven't tried this as I don't know how it would work with all the "assemblies" and stuff that goes into a WFA. I really don't want to have to do this if I can avoid it. Current problem I am having: When I run the embedded code in my app: if (python::handle_exception( test )) { if (PyErr_Occurred()) PyErr_Print(); return 1; } The exception handler fails because apparently test provides an invalid (NULL) pointer so f() has nothing to call in the try-catch handler. If I call test() directly in: <<<< // Register the module with the interpreter if (PyImport_AppendInittab("embedded_hello", initembedded_hello) == -1) throw std::runtime_error("Failed to add embedded_hello to the interpreter's " "builtin modules"); // Initialize the interpreter Py_Initialize(); // Retrieve the main module python::object main_module = python::extract( PyImport_AddModule("__main__") )(); // Retrieve the main module's namespace python::object main_namespace(main_module.attr("__dict__")); >>>> Execution gets as far as "python::object main_module..." and I get the following error: <<<< An unhandled exception of type 'System.TypeLoadException' occurred in WorldEditor.exe Additional information: Could not load type boost.python.detail.new_non_null_reference_t from assembly WorldEditor, Version=1.0.1616.28683, Culture=neutral, PublicKeyToken=null. >>>> I've tried to set all of the correct project settings. I have asynchronous exeception handling turned on (/EHa) as opposed to the default (/EHsc) and RTTI is on. I hope you can help please. It may be obvious to a .NET expert. If not, I'll probably give this another day and move to PyCXX (and then Lua!) Nick From bob at redivi.com Sat Jun 5 02:22:06 2004 From: bob at redivi.com (Bob Ippolito) Date: Fri, 4 Jun 2004 20:22:06 -0400 Subject: [C++-sig] Embedding in .NET architecture In-Reply-To: <911F8C8EB7A8084AAEDD55CEDC54D8F851FE2D@iggy.rockstarvancouver.com> References: <911F8C8EB7A8084AAEDD55CEDC54D8F851FE2D@iggy.rockstarvancouver.com> Message-ID: <60403A5E-B686-11D8-BBA0-000A95686CD8@redivi.com> On Jun 4, 2004, at 8:02 PM, Nick Trout wrote: > I hope you can help please. It may be obvious to a .NET expert. If not, > I'll probably give this another day and move to PyCXX (and then Lua!) Uh, why not just try one of the Python .NET projects, like this: http://www.zope.org/Members/Brian/PythonNet/index_html There may or may not be others, I have no experience with any of them. -bob -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2357 bytes Desc: not available URL: From nick at rockstarvancouver.com Sat Jun 5 02:24:49 2004 From: nick at rockstarvancouver.com (Nick Trout) Date: Fri, 4 Jun 2004 17:24:49 -0700 Subject: [C++-sig] Embedding in .NET architecture Message-ID: <911F8C8EB7A8084AAEDD55CEDC54D8F881FD9B@iggy.rockstarvancouver.com> > Behalf Of Nick Trout > I'm trying to embed Python into Windows Forms Application I'm working > on. .NET is relatively new to me and having just got over the Managed > objects vs unmanaged objects problems I'm now having trouble getting > Boost working. Aggggggghhhhhhhh. And arrrghhhhgghhhh again. You need to put: #pragma unmanaged before the Boost headers and around any code that uses Boost. Jeez. I'm glad .NET is making my life easier and me more productive. Nick From nick at rockstarvancouver.com Sat Jun 5 02:28:06 2004 From: nick at rockstarvancouver.com (Nick Trout) Date: Fri, 4 Jun 2004 17:28:06 -0700 Subject: [C++-sig] Embedding in .NET architecture Message-ID: <911F8C8EB7A8084AAEDD55CEDC54D8F881FD9C@iggy.rockstarvancouver.com> > Behalf Of Bob Ippolito > On Jun 4, 2004, at 8:02 PM, Nick Trout wrote: > > > I hope you can help please. It may be obvious to a .NET expert. If not, > > I'll probably give this another day and move to PyCXX (and then Lua!) > > Uh, why not just try one of the Python .NET projects, like this: > http://www.zope.org/Members/Brian/PythonNet/index_html Oh. Very interesting, I shall certainly look at it in more detail. Thanks Bob! > There may or may not be others, I have no experience with any of them. I did come across IronPython, which is supposed to run off the .NET CLR. Rather surprisingly it seems more efficient than the Python VM (except for compilation/eval). Nick From bob at redivi.com Sat Jun 5 03:06:44 2004 From: bob at redivi.com (Bob Ippolito) Date: Fri, 4 Jun 2004 21:06:44 -0400 Subject: [C++-sig] Embedding in .NET architecture In-Reply-To: <911F8C8EB7A8084AAEDD55CEDC54D8F881FD9C@iggy.rockstarvancouver.com> References: <911F8C8EB7A8084AAEDD55CEDC54D8F881FD9C@iggy.rockstarvancouver.com> Message-ID: <9C876726-B68C-11D8-BBA0-000A95686CD8@redivi.com> On Jun 4, 2004, at 8:28 PM, Nick Trout wrote: > >> Behalf Of Bob Ippolito >> On Jun 4, 2004, at 8:02 PM, Nick Trout wrote: >> >>> I hope you can help please. It may be obvious to a .NET expert. If > not, >>> I'll probably give this another day and move to PyCXX (and then > Lua!) >> >> Uh, why not just try one of the Python .NET projects, like this: >> http://www.zope.org/Members/Brian/PythonNet/index_html > > Oh. Very interesting, I shall certainly look at it in more detail. > Thanks Bob! > >> There may or may not be others, I have no experience with any of them. > > I did come across IronPython, which is supposed to run off the .NET > CLR. > Rather surprisingly it seems more efficient than the Python VM (except > for compilation/eval). IronPython will be much more useful when Jim decides to release it :) -bob -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2357 bytes Desc: not available URL: From nick at rockstarvancouver.com Sat Jun 5 04:36:11 2004 From: nick at rockstarvancouver.com (Nick Trout) Date: Fri, 4 Jun 2004 19:36:11 -0700 Subject: [C++-sig] Embedding in .NET architecture Message-ID: <911F8C8EB7A8084AAEDD55CEDC54D8F851FE2E@iggy.rockstarvancouver.com> > On Behalf Of Bob Ippolito > IronPython will be much more useful when Jim decides to release it :) So, from what I can make out IronPython looks like it compiles into .NET CLR VM code and PythonNet is Python, with an interface to .NET CLR Libs. I can't see any features in IronPython that I need over PythonNet. IronPython is an "unreleased research prototype". So that solves that problem of working out which to use! PythonNet is a one way interface from Python to CLR libraries, which is all I need for embedding. It does support access to PyObject* though so you could delve into Python if need be. I think it uses unmanaged objects. IronPython, compiled in CLR code looks like it is completely managed and closer integrated to the CLR model. So I suppose I have to decide if, now I have Boost working, it's more work to get PythonNet working and support it, rather than support Boost. Nick From texhax at fruitfly.BDGP.berkeley.edu Sun Jun 6 04:51:35 2004 From: texhax at fruitfly.BDGP.berkeley.edu (texhax at fruitfly.BDGP.berkeley.edu) Date: Sun, 06 Jun 2004 02:51:35 +0000 Subject: [C++-sig] software In-Reply-To: <1JFLD3K1F922EEA5@python.org> References: <1JFLD3K1F922EEA5@python.org> Message-ID: <5DLLI3J59F3HJEBL@fruitfly.berkeley.edu> Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://FLLMNA.info/OE017/?affiliate_id=233763&campaign_id=601 uns * ub - scribe http://NANNEH.biz/diamondtron.php?affiliate_id=233763&campaign_id=601 hhfggpxl yowdk phwotay naxje bqtogqw nxcv matkpe ocvw ykpziez hoeth xxmouclx yayg lnjcqgz oqoobuo tit ppqm egthtff udkgr w tictz From Peter.Vandersteegen at intec.Ugent.be Mon Jun 7 09:59:40 2004 From: Peter.Vandersteegen at intec.Ugent.be (Peter Vandersteegen) Date: Mon, 07 Jun 2004 09:59:40 +0200 Subject: [C++-sig] problems compiling simple example in boost-python documentation/tutorial... Message-ID: <6.1.0.6.0.20040607092433.026648c0@pop-tech.intec.UGent.be> An HTML attachment was scrubbed... URL: From g.simpson at zoo-tech.com Mon Jun 7 12:48:26 2004 From: g.simpson at zoo-tech.com (Gareth Simpson) Date: Mon, 7 Jun 2004 11:48:26 +0100 Subject: [C++-sig] Tedious Newbie Question Message-ID: <176AB0A0ADC4734B8FE888D53E75D9D5017EB1F1@s15shefsrv.zoodigitalgroup.com> Apologies in advance if this is not the list to be asking these sort of things. I am trying to use Boost.Python to embed a Python library into my C++ application. The library in question uses unicode strings internally and I can't for the life of me work out how to get them out and into my C++. Google is largely silent on the matter. The below code snippet shows what I'm trying to do. I have no problem using extract<> to get a python string into a std::string but trying the same thing with unicode python strings and std::wstrings throws an exception. Clearly I'm going about it the wrong way - what should I be doing? Thanks in advance Gareth #include "stdafx.h" #include "boost/python.hpp" int _tmain(int argc, _TCHAR* argv[]) { using namespace boost::python; Py_Initialize(); object mainModule (borrowed(PyImport_AddModule("__main__"))); object mainNamespace = mainModule.attr("__dict__"); handle<>(PyRun_String( "str1 = 'a string'\n" // a simple string "str2 = u'a unicode string'\n", // a unicode string Py_file_input , mainNamespace.ptr(), mainNamespace.ptr() )); std::string str1 = extract(mainNamespace["str1"]); // this works fine std::wstring str2 = extract(mainNamespace["str2"]); // boom! Py_Finalize(); return 0; } From AnToine at alexion.nl Mon Jun 7 15:40:58 2004 From: AnToine at alexion.nl (AnToine van Maarle) Date: Mon, 7 Jun 2004 15:40:58 +0200 Subject: [C++-sig] RE: C++-sig Digest, Vol 11, Issue 6 Message-ID: thnx -----Oorspronkelijk bericht----- Van: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org]Namens c++-sig-request at python.org Verzonden: zaterdag 5 juni 2004 18:02 Aan: c++-sig at python.org Onderwerp: C++-sig Digest, Vol 11, Issue 6 Send C++-sig mailing list submissions to c++-sig at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/c++-sig or, via email, send a message with subject or body 'help' to c++-sig-request at python.org You can reach the person managing the list at c++-sig-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of C++-sig digest..." Today's Topics: 1. software (texhax at fruitfly.BDGP.berkeley.edu) ---------------------------------------------------------------------- Message: 1 Date: Sun, 06 Jun 2004 02:51:35 +0000 From: texhax at fruitfly.BDGP.berkeley.edu Subject: [C++-sig] software To: C++-sig Message-ID: <5DLLI3J59F3HJEBL at fruitfly.berkeley.edu> Content-Type: text/plain Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://FLLMNA.info/OE017/?affiliate_id=233763&campaign_id=601 uns * ub - scribe http://NANNEH.biz/diamondtron.php?affiliate_id=233763&campaign_id=601 hhfggpxl yowdk phwotay naxje bqtogqw nxcv matkpe ocvw ykpziez hoeth xxmouclx yayg lnjcqgz oqoobuo tit ppqm egthtff udkgr w tictz ------------------------------ _______________________________________________ C++-sig mailing list C++-sig at python.org http://mail.python.org/mailman/listinfo/c++-sig End of C++-sig Digest, Vol 11, Issue 6 ************************************** From Peter.Vandersteegen at intec.Ugent.be Mon Jun 7 16:23:51 2004 From: Peter.Vandersteegen at intec.Ugent.be (Peter Vandersteegen) Date: Mon, 07 Jun 2004 16:23:51 +0200 Subject: [C++-sig] problems compiling simple example in boost-python documentation/tutorial... Message-ID: <6.1.0.6.0.20040607162218.00a249d0@pop-tech.intec.UGent.be> Hello, Sorry for the previous mail. I didn't realize a html-email would be scrubbed. Therefore the original text is sent in plain text Peter... As a boost-python beginner I've started exploring the tutorial. I however had trouble compiling a very basic example from the tutorial: http://www.boost.org/libs/python/doc/tutorial/doc/virtual_functions_with_default_implementations.html Changing some lines in the tutorial code however solved the compiling problem. Now my question is: Does this relate to my compiler: intel 7.1, msvc7.0? Or something I overlooked in my code? I've started with a pure virtual base class, and indeed the virtual function can be overriden in python and called with a function in c++ ... (fantastic :) ) No problems at all... I recieve however compiler-errors (explained after program) when I however try to compile the exact example from the tutorial ...(see link and following text) // file wraptestpoly.cpp #include using namespace boost::python; struct Base { virtual int f(void){return 0;} }; //* int call_f(Base& b) { return b.f(); } struct BaseWrap : Base { BaseWrap(PyObject* self_) : self(self_) {} virtual int f() { return call_method(self, "f"); } int default_f() { return Base::f(); } PyObject* self; }; BOOST_PYTHON_MODULE(wraptestpoly){ class_("Base") //*1 .def("f", &Base::f, &BaseWrap::default_f) def("call_f", call_f); } //end file The error I recieve is: D:\libraries\boost_1_31_0\boost/python/object/value_holder.hpp(134): error: no instance of constructor "BaseWrap::BaseWrap" matches the argument list argument types are: (PyObject *, boost::reference_wrapper::type) If I however use class_("Base") instead of //*1 --> no compiling problems. Another option which works is adding a copy-constructor: BaseWrap(PyObject* self_, Base const& copy) : Base(copy), self(self_) {} in the wrapperclass. Now my question is: what did I do wrong with this simple example? Could this problem arise from an outdated tutorial? thx a lot Peter From Pere.Mato at cern.ch Mon Jun 7 18:20:54 2004 From: Pere.Mato at cern.ch (Pere Mato Vila) Date: Mon, 7 Jun 2004 18:20:54 +0200 Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined Message-ID: <5BF9E41B6C9F2546B624F30FE840C122351BAF@cernxchg21.cern.ch> I am having the following compilation warnings when including "boost/python.hpp". I am using Boost 1.31.0 Python 2.3.3 and gcc 3.2. Is anything I am doing wrong? In file included from /afs/cern.ch/sw/lcg/external/Python/2.3.3/rh73_gcc32/include/python2.3/P ython.h:8, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python/detail/wrap_python.hpp:121, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python/detail/prefix.hpp:13, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python/args.hpp:9, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python.hpp:12, from test.cpp:1: /afs/cern.ch/sw/lcg/external/Python/2.3.3/rh73_gcc32/include/python2.3/p yconfig.h:847:1: warning: "_POSIX_C_SOURCE" redefined In file included from /usr/include/limits.h:26, from /usr/local/gcc-alt-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/include/limits. h:132, from /usr/local/gcc-alt-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/include/syslimi ts.h:7, from /usr/local/gcc-alt-3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/include/limits. h:11, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python/detail/wrap_python.hpp:27, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python/detail/prefix.hpp:13, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python/args.hpp:9, from /afs/cern.ch/sw/lcg/external/Boost/1.31.0-python233/rh73_gcc32/include/b oost-1_31/boost/python.hpp:12, from test.cpp:1: /usr/include/features.h:131:1: warning: this is the location of the previous definition ------------------------------------------------------------ Pere Mato CERN, PH Department, CH 1211 Geneva 23, Switzerland e-mail: Pere.Mato at cern.ch tel: +41 22 76 78696 fax: +41 22 76 79425 gsm: +41 76 48 70855 From dave at boost-consulting.com Mon Jun 7 22:27:00 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 07 Jun 2004 16:27:00 -0400 Subject: [C++-sig] Re: problems compiling simple example in boost-python documentation/tutorial... References: <6.1.0.6.0.20040607092433.026648c0@pop-tech.intec.UGent.be> Message-ID: Peter Vandersteegen writes: > Hello, As a boost-python beginner I've started exploring the > tutorial. I however had trouble compiling a very basic example from > the tutorial: > http://www.boost.org/libs/python/doc/tutorial/doc/virtual_functions_with_default_implementations.html > Changing some lines in the tutorial code however solved the > compiling problem. Now my question is: Does this relate to my > compiler: intel 7.1, msvc7.0? Or something I overlooked in my code? > I've started with a pure virtual base class, and indeed the virtual > function can be overriden in python and called with a function in > c++ ... (fantastic :) ) No problems at all... I recieve however > compiler-errors (explained after program) when I however try to > compile the exact example from the tutorial ...(see link and > following text) The problem is that Boost.Python is trying to export Base's copy ctor for wrapping return-by-value functions. THat's why your addition of noncopyable works. Actually it seems like you've got everything figured out below. BTW, it would be good nettiquette to leave a blank line between the paragraphs of your postings. > // file wraptestpoly.cpp > #include > > using namespace boost::python; > > struct Base > { > virtual int f(void){return 0;} > }; //* > > int call_f(Base& b) { return b.f(); } > > > struct BaseWrap : Base > { > BaseWrap(PyObject* self_) > : self(self_) {} > virtual int f() { return call_method(self, "f"); } > int default_f() { return Base::f(); } > PyObject* self; > }; > > BOOST_PYTHON_MODULE(wraptestpoly){ > > class_("Base") //*1 > .def("f", &Base::f, &BaseWrap::default_f) > def("call_f", call_f); > } > //end file > The error I recieve is: > D:\libraries\boost_1_31_0\boost/python/object/value_holder.hpp(134): > error: no instance of constructor "BaseWrap::BaseWrap" matches the > argument list argument types are: (PyObject *, > boost::reference_wrapper::type) > > If I however use > class_("Base") > instead of //*1 --> no compiling problems. > Another option which works is adding a copy-constructor: > BaseWrap(PyObject* self_, Base const& copy) : Base(copy), self(self_) {} > in the wrapperclass. > Now my question is: what did I do wrong with this simple example? > Could this problem arise from an outdated tutorial? The tutorial example isn't outdated - it never worked. We've seen about 1 problem per month with the tutorial examples since the tutorial came out. Joel, why don't you make test cases for each of them and put them in the regression test suite? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From dave at boost-consulting.com Mon Jun 7 22:32:13 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 07 Jun 2004 16:32:13 -0400 Subject: [C++-sig] Re: Tedious Newbie Question References: <176AB0A0ADC4734B8FE888D53E75D9D5017EB1F1@s15shefsrv.zoodigitalgroup.com> Message-ID: Gareth Simpson writes: > Apologies in advance if this is not the list to be asking these sort of > things. This is exactly the right list. > I am trying to use Boost.Python to embed a Python library into my C++ > application. The library in question uses unicode strings internally and I > can't for the life of me work out how to get them out and into my C++. > Google is largely silent on the matter. > > The below code snippet shows what I'm trying to do. > > I have no problem using extract<> to get a python string into a std::string > but trying the same thing with unicode python strings and std::wstrings > throws an exception. > > Clearly I'm going about it the wrong way - what should I be doing? Probably you need to be using a newer version of Boost; we've supported wstring conversions since Boost 1.31.0. But we don't support Py_Finalize(); see http://www.boost.org/libs/python/todo.html#pyfinalize-safety > Thanks in advance > > Gareth > > > > > > #include "stdafx.h" > > #include "boost/python.hpp" > > int _tmain(int argc, _TCHAR* argv[]) > { > using namespace boost::python; > Py_Initialize(); > > object mainModule (borrowed(PyImport_AddModule("__main__"))); > object mainNamespace = mainModule.attr("__dict__"); > > handle<>(PyRun_String( > "str1 = 'a string'\n" // a simple string > "str2 = u'a unicode string'\n", // a unicode string > Py_file_input , mainNamespace.ptr(), mainNamespace.ptr() )); > > std::string str1 = extract(mainNamespace["str1"]); // > this works fine > std::wstring str2 = extract(mainNamespace["str2"]); > // boom! > > Py_Finalize(); > > return 0; > } -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From wstwej03 at sneakemail.com Tue Jun 8 01:28:33 2004 From: wstwej03 at sneakemail.com (Eric) Date: Mon, 7 Jun 2004 16:28:33 -0700 Subject: [C++-sig] wrapping a function that returns a FILE * In-Reply-To: <911F8C8EB7A8084AAEDD55CEDC54D8F851FE2E@iggy.rockstarvancouver.com> Message-ID: <13267-06242@sneakemail.com> Following the suggestion found here: http://mail.python.org/pipermail/c++-sig/2002-October/002386.html I tried to wrap a function that returns a FILE * so that python would treat it as a builtin file object. However, it does not work. I get the following error: TypeError: No to_python (by-value) converter found for C++ type: struct _iobuf * I have also tried the variation found here: http://mail.python.org/pipermail/c++-sig/2002-October/002373.html but get then I get a segfault in python when I attempt to run the code that accesses the FILE * functions. Any further suggestions for things I can try? From joel at boost-consulting.com Tue Jun 8 03:47:21 2004 From: joel at boost-consulting.com (Joel de Guzman) Date: Tue, 08 Jun 2004 09:47:21 +0800 Subject: [C++-sig] Re: problems compiling simple example in boost-python documentation/tutorial... In-Reply-To: References: <6.1.0.6.0.20040607092433.026648c0@pop-tech.intec.UGent.be> Message-ID: <40C51AA9.8000200@boost-consulting.com> David Abrahams wrote: > The tutorial example isn't outdated - it never worked. We've seen > about 1 problem per month with the tutorial examples since the > tutorial came out. Joel, why don't you make test cases for each of > them and put them in the regression test suite? I will. In the meantime, I commited the fix to CVS. -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net From nick at rockstarvancouver.com Tue Jun 8 03:52:34 2004 From: nick at rockstarvancouver.com (Nick Trout) Date: Mon, 7 Jun 2004 18:52:34 -0700 Subject: [C++-sig] wrapping a function that returns a FILE * Message-ID: <911F8C8EB7A8084AAEDD55CEDC54D8F881FDA8@iggy.rockstarvancouver.com> > On Behalf Of Eric > but get then I get a segfault in python when I attempt to run the code > that > accesses the FILE * functions. > > Any further suggestions for things I can try? Which platform is this for? >From Python docs: Python/C API Reference Manual, 2. The Very High Level Layer: "Note also that several of these functions take FILE* parameters. On particular issue which needs to be handled carefully is that the FILE structure for different C libraries can be different and incompatible. Under Windows (at least), it is possible for dynamically linked extensions to actually use different libraries, so care should be taken that FILE* parameters are only passed to these functions if it is certain that they were created by the same library that the Python runtime is using." There is a rift between .NET and the Python libraries. Nick From rwgk at yahoo.com Tue Jun 8 12:25:41 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 8 Jun 2004 03:25:41 -0700 (PDT) Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined In-Reply-To: <5BF9E41B6C9F2546B624F30FE840C122351BAF@cernxchg21.cern.ch> Message-ID: <20040608102541.67426.qmail@web20208.mail.yahoo.com> --- Pere Mato Vila wrote: > I am having the following compilation warnings when including > "boost/python.hpp". I am using Boost 1.31.0 Python 2.3.3 and gcc 3.2. Is > anything I am doing wrong? Due to a Python requirement the boost/python.hpp header has to be included before any system header. Please move the python.hpp include to the very top of your file. Let us know if it doesn't help. Ralf __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From g.simpson at zoo-tech.com Tue Jun 8 13:11:27 2004 From: g.simpson at zoo-tech.com (Gareth Simpson) Date: Tue, 8 Jun 2004 12:11:27 +0100 Subject: [C++-sig] Re: Tedious Newbie Question Message-ID: <176AB0A0ADC4734B8FE888D53E75D9D5017EB49A@s15shefsrv.zoodigitalgroup.com> > > > I am trying to use Boost.Python to embed a Python library > into my C++ > > application. The library in question uses unicode strings > internally and I > > can't for the life of me work out how to get them out and > into my C++. > > Google is largely silent on the matter. > > > > I have no problem using extract<> to get a python string > into a std::string > > but trying the same thing with unicode python strings and > std::wstrings > > throws an exception. > > > > Clearly I'm going about it the wrong way - what should I be doing? > > Probably you need to be using a newer version of Boost; we've > supported wstring conversions since Boost 1.31.0. That's the version of boost I have. It looks like it's trying to delete something it shouldn't (access violation) somewhere in the bowels of the STL / boost::python Interestingly if I go up the call stack to where the extract() is being called, the unicode string has actually arrived. > > But we don't support Py_Finalize(); see > http://www.boost.org/libs/python/todo.html#pyfinalize-safety > Ah, what should I do instead? From dave at boost-consulting.com Tue Jun 8 14:05:18 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 08 Jun 2004 08:05:18 -0400 Subject: [C++-sig] Re: Tedious Newbie Question References: <176AB0A0ADC4734B8FE888D53E75D9D5017EB49A@s15shefsrv.zoodigitalgroup.com> Message-ID: Gareth Simpson writes: >> >> > I am trying to use Boost.Python to embed a Python library >> into my C++ >> > application. The library in question uses unicode strings >> internally and I >> > can't for the life of me work out how to get them out and >> into my C++. >> > Google is largely silent on the matter. >> > >> > I have no problem using extract<> to get a python string >> into a std::string >> > but trying the same thing with unicode python strings and >> std::wstrings >> > throws an exception. >> > >> > Clearly I'm going about it the wrong way - what should I be doing? >> >> Probably you need to be using a newer version of Boost; we've >> supported wstring conversions since Boost 1.31.0. > > > That's the version of boost I have. > > It looks like it's trying to delete something it shouldn't (access > violation) somewhere in the bowels of the STL / boost::python Oh, in that case it's probably something in your own code that's causing the crash. > Interestingly if I go up the call stack to where the extract() > is being called, the unicode string has actually arrived. ;-) That should tell you something. >> >> But we don't support Py_Finalize(); see >> http://www.boost.org/libs/python/todo.html#pyfinalize-safety > > Ah, what should I do instead? Nothing; just don't call it. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From g.simpson at zoo-tech.com Tue Jun 8 14:39:10 2004 From: g.simpson at zoo-tech.com (Gareth Simpson) Date: Tue, 8 Jun 2004 13:39:10 +0100 Subject: [C++-sig] Re: Tedious Newbie Question Message-ID: <176AB0A0ADC4734B8FE888D53E75D9D5017EB4DF@s15shefsrv.zoodigitalgroup.com> > > > > It looks like it's trying to delete something it shouldn't (access > > violation) somewhere in the bowels of the STL / boost::python > > Oh, in that case it's probably something in your own code that's > causing the crash. > > > Interestingly if I go up the call stack to where the > extract() > > is being called, the unicode string has actually arrived. > > ;-) That should tell you something. > Bah, it's this. My bad. http://mail.python.org/pipermail/c++-sig/2004-May/007324.html From olivier.ravard at novagrid.com Tue Jun 8 14:26:12 2004 From: olivier.ravard at novagrid.com (Olivier Ravard) Date: Tue, 8 Jun 2004 14:26:12 +0200 Subject: [C++-sig] release compilation with bjam Message-ID: <006101c44d53$c979bf00$3d521481@ravard> Hi, I compiled boost.python under windows with mingw. I test some projects and it works fine. I build my own project with boost.build and it works but the compilation used only the debug release (linking). How should I do to compile with optimization and make a release in a non debug mode ? Thanks. O.R. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Pere.Mato at cern.ch Tue Jun 8 17:26:36 2004 From: Pere.Mato at cern.ch (Pere Mato Vila) Date: Tue, 8 Jun 2004 17:26:36 +0200 Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined Message-ID: <5BF9E41B6C9F2546B624F30FE840C1225FDB76@cernxchg21.cern.ch> My test program to show the problem contains only one line: #include "boost/python.hpp" and therefore I can not move it before anything. Pere > -----Original Message----- > From: c++-sig-bounces at python.org > [mailto:c++-sig-bounces at python.org] On Behalf Of Ralf W. > Grosse-Kunstleve > Sent: 08 June 2004 12:26 > To: Development of Python/C++ integration > Subject: Re: [C++-sig] warning: "_POSIX_C_SOURCE" redefined > > > --- Pere Mato Vila wrote: > > I am having the following compilation warnings when including > > "boost/python.hpp". I am using Boost 1.31.0 Python 2.3.3 > and gcc 3.2. > > Is anything I am doing wrong? > > Due to a Python requirement the boost/python.hpp header has > to be included before any system header. Please move the > python.hpp include to the very top of your file. Let us know > if it doesn't help. Ralf > > > > > > __________________________________ > Do you Yahoo!? > Friends. Fun. Try the all-new Yahoo! Messenger. > http://messenger.yahoo.com/ > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From nitin.shukla at pw.utc.com Tue Jun 8 17:33:47 2004 From: nitin.shukla at pw.utc.com (Shukla, Nitin (Export)) Date: Tue, 8 Jun 2004 11:33:47 -0400 Subject: [C++-sig] release compilation with bjam Message-ID: You should first build the Boost library in the release mode. To do that you should specify this command line argument "-sBUILD=release" while build Boost. Again when building you own project specify this command line argument to bjam and it would build the release version of your project. Make sure that in the jamfile you specify the to the release version of Boost.Python dll. HTH Nitin -----Original Message----- From: Olivier Ravard [mailto:olivier.ravard at novagrid.com] Sent: Tuesday, June 08, 2004 8:26 AM To: Development of Python/C++ integration Subject: [C++-sig] release compilation with bjam Hi, I compiled boost.python under windows with mingw. I test some projects and it works fine. I build my own project with boost.build and it works but the compilation used only the debug release (linking). How should I do to compile with optimization and make a release in a non debug mode ? Thanks. O.R. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave at boost-consulting.com Tue Jun 8 18:49:22 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 08 Jun 2004 12:49:22 -0400 Subject: [C++-sig] Re: release compilation with bjam References: Message-ID: "Shukla, Nitin (Export)" writes: > You should first build the Boost library in the release mode. To do that you > should specify this command line argument "-sBUILD=release" while build > Boost. Again when building you own project specify this command line > argument to bjam and it would build the release version of your project. > Make sure that in the jamfile you specify the to the release > version of Boost.Python dll. That's all correct, except that if you're using the Boost.Build example structure in libs/python/example, the appropriate Boost library will be built on demand. You don't need to separately build it first. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From olivier.ravard at novagrid.com Tue Jun 8 19:04:33 2004 From: olivier.ravard at novagrid.com (Olivier Ravard) Date: Tue, 8 Jun 2004 19:04:33 +0200 Subject: [C++-sig] Re: release compilation with bjam References: Message-ID: <00ff01c44d7a$ab98c040$3d521481@ravard> ----- Original Message ----- From: "David Abrahams" To: Sent: Tuesday, June 08, 2004 6:49 PM Subject: [C++-sig] Re: release compilation with bjam > "Shukla, Nitin (Export)" writes: > > > You should first build the Boost library in the release mode. To do that you > > should specify this command line argument "-sBUILD=release" while build > > Boost. Again when building you own project specify this command line > > argument to bjam and it would build the release version of your project. > > Make sure that in the jamfile you specify the to the release > > version of Boost.Python dll. > > That's all correct, except that if you're using the Boost.Build > example structure in libs/python/example, the appropriate Boost > library will be built on demand. You don't need to separately build > it first. > It works. Thanks. O.R. > -- > Dave Abrahams > Boost Consulting > http://www.boost-consulting.com > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig From nicodemus at esss.com.br Wed Jun 9 01:15:17 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Tue, 08 Jun 2004 20:15:17 -0300 Subject: [C++-sig] Pyste exception handlers In-Reply-To: <40BFF93D.7030506@paradise.net.nz> References: <40BFF93D.7030506@paradise.net.nz> Message-ID: <40C64885.1080009@esss.com.br> Hi Paul, paul.bridger wrote: > Nicodemus, > > How would you recommend exception handler registration be implemented > in Pyste? > > A problem here would be what to do in the differing cases of: > - building a single pyste file into a module > : in this case specifying exception handlers in the pyste file is > sufficient > - building many pyste files into a single module > : in this case you probably want exception handlers to be specified in > a module-level file, or perhaps you could put them in an arbitrary > pyste file > > I think Pyste has some deficiencies in organising modules from > multiple files. It is wonderful that this can be done, but I don't > like that so much has to be specified on the command-line (and that > the meaning of command-line options changes depending on --multiple or > not). > > I think a better organisation would involve a module-level file, which > could then contain such things as exception handlers. This would also > make building modules out of several pyste files cleaner. (A > disadvantage is that it expands the scope of the tool into something > of a build tool). > What do others think? I'm not ignoring you, it's just that I haven't found time to answer this message... I hope I will be to answer it in the next few days. Thanks! Nicodemus. From paul.bridger at paradise.net.nz Wed Jun 9 02:07:38 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Wed, 09 Jun 2004 12:07:38 +1200 Subject: [C++-sig] Pyste exception handlers In-Reply-To: <40C64885.1080009@esss.com.br> References: <40BFF93D.7030506@paradise.net.nz> <40C64885.1080009@esss.com.br> Message-ID: <40C654CA.9010600@paradise.net.nz> Sweet. I'm not sulkily not using Pyste anymore, just fighting off a computer game addiction. :) Paul. Nicodemus wrote: > Hi Paul, > > paul.bridger wrote: > >> Nicodemus, >> >> How would you recommend exception handler registration be implemented >> in Pyste? >> >> A problem here would be what to do in the differing cases of: >> - building a single pyste file into a module >> : in this case specifying exception handlers in the pyste file is >> sufficient >> - building many pyste files into a single module >> : in this case you probably want exception handlers to be specified in >> a module-level file, or perhaps you could put them in an arbitrary >> pyste file >> >> I think Pyste has some deficiencies in organising modules from >> multiple files. It is wonderful that this can be done, but I don't >> like that so much has to be specified on the command-line (and that >> the meaning of command-line options changes depending on --multiple or >> not). >> >> I think a better organisation would involve a module-level file, which >> could then contain such things as exception handlers. This would also >> make building modules out of several pyste files cleaner. (A >> disadvantage is that it expands the scope of the tool into something >> of a build tool). >> What do others think? > > > > I'm not ignoring you, it's just that I haven't found time to answer this > message... I hope I will be to answer it in the next few days. > > Thanks! > Nicodemus. > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > > From jeff.holle at verizon.net Tue Jun 8 15:35:56 2004 From: jeff.holle at verizon.net (Jeff Holle) Date: Tue, 08 Jun 2004 09:35:56 -0400 Subject: [C++-sig] Forward References Message-ID: <40C5C0BC.6020203@verizon.net> I want to express this issue to pyste users. With a class that uses forward references to express things like bi-directional assocition, it is necessary to add line in the associated pyste configure file like: declaration_code('#include "MyClass.h"\n') If this isn't done, the compiler errors, with at least gcc, aren't very helpful. From shin1_morita at yahoo.co.jp Wed Jun 9 16:09:22 2004 From: shin1_morita at yahoo.co.jp (Shin-ichi MORITA) Date: Wed, 9 Jun 2004 23:09:22 +0900 (JST) Subject: [C++-sig] call_f(Derived) did not match C++ signature Message-ID: <20040609140922.46979.qmail@web2302.mail.yahoo.co.jp> Hi, this is my first post. I've just started learning Boost.Python. I want to expose C++ abstract class and function that receives its instance like this example in the tutorial: http://boost.org/libs/python/doc/tutorial/doc/class_virtual_functions.html But I have a problem ... I compiled this example as module foo and ran test_foo.py attached to this mail. Then I had following errors: ====== BEGIN OUTPUT ====== ***************************************************************** Failure in example: foo.call_f(a) from line #9 of test_foo Exception raised: Traceback (most recent call last): File "/home/shin/.local/lib/python2.3/doctest.py", line 442, in _run_examples_inner compileflags, 1) in globs File "", line 1, in ? ArgumentError: Python argument types in foo.call_f(Derived) did not match C++ signature: call_f(Base {lvalue}) ***************************************************************** 1 items had failures: 1 of 4 in test_foo ***Test Failed*** 1 failures. EXIT STATUS: 1 ====== END OUTPUT ====== What's wrong? Thanks. __________________________________________________ Do You Yahoo!? http://bb.yahoo.co.jp/ -------------- next part -------------- A non-text attachment was scrubbed... Name: foo.cc Type: application/octet-stream Size: 411 bytes Desc: foo.cc URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test_foo.py Type: application/octet-stream Size: 370 bytes Desc: test_foo.py URL: From aashish at iastate.edu Wed Jun 9 16:52:11 2004 From: aashish at iastate.edu (aashish at iastate.edu) Date: Wed, 9 Jun 2004 09:52:11 -0500 (CDT) Subject: [C++-sig] call_f(Derived) did not match C++ signature In-Reply-To: <20040609140922.46979.qmail@web2302.mail.yahoo.co.jp> References: <20040609140922.46979.qmail@web2302.mail.yahoo.co.jp> Message-ID: <3061.129.186.232.105.1086792731.squirrel@mail.eng.iastate.edu> I think what you are doing wrong is instead of passing the object of Derived you are passing the class itself do this: from test_foo import * class Derived(Base): def f(self): return 42 derived = Derived() print derived.f() print call_f(derived) ------------------------------------ and in C++ #include using namespace boost::python; struct Base{ virtual int f() = 0; }; int call_f(Base& b) {return b.f();} struct BaseWrap : Base{ BaseWrap(PyObject* self_) : self(self_){} int f() { return call_method(self,"f") ;} PyObject* self; }; BOOST_PYTHON_MODULE(test_foo) { class_("Base") ; def("call_f", call_f); } --------------------------------- if you look carefull the call_f takes the ref to Base ... Hope this helps, ~aashish >/doc/class_virtual_functions.html > > But I have a problem ... > I compiled this example as module foo and ran test_foo.py > attached to this mail. > Then I had following errors: > > ====== BEGIN OUTPUT ====== > ***************************************************************** > Failure in example: foo.call_f(a) > from line #9 of test_foo > Exception raised: > Traceback (most recent call last): > File "/home/shin/.local/lib/python2.3/doctest.py", line > 442, in _run_examples_inner > compileflags, 1) in globs > File "", line 1, in ? > ArgumentError: Python argument types in > foo.call_f(Derived) > did not match C++ signature: > call_f(Base {lvalue}) > ***************************************************************** > 1 items had failures: > 1 of 4 in test_foo > ***Test Failed*** 1 failures. > > EXIT STATUS: 1 > ====== END OUTPUT ====== > > What's wrong? > Thanks. > > > > __________________________________________________ > Do You Yahoo!? > http://bb.yahoo.co.jp/ > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > ----------------------------------------------- Aashish Chaudhary | Email: Research Assistant | ashish_cy at yahoo.com Iowa State University | aashish at iastate.edu Ames, Iowa - USA | Ph: (515) 441-1178 ----------------------------------------------- From vmilitaru at sympatico.ca Wed Jun 9 13:54:31 2004 From: vmilitaru at sympatico.ca (Vio) Date: Wed, 09 Jun 2004 07:54:31 -0400 Subject: [C++-sig] importing embedded dynamic lib Message-ID: <40C6FA77.9080708@sympatico.ca> I have a basic dynamic lib "noddy.so" which I want to 1- embed inside my executable 2- import by embedded python interpreter using an API call. I have two questions: 1- what would be the recommended technique to embed a binary file inside an executable? My guess would be to add the binary "noddy.so" to the linking command, but then how do I get access to that chunk of code in my source file? My goal would be to achieve something like int* noddy_so = ... but then how do I include the binary code, or make the source code aware of it? Using "#include" doesn't feel right, as this is a binary file, not ASCII. And loading the file at run-time isn't right either, I need to load it at compile time. And is "int*" the appropriate data type for binary data? 2- Let's imagine that I managed to load "noddy.so" into my source code somehow, and now have a pointer to it. Any hints as to the correct python API call to import a dynamic lib from a memory buffer? Could someone tell me for example if the following makes sense for my purpose? ------------------------------ char *modulename="noddy", *filename="no_real_file"; PyObject *tmp; /*Here try to translate the binary lib into a PyObject*/ tmp = Py_CompileString(noddy_so, filename, Py_file_input); if (tmp == NULL) error("Can't compile module [tmp]"); /*Import the "noddy" module*/ pmod = PyImport_ExecCodeModule(modulename, tmp); if (pmod == NULL) error("Can't load module [pmod]"); ------------------------------ Regards, Vio From shin1_morita at yahoo.co.jp Wed Jun 9 18:11:23 2004 From: shin1_morita at yahoo.co.jp (Shin-ichi MORITA) Date: Thu, 10 Jun 2004 01:11:23 +0900 (JST) Subject: [C++-sig] call_f(Derived) did not match C++ signature In-Reply-To: <3061.129.186.232.105.1086792731.squirrel@mail.eng.iastate.edu> Message-ID: <20040609161123.71152.qmail@web2307.mail.yahoo.co.jp> > if you look carefull the call_f takes the ref to > Base ... Thanks, but I believe that I did almost exactly the same thing. Please check out my codes attached before ... I found the same report in The C++-sig Archives: http://mail.python.org/pipermail/c++-sig/2004-March/006988.html Is this already resolved? Anyone knows? By the way, this is my environment: gcc-3.2.3 and gcc-3.4.0 python-2.3.4 boost-1.31.0 __________________________________________________ Do You Yahoo!? http://bb.yahoo.co.jp/ From aherrman at mi.fu-berlin.de Wed Jun 9 18:11:26 2004 From: aherrman at mi.fu-berlin.de (aherrman at mi.fu-berlin.de) Date: Wed, 9 Jun 2004 18:11:26 +0200 Subject: [C++-sig] Survey of IDE users and source code editors Message-ID: <1086797486.40c736aee0c60@webmail.mi.fu-berlin.de> As part of a University study of Integrated Development Environment (IDE) users, we are conducting a survey to appraise the relative utility of different features of IDE source code editors, such as those included with Visual Studio and Eclipse as well as stand-alone editors like Emacs that support programming tasks. Our survey is designed to assess how often users employ editor features like syntax highlighting and code completion, and how satisfied users are with these features in their particular environments. If you or your project group have active experience using an IDE, we would like you to participate in our study. You can find the survey at http://physik.fu-berlin.de/~zabel/ide_editor_survey/ The survey should take no more than 20 minutes to complete. No personal information is required of participants. The survey period is two weeks (until June 22nd, 2004). Participants who opt to enter their e-mail addresses on the survey page will receive a copy of the findings of our study after the survey period. We look forward to hearing from you. Philipp Zabel, Minor Gordon and Antoinette Herrmann Freie Universitaet Berlin Institut fuer Informatik Takustr. 9 14195 Berlin From gwl at u.washington.edu Wed Jun 9 18:32:47 2004 From: gwl at u.washington.edu (Graeme Lufkin) Date: Wed, 09 Jun 2004 09:32:47 -0700 Subject: [C++-sig] importing embedded dynamic lib Message-ID: <1086798766.17992.23.camel@montague.astro.washington.edu> I've done this myself; let me try and explain what I did. First, write the extension module as normal. I used Boost.Python, but what's important is having access to the 'extern "C" void init()' function pointer. Second, instead of compiling your module into its own shared library (.so file), simply link it in with your executable. Using the Boost.Build system, you can just add the .cpp files that make up your module to the dependency list of the executable. Third, before you create the embedded interpreter, make a call to PyImport_AppendInittab(). For example, if my module is called funcs, the init function is declared as 'extern "C" void initfuncs();', so I call: PyImport_AppendInittab("funcs", initfuncs); then I call Py_Initialize(). Fourth, finally I can actually import the module into my embedded interpreter: PyRun_SimpleString("import funcs"); So, if you follow my steps, you have only one binary file, the executable. This file contains code for the module, as well as the regular C++ stuff of your program. You embed the Python interpreter, and import your module into its Python namespace. The embedding part of the Boost.Python tutorial is a bit lacking, and some of the code snippets won't compile, but give it a try anyway, as there's no other option ;) Hope this helps > I have a basic dynamic lib "noddy.so" which I want to > 1- embed inside my executable > 2- import by embedded python interpreter using an API call. > > I have two questions: > > 1- what would be the recommended technique to embed a binary file > inside > an executable? > My guess would be to add the binary "noddy.so" to the linking command, > but then > how do I get access to that chunk of code in my source file? My goal > would be to achieve something like > > int* noddy_so = ... but then how do I include the > binary code, or make the source code aware of it? > > Using "#include" doesn't feel right, as this is a binary file, not > ASCII. And loading the file at run-time isn't right either, I need to > load it at compile time. And is "int*" the appropriate data type for > binary data? > > 2- Let's imagine that I managed to load "noddy.so" into my source code > somehow, and now have a pointer to it. > Any hints as to the correct python API call to import a dynamic lib > from a memory buffer? Could someone > tell me for example if the following makes sense for my purpose? > > ------------------------------ > char *modulename="noddy", *filename="no_real_file"; > PyObject *tmp; > > /*Here try to translate the binary lib into a PyObject*/ > tmp = Py_CompileString(noddy_so, filename, Py_file_input); > if (tmp == NULL) > error("Can't compile module [tmp]"); > > /*Import the "noddy" module*/ > pmod = PyImport_ExecCodeModule(modulename, tmp); > if (pmod == NULL) > error("Can't load module [pmod]"); > ------------------------------ > > Regards, > Vio -- - Graeme gwl at u.washington.edu "This sentence contains exactly threee erors." From aashish at iastate.edu Wed Jun 9 18:40:25 2004 From: aashish at iastate.edu (aashish at iastate.edu) Date: Wed, 9 Jun 2004 11:40:25 -0500 (CDT) Subject: [C++-sig] call_f(Derived) did not match C++ signature In-Reply-To: <20040609161123.71152.qmail@web2307.mail.yahoo.co.jp> References: <3061.129.186.232.105.1086792731.squirrel@mail.eng.iastate.edu> <20040609161123.71152.qmail@web2307.mail.yahoo.co.jp> Message-ID: <3512.129.186.232.105.1086799225.squirrel@mail.eng.iastate.edu> Hi, Yes I did check your code. Sorry to say that I didnt check it before. Well its working on my environment: Windows XP Python 2.3 boost-1.31.0 I am not sure what the problem is. ~aashish > By the way, this is my environment: > > gcc-3.2.3 and gcc-3.4.0 > python-2.3.4 > boost-1.31.0 > > > __________________________________________________ > Do You Yahoo!? > http://bb.yahoo.co.jp/ > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > ----------------------------------------------- Aashish Chaudhary | Email: Research Assistant | ashish_cy at yahoo.com Iowa State University | aashish at iastate.edu Ames, Iowa - USA | Ph: (515) 441-1178 ----------------------------------------------- From dave at boost-consulting.com Wed Jun 9 20:06:40 2004 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 09 Jun 2004 14:06:40 -0400 Subject: [C++-sig] Re: call_f(Derived) did not match C++ signature References: <20040609140922.46979.qmail@web2302.mail.yahoo.co.jp> Message-ID: Shin-ichi MORITA writes: > Hi, this is my first post. > > I've just started learning Boost.Python. > I want to expose C++ abstract class and function that > receives its instance like this example in the tutorial: > > http://boost.org/libs/python/doc/tutorial/doc/class_virtual_functions.html > > But I have a problem ... > I compiled this example as module foo and ran test_foo.py > attached to this mail. > Then I had following errors: > > ====== BEGIN OUTPUT ====== > ***************************************************************** > Failure in example: foo.call_f(a) > from line #9 of test_foo > Exception raised: > Traceback (most recent call last): > File "/home/shin/.local/lib/python2.3/doctest.py", line > 442, in _run_examples_inner > compileflags, 1) in globs > File "", line 1, in ? > ArgumentError: Python argument types in > foo.call_f(Derived) ^^^^^^^ > did not match C++ signature: > call_f(Base {lvalue}) ^^^^ > ***************************************************************** > 1 items had failures: > 1 of 4 in test_foo > ***Test Failed*** 1 failures. > > EXIT STATUS: 1 > ====== END OUTPUT ====== > > What's wrong? Normally for me to help you, you'd need to post the code you used that caused the problem, but in this case I think it's pretty clear that when you wrapped Derived you didn't put bases in the class_< ... > argument list. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From rwgk at yahoo.com Wed Jun 9 21:10:02 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Wed, 9 Jun 2004 12:10:02 -0700 (PDT) Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined In-Reply-To: <5BF9E41B6C9F2546B624F30FE840C1225FDB76@cernxchg21.cern.ch> Message-ID: <20040609191002.30354.qmail@web20211.mail.yahoo.com> --- Pere Mato Vila wrote: > My test program to show the problem contains only one line: > > #include "boost/python.hpp" > > and therefore I can not move it before anything. Hm. What is your platform? Linux (which), Cygwin? > > -----Original Message----- > > From: c++-sig-bounces at python.org > > [mailto:c++-sig-bounces at python.org] On Behalf Of Ralf W. > > Grosse-Kunstleve > > Sent: 08 June 2004 12:26 > > To: Development of Python/C++ integration > > Subject: Re: [C++-sig] warning: "_POSIX_C_SOURCE" redefined > > > > > > --- Pere Mato Vila wrote: > > > I am having the following compilation warnings when including > > > "boost/python.hpp". I am using Boost 1.31.0 Python 2.3.3 > > and gcc 3.2. > > > Is anything I am doing wrong? > > > > Due to a Python requirement the boost/python.hpp header has > > to be included before any system header. Please move the > > python.hpp include to the very top of your file. Let us know > > if it doesn't help. Ralf > > > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Friends. Fun. Try the all-new Yahoo! Messenger. > > http://messenger.yahoo.com/ > > > > _______________________________________________ > > C++-sig mailing list > > C++-sig at python.org > > http://mail.python.org/mailman/listinfo/c++-sig > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From phil at freehackers.org Wed Jun 9 21:57:02 2004 From: phil at freehackers.org (Philippe Fremy) Date: Wed, 9 Jun 2004 21:57:02 +0200 Subject: [C++-sig] multiple to_python converters ? Message-ID: <200406092157.02366.phil@freehackers.org> Hi, I have the case where I have two python modules, both declaring the same to_python converter. The modules may be used separately or together. The problem is that if used together, I get (you see me coming I guess) a RunTimeError. Only one to_python converter may be registerted at a time for a given type. I looked in the archives and on google. I saw two references to discussions of this problem and even a possible solution to be included in boost. But checking the documentation today, I could not find any hint on how to solve this problem. So, is the problem still here ? regards, Philippe -- An open source OS for contactless Smart Cards http://www.jayacard.org - Jayacard From vmilitaru at sympatico.ca Wed Jun 9 22:16:16 2004 From: vmilitaru at sympatico.ca (Vio) Date: Wed, 09 Jun 2004 16:16:16 -0400 Subject: [C++-sig] importing embedded dynamic lib Message-ID: <40C77010.8000505@sympatico.ca> Many thanks for your solution Graeme. Unfortunately, I do need to use ".so" files as I want to "extend dynamically" an embedded python interpreter, skipping recompile each time. Yes, I've tried both Boost and SWIG to generate wrappers, but right now I like to do things "manually" to understand what's going on "under the hood". More details: Imagine a situation where the ".so" files are delivered through a network; the easy solution would be to save the downloaded binary stream as a ".so" file to disk, then simply run the python command "import " and I'm done. But I simply wish to avoid the "save to disk" step which seems superfluous in this case, and feed the binary lib directly to the embedded python interpreter. Exploring the API docs, it would seem that something like PyRun_AnyFile(FILE *fp, char *filename) could do what I want. But I don't know if/how I can give it a memory buffer instead of a FILE pointer, and also I'm too much of a c/c++ newbie right now to figure out how to handle huge binary data (as I write this, I'm trying to make sense of Stroustrup's C++ bible "the c++ prog. lang, ed. 2000"), so a simple task like putting contents of a ".so" file into a memory buffer is a big challenge for me right now. Anyway, thanks for your help, Vio > I've done this myself; let me try and explain what I did. First, write >the extension module as normal. I used Boost.Python, but what's >important is having access to the 'extern "C" void >init()' function pointer. >Second, instead of compiling your module into its own shared library >(.so file), simply link it in with your executable. Using the >Boost.Build system, you can just add the .cpp files that make up your >module to the dependency list of the executable. >Third, before you create the embedded interpreter, make a call to >PyImport_AppendInittab(). For example, if my module is called funcs, >the init function is declared as 'extern "C" void initfuncs();', so I >call: >PyImport_AppendInittab("funcs", initfuncs); >then I call Py_Initialize(). >Fourth, finally I can actually import the module into my embedded >interpreter: >PyRun_SimpleString("import funcs"); > > So, if you follow my steps, you have only one binary file, the >executable. This file contains code for the module, as well as the >regular C++ stuff of your program. You embed the Python interpreter, >and import your module into its Python namespace. > The embedding part of the Boost.Python tutorial is a bit lacking, and >some of the code snippets won't compile, but give it a try anyway, as >there's no other option ;) > Hope this helps > >>/ I have a basic dynamic lib "noddy.so" which I want to >/>/ 1- embed inside my executable >/>/ 2- import by embedded python interpreter using an API call. >/>/ >/>/ I have two questions: >/>/ >/>/ 1- what would be the recommended technique to embed a binary file >/>/ inside >/>/ an executable? >/>/ My guess would be to add the binary "noddy.so" to the linking command, >/>/ but then >/>/ how do I get access to that chunk of code in my source file? My goal >/>/ would be to achieve something like >/>/ >/>/ int* noddy_so = ... but then how do I include the >/>/ binary code, or make the source code aware of it? >/>/ >/>/ Using "#include" doesn't feel right, as this is a binary file, not >/>/ ASCII. And loading the file at run-time isn't right either, I need to >/>/ load it at compile time. And is "int*" the appropriate data type for >/>/ binary data? >/>/ >/>/ 2- Let's imagine that I managed to load "noddy.so" into my source code >/>/ somehow, and now have a pointer to it. >/>/ Any hints as to the correct python API call to import a dynamic lib >/>/ from a memory buffer? Could someone >/>/ tell me for example if the following makes sense for my purpose? >/>/ >/>/ ------------------------------ >/>/ char *modulename="noddy", *filename="no_real_file"; >/>/ PyObject *tmp; >/>/ >/>/ /*Here try to translate the binary lib into a PyObject*/ >/>/ tmp = Py_CompileString(noddy_so, filename, Py_file_input); >/>/ if (tmp == NULL) >/>/ error("Can't compile module [tmp]"); >/>/ >/>/ /*Import the "noddy" module*/ >/>/ pmod = PyImport_ExecCodeModule(modulename, tmp); >/>/ if (pmod == NULL) >/>/ error("Can't load module [pmod]"); >/>/ ------------------------------ >/ > From grafik.list at redshift-software.com Thu Jun 10 01:37:25 2004 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 09 Jun 2004 18:37:25 -0500 Subject: [C++-sig] importing embedded dynamic lib In-Reply-To: <40C77010.8000505@sympatico.ca> References: <40C77010.8000505@sympatico.ca> Message-ID: <40C79F35.5080708@redshift-software.com> Vio wrote: > More details: Imagine a situation where the ".so" files are delivered > through > a network; the easy solution would be to save the downloaded binary stream > as a ".so" file to disk, > then simply run the python command "import " and I'm done. > But I simply wish to avoid the "save to disk" step which seems > superfluous in this > case, and feed the binary lib directly to the embedded python interpreter. If I'm understanding you correctly you want to load a dynamic library straight from a stream, instead of from a file? If that's the case unless you decide you want to undertake rewriting the dynamic loader you won't be able to do it. The dlopen call, which is what loads the .so in Linux and others, doesn't support that. About the best you could try is to create a temporary pipe and feed the stream into that, and give the pipe to dlopen. But I would bet it's not going to work as the dynamic loader is likely to require random access to the data. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq From s_sourceforge at nedprod.com Thu Jun 10 04:17:41 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Thu, 10 Jun 2004 03:17:41 +0100 Subject: [C++-sig] importing embedded dynamic lib In-Reply-To: <40C77010.8000505@sympatico.ca> Message-ID: <40C7D2D5.11462.75838EA@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 9 Jun 2004 at 16:16, Vio wrote: > More details: Imagine a situation where the ".so" files are delivered > through a network; the easy solution would be to save the downloaded > binary stream as a ".so" file to disk, then simply run the python > command "import " and I'm done. But I simply wish to avoid > the "save to disk" step which seems superfluous in this case, and feed > the binary lib directly to the embedded python interpreter. Why don't you just mount the remote file system (SMB or NFS) and run via that? I personally develop on Linux and FreeBSD using a source tree on a Windows share on a Win2k machine. It's a little slow, but it's manageable. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQMfExcEcvDLFGKbPEQJZRQCg8OTo23lq6YtAY41rddFiPIecgPoAoJ22 zqAulJvda5rIZkglBEWseO92 =oaxw -----END PGP SIGNATURE----- From vmilitaru at sympatico.ca Thu Jun 10 02:17:45 2004 From: vmilitaru at sympatico.ca (Vio) Date: Wed, 09 Jun 2004 20:17:45 -0400 Subject: [C++-sig] importing embedded dynamic lib Message-ID: <40C7A8A9.5050400@sympatico.ca> Perhaps I didn't explain myself correctly. My question would come down to: *what API call* does the python interpreter use when I type at the python prompt: >>> import mysharedlib where "mysharedlib" is file "mysharedlib.so" somewhere on the PYTHONPATH. What I wish is to use *that* call, but change arguments as to substitute to the [my guess] file pointer for a memory buffer pointer. The memory buffer having the exact contents of file "mysharedlib.so", thus avoiding a disk access. While the result here is not very sexy, this exercise becomes interesting when the app receives "mysharedlib.so" over the network. Once received over network, easy solution is to write "mysharedlib.so" to local disk, then either do something like: PyRun_SimpleString("import mysharedlib") or PyImport_ImportModule("mysharedlib") I simply want to skip that. In still other words, I guess I'm looking for something like PyImport_ExecCodeModule(char *name, PyObject *co) only I'd have to construct a PyObject out of my buffer, since that's what PyImport_ExecCodeModule() wants as 2nd argument. But API docs say this 2nd argument should be python bytecode data, so I don't know if it won't choke on compiled ELF binaries instead, hence I'm not too sure about this particular hack. Anyway, my gut guess is that I must find what calls python uses to import shared libs, and somehow use that and substitute that file pointer to my buffer pointer. Just a wild guess. If someone has some ideas on this, I'd appreciate it. Vio From grafik.list at redshift-software.com Thu Jun 10 05:51:57 2004 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 09 Jun 2004 22:51:57 -0500 Subject: [C++-sig] importing embedded dynamic lib In-Reply-To: <40C7A8A9.5050400@sympatico.ca> References: <40C7A8A9.5050400@sympatico.ca> Message-ID: <40C7DADD.2080907@redshift-software.com> Vio wrote: > Perhaps I didn't explain myself correctly. My question would come down to: > *what API call* > does the python interpreter use when I type at the python prompt: > > >>> import mysharedlib > > where "mysharedlib" is file "mysharedlib.so" somewhere on the PYTHONPATH. Like I said before it uses dlopen and related OS functions, see: http://www.die.net/doc/linux/include/dlfcn.h http://www.die.net/doc/linux/man/man3/dlopen.3.html http://www.die.net/doc/linux/man/man3/dlsym.3.html http://www.die.net/doc/linux/man/man3/dlclose.3.html Or go to your Linux shell and type "man dlopen". > What I wish is to use *that* call, but change arguments as to substitute > to the [my guess] file pointer for a memory buffer pointer. You can not. Unless you write a different *dynamic linker loader* (ld.so), see: http://www.die.net/doc/linux/man/man8/ld.so.8.html [snip] > PyImport_ExecCodeModule(char *name, PyObject *co) > > only I'd have to construct a PyObject out of my buffer, since that's what > PyImport_ExecCodeModule() wants as 2nd argument. But API docs say this 2nd > argument should be python bytecode data, so I don't know if it won't > choke on > compiled ELF binaries instead, hence I'm not too sure about this > particular hack. It will not work. Python doesn't load ELF, it only loads Python code. It's the *operating system* which is loading the ELF. [snip] > Just a wild guess. Very wild ;-) And like my sig below says... Don't assume.. that things work they way you want them to work. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq From vmilitaru at sympatico.ca Thu Jun 10 02:53:32 2004 From: vmilitaru at sympatico.ca (Vio) Date: Wed, 09 Jun 2004 20:53:32 -0400 Subject: [C++-sig] importing embedded dynamic lib Message-ID: <40C7B10C.7040701@sympatico.ca> followup... I think what I'm looking for is "PyCObject_Import()", which I found in wxPython.h ------------------------ // This needs to be called in modules that make calls to any of the functions // exported by the wxPython API. It sets a static pointer to a structure of // function pointers located in the wx._core extension module. static void wxPyCoreAPI_IMPORT() { wxPyCoreAPIPtr = (wxPyCoreAPI*)PyCObject_Import("wx._core", "_wxPyCoreAPI"); if (! wxPyCoreAPIPtr) wxPyCoreAPIPtr = (wxPyCoreAPI*)PyCObject_Import("_core", "_wxPyCoreAPI"); } ------------------------ wx._core referred here is file "_core.so". Unfortunately, PyCObject_Import() does not seem to be documented in the Python API docs. More digging required... Vio From vmilitaru at sympatico.ca Thu Jun 10 03:30:47 2004 From: vmilitaru at sympatico.ca (Vio) Date: Wed, 09 Jun 2004 21:30:47 -0400 Subject: [C++-sig] importing embedded dynamic lib Message-ID: <40C7B9C7.90004@sympatico.ca> > > >It will not work. Python doesn't load ELF, it only loads Python code. >It's the *operating system* which is loading the ELF. > I *finally* got it. (with convincing args from python sources) >-- Grafik - Don't Assume Anything > But then that's why we're called newbies, as long as we don't understand how the world turns, we assume Elvis still lives. Thanks for your help! Vio From grafik.list at redshift-software.com Thu Jun 10 06:45:26 2004 From: grafik.list at redshift-software.com (Rene Rivera) Date: Wed, 09 Jun 2004 23:45:26 -0500 Subject: [C++-sig] importing embedded dynamic lib In-Reply-To: <40C7B9C7.90004@sympatico.ca> References: <40C7B9C7.90004@sympatico.ca> Message-ID: <40C7E766.8070402@redshift-software.com> Vio wrote: >> -- Grafik - Don't Assume Anything >> > But then that's why we're called newbies, as long as we don't understand > how > the world turns, we assume Elvis still lives. Of course Elvis Costello lives ;-) > Thanks for your help! Your welcome. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq From Pere.Mato at cern.ch Thu Jun 10 09:35:31 2004 From: Pere.Mato at cern.ch (Pere Mato Vila) Date: Thu, 10 Jun 2004 09:35:31 +0200 Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined Message-ID: <5BF9E41B6C9F2546B624F30FE840C1225FDBBA@cernxchg21.cern.ch> Linux Redhad 7.3 with gcc 3.2 > -----Original Message----- > From: c++-sig-bounces at python.org > [mailto:c++-sig-bounces at python.org] On Behalf Of Ralf W. > Grosse-Kunstleve > Sent: 09 June 2004 21:10 > To: Development of Python/C++ integration > Subject: RE: [C++-sig] warning: "_POSIX_C_SOURCE" redefined > > > --- Pere Mato Vila wrote: > > My test program to show the problem contains only one line: > > > > #include "boost/python.hpp" > > > > and therefore I can not move it before anything. > > Hm. What is your platform? Linux (which), Cygwin? > > > > > -----Original Message----- > > > From: c++-sig-bounces at python.org > > > [mailto:c++-sig-bounces at python.org] On Behalf Of Ralf W. > > > Grosse-Kunstleve > > > Sent: 08 June 2004 12:26 > > > To: Development of Python/C++ integration > > > Subject: Re: [C++-sig] warning: "_POSIX_C_SOURCE" redefined > > > > > > > > > --- Pere Mato Vila wrote: > > > > I am having the following compilation warnings when including > > > > "boost/python.hpp". I am using Boost 1.31.0 Python 2.3.3 > > > and gcc 3.2. > > > > Is anything I am doing wrong? > > > > > > Due to a Python requirement the boost/python.hpp header has > > > to be included before any system header. Please move the > > > python.hpp include to the very top of your file. Let us know > > > if it doesn't help. Ralf > > > > > > > > > > > > > > > > > > __________________________________ > > > Do you Yahoo!? > > > Friends. Fun. Try the all-new Yahoo! Messenger. > > > http://messenger.yahoo.com/ > > > > > > _______________________________________________ > > > C++-sig mailing list > > > C++-sig at python.org > > > http://mail.python.org/mailman/listinfo/c++-sig > > > > > > > _______________________________________________ > > C++-sig mailing list > > C++-sig at python.org > > http://mail.python.org/mailman/listinfo/c++-sig > > > > > > __________________________________ > Do you Yahoo!? > Friends. Fun. Try the all-new Yahoo! Messenger. > http://messenger.yahoo.com/ > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From olivier.ravard at novagrid.com Thu Jun 10 13:15:32 2004 From: olivier.ravard at novagrid.com (Olivier Ravard) Date: Thu, 10 Jun 2004 13:15:32 +0200 Subject: [C++-sig] Compilation options Message-ID: <000c01c44edc$3f0c0320$3d521481@ravard> Hi, I compiled some modules with boost.build and mingw tool. How can I do to tell bjam to compile with the -O3 option ? Thanks. O.R. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave at boost-consulting.com Thu Jun 10 14:35:10 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 10 Jun 2004 08:35:10 -0400 Subject: [C++-sig] Re: Compilation options References: <000c01c44edc$3f0c0320$3d521481@ravard> Message-ID: "Olivier Ravard" writes: > Hi, > > I compiled some modules with boost.build and mingw tool. > How can I do to tell bjam to compile with the -O3 option ? > > Thanks. Are you sure you don't just want a full release build? bjam -sTOOLS=mingw -sBUILD=release If you really *only* want the -03 flag, bjam -sTOOLS=mingw "-sBUILD=-O3" but that's usually not what you want. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From olivier.ravard at novagrid.com Thu Jun 10 15:14:03 2004 From: olivier.ravard at novagrid.com (Olivier Ravard) Date: Thu, 10 Jun 2004 15:14:03 +0200 Subject: [C++-sig] Re: Compilation options References: <000c01c44edc$3f0c0320$3d521481@ravard> Message-ID: <002f01c44eec$cd8f5e70$3d521481@ravard> ----- Original Message ----- From: "David Abrahams" To: Sent: Thursday, June 10, 2004 2:35 PM Subject: [C++-sig] Re: Compilation options > "Olivier Ravard" writes: > > > Hi, > > > > I compiled some modules with boost.build and mingw tool. > > How can I do to tell bjam to compile with the -O3 option ? > > > > Thanks. > > Are you sure you don't just want a full release build? > > bjam -sTOOLS=mingw -sBUILD=release > > If you really *only* want the -03 flag, > > bjam -sTOOLS=mingw "-sBUILD=-O3" > > but that's usually not what you want. > In fact, I want a release build with the -O3 option... > > -- > Dave Abrahams > Boost Consulting > http://www.boost-consulting.com > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig From rwgk at yahoo.com Thu Jun 10 16:38:12 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 10 Jun 2004 07:38:12 -0700 (PDT) Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined In-Reply-To: <5BF9E41B6C9F2546B624F30FE840C1225FDBBA@cernxchg21.cern.ch> Message-ID: <20040610143812.99879.qmail@web20212.mail.yahoo.com> I can reproduce the warning... but only after removing the -w from the g++ command line. With g++ I am always compiling with -w because I get useless warnings otherwise that I cannot disable with other switches. I rely on EDG compilers to check my code for standard conformance; for this purpose the EDG compilers generally do a much better job than g++. If you don't want to use -w (I don't know how to tell bjam to insert the -w) you have to analyze how exactly the conflicting definitions of _POSIX_C_SOURCE come about. Maybe we can do something with #ifdef in the right places. However, I doubt it is worth the effort unless you can demonstrate the same problem on a more recent platform with a more recent compiler. Ralf --- Pere Mato Vila wrote: > Linux Redhad 7.3 with gcc 3.2 > > > > -----Original Message----- > > From: c++-sig-bounces at python.org > > [mailto:c++-sig-bounces at python.org] On Behalf Of Ralf W. > > Grosse-Kunstleve > > Sent: 09 June 2004 21:10 > > To: Development of Python/C++ integration > > Subject: RE: [C++-sig] warning: "_POSIX_C_SOURCE" redefined > > > > > > --- Pere Mato Vila wrote: > > > My test program to show the problem contains only one line: > > > > > > #include "boost/python.hpp" > > > > > > and therefore I can not move it before anything. > > > > Hm. What is your platform? Linux (which), Cygwin? > > > > > > > > -----Original Message----- > > > > From: c++-sig-bounces at python.org > > > > [mailto:c++-sig-bounces at python.org] On Behalf Of Ralf W. > > > > Grosse-Kunstleve > > > > Sent: 08 June 2004 12:26 > > > > To: Development of Python/C++ integration > > > > Subject: Re: [C++-sig] warning: "_POSIX_C_SOURCE" redefined > > > > > > > > > > > > --- Pere Mato Vila wrote: > > > > > I am having the following compilation warnings when including > > > > > "boost/python.hpp". I am using Boost 1.31.0 Python 2.3.3 > > > > and gcc 3.2. > > > > > Is anything I am doing wrong? > > > > > > > > Due to a Python requirement the boost/python.hpp header has > > > > to be included before any system header. Please move the > > > > python.hpp include to the very top of your file. Let us know > > > > if it doesn't help. Ralf __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From shin1_morita at yahoo.co.jp Thu Jun 10 17:19:41 2004 From: shin1_morita at yahoo.co.jp (Shin-ichi MORITA) Date: Fri, 11 Jun 2004 00:19:41 +0900 (JST) Subject: [C++-sig] Re: call_f(Derived) did not match C++ signature In-Reply-To: Message-ID: <20040610151941.77721.qmail@web2306.mail.yahoo.co.jp> > Normally for me to help you, you'd need to post the > code you used that I attached the code to my first posting ... But next time I would write code in the message. > caused the problem, but in this case I think it's > pretty clear that > when you wrapped Derived you didn't put bases > in the > class_< ... > argument list. No, I din not wrap "Derived". "Derived" is defined in python code. Writing this, I've just found the cause. I exposed in foo.cc: > -- > Dave Abrahams > Boost Consulting > http://www.boost-consulting.com __________________________________________________ Do You Yahoo!? http://bb.yahoo.co.jp/ From Paul_Kunz at slac.stanford.edu Thu Jun 10 17:46:04 2004 From: Paul_Kunz at slac.stanford.edu (Paul F. Kunz) Date: Thu, 10 Jun 2004 08:46:04 -0700 Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined In-Reply-To: <20040610143812.99879.qmail@web20212.mail.yahoo.com> (rwgk@yahoo.com) References: <20040610143812.99879.qmail@web20212.mail.yahoo.com> Message-ID: <200406101546.i5AFk4C24429@libra3.slac.stanford.edu> >>>>> On Thu, 10 Jun 2004 07:38:12 -0700 (PDT), "Ralf W. Grosse-Kunstleve" said: > If you don't want to use -w (I don't know how to tell bjam to insert > the -w) you have to analyze how exactly the conflicting definitions > of _POSIX_C_SOURCE come about. Maybe we can do something with #ifdef > in the right places. However, I doubt it is worth the effort unless > you can demonstrate the same problem on a more recent platform with > a more recent compiler. I see the same warning with Red Hat Linux 9 and gcc 3.4.0. Is that recent enough? Also see them when I build boost 1.31.0 with bjam. From tbm at esperanto.org Fri Jun 11 05:40:16 2004 From: tbm at esperanto.org (tbm at esperanto.org) Date: Fri, 11 Jun 2004 03:40:16 +0000 Subject: [C++-sig] software In-Reply-To: <5E595638E4887FJG@python.org> References: <5E595638E4887FJG@python.org> Message-ID: <04AL1E4G9H00HA0K@esperanto.org> Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://GNNDJA.biz/OE017/?affiliate_id=233763&campaign_id=601 uns * ub - scribe http://FKEFCK.biz/diamondtron.php?affiliate_id=233763&campaign_id=601 ekclrtpb juaxe cnrqzri edtbu dtbpfzu qcgi wxkgql ewor ogrhowj iyemq gexgyntf yecj kuwoqkt gqamhxy pvd elit iohyxlx cohmj d cbojt From shin1_morita at yahoo.co.jp Thu Jun 10 17:51:54 2004 From: shin1_morita at yahoo.co.jp (Shin-ichi MORITA) Date: Fri, 11 Jun 2004 00:51:54 +0900 (JST) Subject: [C++-sig] Re: call_f(Derived) did not match C++ signature Message-ID: <20040610155154.86156.qmail@web2307.mail.yahoo.co.jp> Sorry, I sent incomplete message. > Writing this, I've just found the cause. > I exposed Base in foo.cc: class_("Base", no_init); and defined Derived in test_foo.py: class Derived(Base): def __init__(self): pass # because I exposed with no_init. def f(self): return 42 This is wrong. Next I removed "no_init" and "__init__" above like this: class_("Base"); class Derived(Base): # Base.__init__ will be called. def f(self): return 42 Finally I got *passed*. Base.__init__ must be called to initialize Derived instance correctly, is this right? If so, I think that "no_init" is not for abstract base class, but just for only noncreatable class. Why dose this page in the tutorial uses "no_init" to explain abstract base class? http://boost.org/libs/python/doc/tutorial/doc/class_virtual_functions.html Thanks. __________________________________________________ Do You Yahoo!? http://bb.yahoo.co.jp/ From dave at boost-consulting.com Thu Jun 10 18:43:57 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 10 Jun 2004 12:43:57 -0400 Subject: [C++-sig] Re: Compilation options References: <000c01c44edc$3f0c0320$3d521481@ravard> <002f01c44eec$cd8f5e70$3d521481@ravard> Message-ID: "Olivier Ravard" writes: > ----- Original Message ----- > From: "David Abrahams" > To: > Sent: Thursday, June 10, 2004 2:35 PM > Subject: [C++-sig] Re: Compilation options > > >> "Olivier Ravard" writes: >> >> > Hi, >> > >> > I compiled some modules with boost.build and mingw tool. >> > How can I do to tell bjam to compile with the -O3 option ? >> > >> > Thanks. >> >> Are you sure you don't just want a full release build? >> >> bjam -sTOOLS=mingw -sBUILD=release >> >> If you really *only* want the -03 flag, >> >> bjam -sTOOLS=mingw "-sBUILD=-O3" >> >> but that's usually not what you want. >> > > In fact, I want a release build with the -O3 option... I believe the release build already uses -O3; you can add -d+2 to the beginning of the bjam command-line to check. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From dave at boost-consulting.com Thu Jun 10 18:45:35 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 10 Jun 2004 12:45:35 -0400 Subject: [C++-sig] Re: call_f(Derived) did not match C++ signature References: <20040610151941.77721.qmail@web2306.mail.yahoo.co.jp> Message-ID: Shin-ichi MORITA writes: >> Normally for me to help you, you'd need to post the >> code you used that > > I attached the code to my first posting ... I'm blind! Sorry! > But next time I would write code in the message. No, an attachment is fine, thanks. >> caused the problem, but in this case I think it's >> pretty clear that >> when you wrapped Derived you didn't put bases >> in the >> class_< ... > argument list. > > No, I din not wrap "Derived". > "Derived" is defined in python code. > > Writing this, I've just found the cause. > I exposed in foo.cc: ...continued -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From dave at boost-consulting.com Thu Jun 10 18:46:18 2004 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 10 Jun 2004 12:46:18 -0400 Subject: [C++-sig] Re: call_f(Derived) did not match C++ signature References: <20040610155154.86156.qmail@web2307.mail.yahoo.co.jp> Message-ID: Shin-ichi MORITA writes: > Sorry, I sent incomplete message. > >> Writing this, I've just found the cause. >> I exposed Base in foo.cc: > > class_("Base", > no_init); > > and defined Derived in test_foo.py: > > class Derived(Base): > def __init__(self): > pass # because I exposed with no_init. > def f(self): > return 42 > > This is wrong. > Next I removed "no_init" and "__init__" above like this: > > class_("Base"); > > class Derived(Base): > # Base.__init__ will be called. > def f(self): > return 42 > > Finally I got *passed*. > > Base.__init__ must be called to initialize Derived > instance correctly, is this right? Correct. > If so, I think that "no_init" is not for abstract base > class, but just for only noncreatable class. Correct, though I hope to fix that one day. > > Why dose this page in the tutorial uses "no_init" to > explain abstract base class? > http://boost.org/libs/python/doc/tutorial/doc/class_virtual_functions.html Because it's wrong, I guess :( -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From shin1_morita at yahoo.co.jp Thu Jun 10 19:16:12 2004 From: shin1_morita at yahoo.co.jp (Shin-ichi MORITA) Date: Fri, 11 Jun 2004 02:16:12 +0900 (JST) Subject: [C++-sig] Re: call_f(Derived) did not match C++ signature In-Reply-To: Message-ID: <20040610171612.39624.qmail@web2301.mail.yahoo.co.jp> Thanks David, ~aashish, and every one. Now my problem has been resolved :-) __________________________________________________ Do You Yahoo!? http://bb.yahoo.co.jp/ From rwgk at yahoo.com Thu Jun 10 19:59:31 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 10 Jun 2004 10:59:31 -0700 (PDT) Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined In-Reply-To: <200406101546.i5AFk4C24429@libra3.slac.stanford.edu> Message-ID: <20040610175931.74078.qmail@web20206.mail.yahoo.com> --- "Paul F. Kunz" wrote: > >>>>> On Thu, 10 Jun 2004 07:38:12 -0700 (PDT), "Ralf W. Grosse-Kunstleve" > said: > > > If you don't want to use -w (I don't know how to tell bjam to insert > > the -w) you have to analyze how exactly the conflicting definitions > > of _POSIX_C_SOURCE come about. Maybe we can do something with #ifdef > > in the right places. However, I doubt it is worth the effort unless > > you can demonstrate the same problem on a more recent platform with > > a more recent compiler. > > I see the same warning with Red Hat Linux 9 and gcc 3.4.0. Is > that recent enough? Also see them when I build boost 1.31.0 with > bjam. Surely recent enough that there is hope that some developer will listen. Now we need a volunteer to 1. Reduce the problem. I.e. strip down the includes to a minimum. I'd expect the critial point to be in boost/python/detail/prefix.hpp. See the comment in there. 2. Potentially follow up on this: http://sourceforge.net/tracker/?func=detail&aid=663397&group_id=5470&atid=105470 My concerns were brushed away quite rudely and I am not keen to pick this up again. Ralf __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From Paul_Kunz at slac.stanford.edu Fri Jun 11 01:27:57 2004 From: Paul_Kunz at slac.stanford.edu (Paul F. Kunz) Date: Thu, 10 Jun 2004 16:27:57 -0700 Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined In-Reply-To: <20040610175931.74078.qmail@web20206.mail.yahoo.com> (rwgk@yahoo.com) References: <20040610175931.74078.qmail@web20206.mail.yahoo.com> Message-ID: <200406102327.i5ANRvb12047@libra3.slac.stanford.edu> >>>>> On Thu, 10 Jun 2004 10:59:31 -0700 (PDT), "Ralf W. Grosse-Kunstleve" said: > Surely recent enough that there is hope that some developer will > listen. Now we need a volunteer to > 1. Reduce the problem. I.e. strip down the includes to a > minimum. I'd expect the critial point to be in > boost/python/detail/prefix.hpp. See the comment in there. Here goes... foo.cxx ... ---- #include "boost/python.hpp" int main () { return 0; } ---- compile with g++ -c foo.cxx -I/usr/local/include/boost-1_31 -I/usr/local/include/python2.3 -ftemplate-depth-60 Results are... cd /u/ek/pfkeb/home/temp/ g++ -c foo.cxx -I/usr/local/include/boost-1_31 -I/usr/local/include/python2.3 -ftemplate-depth-60 In file included from /usr/local/include/python2.3/Python.h:8, from /usr/local/include/boost-1_31/boost/python/detail/wrap_python.hpp:121, from /usr/local/include/boost-1_31/boost/python/detail/prefix.hpp:13, from /usr/local/include/boost-1_31/boost/python/args.hpp:9, from /usr/local/include/boost-1_31/boost/python.hpp:12, from foo.cxx:1: /usr/local/include/python2.3/pyconfig.h:847: warning: `_POSIX_C_SOURCE' redefined /usr/include/features.h:171: warning: this is the location of the previous definition Compilation finished at Thu Jun 10 16:24:24 From rwgk at yahoo.com Fri Jun 11 02:17:37 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 10 Jun 2004 17:17:37 -0700 (PDT) Subject: [C++-sig] [PATCH] unused variables. In-Reply-To: Message-ID: <20040611001737.46277.qmail@web20205.mail.yahoo.com> Done, finally! --- Giulio Eulisse wrote: > Could someone please patch boost/boost.python as follows? Those unused > variables generate a lot of warnings when full warning report is used. > Thanks. > > Ciao, > Giulio > > Index: boost/python/class.hpp > =================================================================== > RCS file: /cvsroot/boost/boost/boost/python/class.hpp,v > retrieving revision 1.83.2.2 > diff -u -r1.83.2.2 class.hpp > --- boost/python/class.hpp????? 7 Jan 2004 14:08:10 -0000?????? 1.83.2.2 > +++ boost/python/class.hpp????? 25 May 2004 13:35:12 -0000 > @@ -556,7 +556,7 @@ > ???? template > ???? inline void def_default( > ???????? char const* name > -??????? , Fn fn > +??????? , Fn /*fn*/ > ???????? , Helper const& helper > ???????? , mpl::bool_) > ???? { > Index: boost/python/detail/caller.hpp > =================================================================== > RCS file: /cvsroot/boost/boost/boost/python/detail/caller.hpp,v > retrieving revision 1.21.2.1 > diff -u -r1.21.2.1 caller.hpp > --- boost/python/detail/caller.hpp????? 6 Jan 2004 13:08:25 -0000?????? > 1.21.2.1 > +++ boost/python/detail/caller.hpp????? 25 May 2004 13:35:12 -0000 > @@ -82,7 +82,7 @@ > > ?template > ?inline ResultConverter create_result_converter( > -??? ArgPackage const& args_ > +??? ArgPackage const& /*args_*/ > ?? , ResultConverter* > ?? , ... > ?) __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From rwgk at yahoo.com Fri Jun 11 03:15:59 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 10 Jun 2004 18:15:59 -0700 (PDT) Subject: [C++-sig] warning: "_POSIX_C_SOURCE" redefined In-Reply-To: <200406102327.i5ANRvb12047@libra3.slac.stanford.edu> Message-ID: <20040611011559.7330.qmail@web20208.mail.yahoo.com> --- "Paul F. Kunz" wrote: > >>>>> On Thu, 10 Jun 2004 10:59:31 -0700 (PDT), "Ralf W. Grosse-Kunstleve" > said: > > > Surely recent enough that there is hope that some developer will > > listen. Now we need a volunteer to > > > 1. Reduce the problem. I.e. strip down the includes to a > > minimum. I'd expect the critial point to be in > > boost/python/detail/prefix.hpp. See the comment in there. > > Here goes... > > foo.cxx ... > ---- > #include "boost/python.hpp" The Python developers will not be interested in this. If you absolutely have to avoid -w, and if you cannot tolerate the warning, start with boost/detail/prefix.hpp, the Python documentation and my bug report. The goal would be to show that you need to include a certain system file before including Python.h/pyconfig.h. Maybe you get lucky and you find a way to avoid the warning with some clever code rearrangements in boost, maybe it is impossible given the harsh approach of Python.h/pyconfig.h. In my experience resolving this type of problem can easily absorb a few days worth of time. I still believe it is not worth the effort. Ralf __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From amber at processed.users.sf.meat.com Mon Jun 14 01:35:39 2004 From: amber at processed.users.sf.meat.com (amber at processed.users.sf.meat.com) Date: Sun, 13 Jun 2004 23:35:39 +0000 Subject: [C++-sig] software In-Reply-To: References: Message-ID: <4H3L763G724J96LL@processed.users.sf.meat.com> Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://FJGCNA.info/OE017/?affiliate_id=233763&campaign_id=601 uns * ub - scribe http://FKEFCK.biz/diamondtron.php?affiliate_id=233763&campaign_id=601 auzqhxhz wbgdo rhwutwe rvvcm rqiftwf nvxv reunga rvta qntntai ncwgu gkmcqbyn xprq ezrxulx kbfaugi tig ndmz qpprnfp eyhix a gqldd From laurenz at t-online.de Mon Jun 14 06:00:16 2004 From: laurenz at t-online.de (yolanda) Date: Mon, 14 Jun 2004 04:00:16 +0000 Subject: [C++-sig] access information Message-ID: <200406140406.i5E46126097381@mxzilla1.xs4all.nl> Dear Great s,e,x ! Awesome videos! Enchanting stories! On the best adu1t site Love For Lust Special offer: Buy V1a,gra and get Free Access http://www.loveforlust.biz/?m=c++-sig at python.org From pierre.barbier at cirad.fr Mon Jun 14 09:44:00 2004 From: pierre.barbier at cirad.fr (Pierre Barbier de Reuille) Date: Mon, 14 Jun 2004 09:44:00 +0200 Subject: [C++-sig] multiple to_python converters ? In-Reply-To: <200406092157.02366.phil@freehackers.org> References: <200406092157.02366.phil@freehackers.org> Message-ID: <1087199040.734.1.camel@pbarbier> Mmmh ... a runtime _error_ ? that's strange : I had this problem but it was only a warning and my code worked properly (only one of the two converter was actually used ... so if it's the same it's no problem). Or perhaps your problem is due to having two libraries defining the same symbols ! If that's the case, you should have a third library which includes the common symbols and link this third library with the two first. Pierre Le mer 09/06/2004 ? 21:57, Philippe Fremy a ?crit : > Hi, > > I have the case where I have two python modules, both declaring the same > to_python converter. The modules may be used separately or together. The > problem is that if used together, I get (you see me coming I guess) a > RunTimeError. Only one to_python converter may be registerted at a time for > a given type. > > I looked in the archives and on google. I saw two references to discussions > of this problem and even a possible solution to be included in boost. But > checking the documentation today, I could not find any hint on how to solve > this problem. > > So, is the problem still here ? > > regards, > > Philippe -- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68 From edelrio at b.maus.de Tue Jun 15 03:47:25 2004 From: edelrio at b.maus.de (edelrio at b.maus.de) Date: Tue, 15 Jun 2004 01:47:25 +0000 Subject: [C++-sig] access information In-Reply-To: References: Message-ID: <72KE8K4HCKLJ07JD@b.maus.de> Dear C++-sig Great s,e,x ! Awesome videos! Enchanting stories! On the best adu1t site Love For Lust Special offer: Buy V1a,gra and get Free Access http://www.loveforlust.biz/?m=c++-sig at python.org mdvakqwk cwmh iebxn pyf xezhtz ltoan dd idnaaacx m igrkegb ckzh kgokribr xewh tkhtl jfa ulrfpy htjga wl ptfziyxn v ewglftx ktqy kxojetvj irxz aczjb xzw cwcocv lmoek bb algihqta n tbqrlrp koth qtimvxda iecj ptuyz myn gagzlz oxnif gr oumlxmwc p gryaqyn omup From dave at boost-consulting.com Mon Jun 14 17:58:19 2004 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 14 Jun 2004 11:58:19 -0400 Subject: [C++-sig] Re: multiple to_python converters ? References: <200406092157.02366.phil@freehackers.org> Message-ID: Philippe Fremy writes: > Hi, > > I have the case where I have two python modules, both declaring the same > to_python converter. The modules may be used separately or together. The > problem is that if used together, I get (you see me coming I guess) a > RunTimeError. Only one to_python converter may be registerted at a time for > a given type. > > I looked in the archives and on google. I saw two references to discussions > of this problem and even a possible solution to be included in boost. But > checking the documentation today, I could not find any hint on how to solve > this problem. > > So, is the problem still here ? That error was changed to a warning on 11-Sep-03 and is in Boost version 1.31.0 -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From paul.bridger at paradise.net.nz Tue Jun 15 02:09:04 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Tue, 15 Jun 2004 12:09:04 +1200 Subject: [C++-sig] Pyste: wrapper function for overloaded function problems Message-ID: <40CE3E20.1020409@paradise.net.nz> I am trying to expose a C++ member function with a bunch of default arguments, but I also want to provide a C++ wrapper for it. The problem I've had is that Pyste still generates the overload machinery even though it's not wanted since my wrapper function takes different arguments. Any hints? I'm going digging in the Pyste source. Paul Bridger From christophe.grimault at novagrid.com Tue Jun 15 10:28:53 2004 From: christophe.grimault at novagrid.com (Christophe Grimault) Date: Tue, 15 Jun 2004 10:28:53 +0200 Subject: [C++-sig] Size difference between .so and .dll files References: <40CE3E20.1020409@paradise.net.nz> Message-ID: <40CEB345.6010804@novagrid.com> Hi all, We have 2 versions of the same software. One on linux RH9, and one Win XP. Both of them compile and work fine. They use several C++ files compiled with boost to interact with Python. On windows, a dll with a size of a few hundreds of ko. On linux, the size for the equivalent .so is a few Mo. Have we missed something ? Any hints to reduce this size, if possible, are welcome ! Thanks in advance ... C. Grimault From rwgk at yahoo.com Tue Jun 15 16:39:48 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 15 Jun 2004 07:39:48 -0700 (PDT) Subject: [C++-sig] Size difference between .so and .dll files In-Reply-To: <40CEB345.6010804@novagrid.com> Message-ID: <20040615143948.43122.qmail@web20221.mail.yahoo.com> --- Christophe Grimault wrote: > We have 2 versions of the same software. One on linux RH9, and one Win > XP. > Both of them compile and work fine. They use several C++ files compiled with > boost to interact with Python. On windows, a dll with a size of a few > hundreds > of ko. On linux, the size for the equivalent .so is a few Mo. > > Have we missed something ? Any hints to reduce this size, if possible, > are welcome ! You seem to imply a size difference of three orders of magnitude (kB vs. MB). In my experience it is more a factor of roughly 2-4. I never looked in detail, but you can compare the sizes of the downloads posted here: http://cci.lbl.gov/cctbx_build/ E.g. the Redhat 9 download is 6.8MB, the Windows download is 5.0MB. This comparison is not a really good size-benchmark (gunzip vs. info-zip, Python sources are the same in both downloads), but it gives you a ballpark estimate. Could it be that you are comparing debug builds? Last time I did a Linux debug build (ages ago...) I noticed that the object files are enormous. I didn't pay attention to the sizes of the final .so files, though. Ralf __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From s_sourceforge at nedprod.com Wed Jun 16 03:04:32 2004 From: s_sourceforge at nedprod.com (Niall Douglas) Date: Wed, 16 Jun 2004 02:04:32 +0100 Subject: [C++-sig] Size difference between .so and .dll files In-Reply-To: <40CEB345.6010804@novagrid.com> Message-ID: <40CFAAB0.32271.25FB68FE@localhost> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 15 Jun 2004 at 10:28, Christophe Grimault wrote: > We have 2 versions of the same software. One on linux RH9, and one > Win XP. Both of them compile and work fine. They use several C++ files > compiled with boost to interact with Python. On windows, a dll with a > size of a few hundreds of ko. On linux, the size for the equivalent > .so is a few Mo. > > Have we missed something ? Any hints to reduce this size, if possible, > are welcome ! 1. Use GCC 3.4. This should knock 50% off your binary. 2. Patch GCC with my patch at http://www.nedprod.com/programs/gccvisibility.html. With - fvisibility=hidden this should knock a further few hundred Kb off your binary and produce better quality code too. No matter what you do, the Linux binary will be at least 20% larger than your MSVC binary. Cheers, Niall -----BEGIN PGP SIGNATURE----- Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 iQA/AwUBQM+cocEcvDLFGKbPEQLS8wCbBUA+oewaC4wT2JlPiE3ZpB47xBUAoK6o y6Gdwodyc/ngkqG3aWpsOLPC =sbJi -----END PGP SIGNATURE----- From caustin at gmail.com Thu Jun 17 10:12:37 2004 From: caustin at gmail.com (Chad Austin) Date: Thu, 17 Jun 2004 03:12:37 -0500 Subject: [C++-sig] Making Boost.Python understand DerivedSafe Message-ID: <2096514e0406170112773a0e76@mail.gmail.com> (I am not yet subscribed to the list... it seems mailman is having trouble sending me the authorization. Please CC me on replies.. Thanks.) Hi all, I just started using Boost.Python to embed Python in a project of mine. I spent a couple days evaluating, testing, and studying, but it seems to have paid off! Great job on making such a time-saving library! I am wrapping an internally refcounted class called CutScene. CutScene objects are referenced by RefPtr smart pointers, typedef'd as CutScenePtr. I export the class with: class_("CutScene").def /*etc*/; So far, so good. The problem comes about when I want to pass a CutScenePtr into object::operator() to call a function. If I pass a CutScenePtr object in, it says something about reject_raw_object_ptr: d:\Projects\empyrean\empyrean\third-party-vc7\include\boost\python\converter\arg_to_python.hpp(244) : error C2784: 'void boost::python::converter::detail::reject_raw_object_ptr(T *)' : could not deduce template argument for 'T1 *' from 'pyr::RefPtr' with [ T=pyr::CutScene ] If I pass the result of CutScenePtr::get() into operator() I get a runtime error about Boost.Python not knowing how to convert RefDerivedSafe* to a Python object. This makes sense, because RefPtr's implicit conversion operator, operator->, and get() all return RefDerivedSafe*. (RefDerivedSafe is a special class derived from T that prevents C++ clients from accidentally calling delete, ref(), or unref() on a smart pointer. This techique is used in both ATL and nsCOMPtr in Mozilla). Here's my question: Is there a way to tell Boost.Python that ptr(someCutScenePtr) is valid and should be equivalent to ptr(someCutScenePtr.get()) and/or that RefDerivedSafe* can be implicitly converted to T*? I've tried several different things, and nothing seems to work... I'm currently using Boost 1.31 with both gcc 3.3.1 and VS.NET 2003. Many thanks, Chad From christophe.grimault at novagrid.com Wed Jun 16 18:16:37 2004 From: christophe.grimault at novagrid.com (Christophe Grimault) Date: Wed, 16 Jun 2004 18:16:37 +0200 Subject: [C++-sig] Size difference between .so and .dll files References: <40CFAAB0.32271.25FB68FE@localhost> Message-ID: <40D07265.6080305@novagrid.com> Niall Douglas wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On 15 Jun 2004 at 10:28, Christophe Grimault wrote: > > > >>We have 2 versions of the same software. One on linux RH9, and one >>Win XP. Both of them compile and work fine. They use several C++ files >>compiled with boost to interact with Python. On windows, a dll with a >>size of a few hundreds of ko. On linux, the size for the equivalent >>.so is a few Mo. >> >>Have we missed something ? Any hints to reduce this size, if possible, >>are welcome ! >> >> > >1. Use GCC 3.4. This should knock 50% off your binary. > I have tried the gcc-3.4. Compared to gcc-3.2 used before, a .so typically goes from 5.4 Mo to 4.0 Mo. >2. Patch GCC with my patch at >http://www.nedprod.com/programs/gccvisibility.html. With - >fvisibility=hidden this should knock a further few hundred Kb off >your binary and produce better quality code too. > Thanks for the hint. I did not have the time to try yet ! > >No matter what you do, the Linux binary will be at least 20% larger >than your MSVC binary. > > Last question. I do not compile my .so with bjam but with a separate Makefile, outside of the boost architecture. May be I'm also missing something in the Makefile that the Jamfile does !? I think i remember that, if I try to compile the same .so, inside the boost architecture, I get a big improvement. Uhm ? Thanks a lot !! >Cheers, >Niall > > > > > >-----BEGIN PGP SIGNATURE----- >Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2 > >iQA/AwUBQM+cocEcvDLFGKbPEQLS8wCbBUA+oewaC4wT2JlPiE3ZpB47xBUAoK6o >y6Gdwodyc/ngkqG3aWpsOLPC >=sbJi >-----END PGP SIGNATURE----- > >_______________________________________________ >C++-sig mailing list >C++-sig at python.org >http://mail.python.org/mailman/listinfo/c++-sig > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timster at mygale.org Thu Jun 17 18:32:52 2004 From: timster at mygale.org (timster at mygale.org) Date: Thu, 17 Jun 2004 16:32:52 +0000 Subject: [C++-sig] software In-Reply-To: References: Message-ID: Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://MALMIK.biz/OE017/?affiliate_id=233763&campaign_id=601 uns * ub - scribe http://FKEFCK.biz/diamondtron.php?affiliate_id=233763&campaign_id=601 jymjhxpv xgxel vhkqxnb creyw ytoxcth bwrt ttdpob vbxd lnbbodt ucotj fplnynjp wdya umcpozt cnudexw zak rjqt xfgkowt tvtni k eyjxa From hellfire at icsi.berkeley.edu Fri Jun 18 23:45:48 2004 From: hellfire at icsi.berkeley.edu (hellfire at icsi.berkeley.edu) Date: Fri, 18 Jun 2004 21:45:48 +0000 Subject: [C++-sig] software In-Reply-To: <345CKIJJ17C664JH@python.org> References: <345CKIJJ17C664JH@python.org> Message-ID: Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Our site is http://ceazpzh.agelmkb.info/?U7qZWFUXxY_haoUdfchbodt Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://fgnexmkb.cgnacmg.info/?MviRixgPpkT9yggrmiud lcpztmha akfrz iombaaj hmfyu oyvckzf rxpp amzzrx hdmp gtoxtjl yqiof mxrwlopx odda muklgzj oluqbnv udt pecd xldiljd orrjx b lhrdl From emily at t-online.de Thu Jun 17 09:20:44 2004 From: emily at t-online.de (khoi) Date: Thu, 17 Jun 2004 07:20:44 +0000 Subject: [C++-sig] access information Message-ID: <200406170728.i5H7SHC3094908@mxzilla7.xs4all.nl> Dear Great s,e,x ! Awesome videos! Enchanting stories! On the best adu1t site Love For Lust Special offer: Buy V1a,gra and get Free Access http://www.loveforlust.biz/?m=c++-sig at python.org From nicodemus at esss.com.br Wed Jun 16 19:45:04 2004 From: nicodemus at esss.com.br (Nicodemus) Date: Wed, 16 Jun 2004 14:45:04 -0300 Subject: [C++-sig] Pyste: wrapper function for overloaded function problems In-Reply-To: <40CE3E20.1020409@paradise.net.nz> References: <40CE3E20.1020409@paradise.net.nz> Message-ID: <40D08720.8080201@esss.com.br> Hi Paul, sorry about the delay, paul.bridger wrote: > I am trying to expose a C++ member function with a bunch of default > arguments, but I also want to provide a C++ wrapper for it. > The problem I've had is that Pyste still generates the overload > machinery even though it's not wanted since my wrapper function takes > different arguments. > > Any hints? I'm going digging in the Pyste source. You want to take a look at the method ExportMethods in ClassExporter.py. ;) Patches are welcome, as always! Regards, Nicodemus. From dave at boost-consulting.com Sat Jun 19 13:00:41 2004 From: dave at boost-consulting.com (David Abrahams) Date: Sat, 19 Jun 2004 07:00:41 -0400 Subject: [C++-sig] Re: Making Boost.Python understand DerivedSafe References: <2096514e0406170112773a0e76@mail.gmail.com> Message-ID: Chad Austin writes: > (I am not yet subscribed to the list... it seems mailman is having > trouble sending me the authorization. Please CC me on replies.. > Thanks.) > > Hi all, > > I just started using Boost.Python to embed Python in a project of > mine. I spent a couple days evaluating, testing, and studying, but it > seems to have paid off! Great job on making such a time-saving > library! > > I am wrapping an internally refcounted class called CutScene. > CutScene objects are referenced by RefPtr smart pointers, > typedef'd as CutScenePtr. I export the class with: > > class_("CutScene").def /*etc*/; > > So far, so good. The problem comes about when I want to pass a > CutScenePtr into object::operator() to call a function. If I pass a > CutScenePtr object in, it says something about reject_raw_object_ptr: > > d:\Projects\empyrean\empyrean\third-party-vc7\include\boost\python\converter\arg_to_python.hpp(244) > : error C2784: 'void > boost::python::converter::detail::reject_raw_object_ptr(T *)' : could > not deduce template argument for 'T1 *' from 'pyr::RefPtr' > with > [ > T=pyr::CutScene > ] 1. Show us more detail: more of the error messages, some sample code, etc. 2. As far as I can tell you have used boost::ptr around one of your RefPtrs, call it 'x': ptr(x) boost::ptr is reserved for real pointers. > If I pass the result of CutScenePtr::get() into operator() I get a > runtime error about Boost.Python not knowing how to convert > RefDerivedSafe* to a Python object. This makes sense, because > RefPtr's implicit conversion operator, operator->, and get() all > return RefDerivedSafe*. (RefDerivedSafe is a special class > derived from T that prevents C++ clients from accidentally calling > delete, ref(), or unref() on a smart pointer Bah! T* p = x.get(); delete p; > . This techique is used in both ATL and nsCOMPtr in Mozilla). That doesn't make it safe ;-> > Here's my question: Is there a way to tell Boost.Python that > ptr(someCutScenePtr) is valid No! Why do you want to use ptr? > and should be equivalent to > ptr(someCutScenePtr.get()) and/or that RefDerivedSafe* can be > implicitly converted to T*? I've tried several different things, and > nothing seems to work... Maybe this helps? http://www.boost.org/libs/python/doc/v2/register_ptr_to_python.html -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From jeff.holle at verizon.net Sat Jun 19 05:54:38 2004 From: jeff.holle at verizon.net (Jeff Holle) Date: Fri, 18 Jun 2004 23:54:38 -0400 Subject: [C++-sig] Added to a vector_indexing_suite container in python Message-ID: <40D3B8FE.9070900@verizon.net> I am using gcc 3.2 and boost 1_31_0. In my application, I'm using python is a consumer of data created in C++ and housed in vectors wrapped with vector_indexing_suite. Now I want to create some Python scripts that are data producers for test purposes, but can't seem to be able to populate these containers. I've noted that a 'append' method is exposed, trying this doesn't add to the container. Attempting to use 'myContainer[0] = something' causes an illegal indexing exception on an empty container... Am I missing something? Do I have to add my own methods independent of the vector_indexing_suite? From jeff.holle at verizon.net Sat Jun 19 11:18:37 2004 From: jeff.holle at verizon.net (Jeff Holle) Date: Sat, 19 Jun 2004 05:18:37 -0400 Subject: [C++-sig] [Re: Added to a vector_indexing_suite container in python] Message-ID: <40D404ED.6020905@verizon.net> I suspect that my previous post concerning this problem does not provide adequite information. So here is more. Following is a grep of my files that highlite what I'm trying to wrap with pyste and how I'm doing it: typedef std::vector Parameters; MemberFunction.h: Parameters& getParameters( void); MemberFunction.h: const Parameters& getParameters( void) const; MemberFunction.h:UMLModel::Parameters& PygetParameters(UMLModel::CMemberFunction& self); MemberFunction.pyste:exclude(a.getParameters) MemberFunction.pyste:add_method(a,"PygetParameters") MemberFunction.pyste:set_policy(a.PygetParameters,return_value_policy(copy_non_const_reference)) MemberFunction.pyste:rename(a.PygetParameters,"getParameters") The PygetParameters function exists because pyste throws errors in encountering the overloaded pair that are in-place to facilitate const correct coding. Note the method call policy that I'm applying, "copy_non_const_reference". It appears that this policy causes a copy of the container in the process of calling "getParameters" in python. I believe this because the following python script: aMethod.getParameters().append(aParm) print 'number of parameters is %d' % len(aMethod.getParameters()) prints: number of parameters is 0 I've added my own "push_back" method to this container in a way similiar to the iterator.cpp file. The same results occur, which are explained if a container copy is going on. It there a way to avoid this copy? From kevin at kevinatkinson.com Mon Jun 21 21:22:07 2004 From: kevin at kevinatkinson.com (kevin at kevinatkinson.com) Date: Mon, 21 Jun 2004 15:22:07 -0400 Subject: [C++-sig] opencascade Message-ID: <002b01c457c5$1378e380$73c809c0@CPQ30541773923> This email is addressed to Niki Spahiev; it is in regard to this message on mail.python.org: http://mail.python.org/pipermail/c++-sig/2003-March/003577.html I am trying to do precisely the same thing: generate boost.python wrappers using the metadata exposed in the cdl files of Open Cascade. Did you have any luck doing this? I ask because I am anxious to get my hands on a Python wrapper of Open Cascade, and at this point it's looking like I may have to do it myself. I know there is a fellow named Sandor Racz who has made an incomplete wrapper for 5.0, but I'm not having much luck with it. I would greatly appreciate any tips you might have in this regard. Best, Kevin Atkinson Software Developer -------------- next part -------------- An HTML attachment was scrubbed... URL: From nickm at sitius.com Tue Jun 22 00:01:57 2004 From: nickm at sitius.com (Nikolay Mladenov) Date: Mon, 21 Jun 2004 18:01:57 -0400 Subject: [C++-sig] Re: Making Boost.Python understand DerivedSafe References: <2096514e0406170112773a0e76@mail.gmail.com> Message-ID: <40D75AD5.A7240E56@sitius.com> Try to satisfy the detailed requirements for the "HeldType" (http://www.boost.org/libs/python/doc/v2/class.html#class_-spec). I think you'll have to define get_pointer(CutScenePtr). And maybe specialize python::pointee. HTH, Nikolay Chad Austin wrote: > > (I am not yet subscribed to the list... it seems mailman is having > trouble sending me the authorization. Please CC me on replies.. > Thanks.) > > Hi all, > > I just started using Boost.Python to embed Python in a project of > mine. I spent a couple days evaluating, testing, and studying, but it > seems to have paid off! Great job on making such a time-saving > library! > > I am wrapping an internally refcounted class called CutScene. > CutScene objects are referenced by RefPtr smart pointers, > typedef'd as CutScenePtr. I export the class with: > > class_("CutScene").def /*etc*/; > > So far, so good. The problem comes about when I want to pass a > CutScenePtr into object::operator() to call a function. If I pass a > CutScenePtr object in, it says something about reject_raw_object_ptr: > > d:\Projects\empyrean\empyrean\third-party-vc7\include\boost\python\converter\arg_to_python.hpp(244) > : error C2784: 'void > boost::python::converter::detail::reject_raw_object_ptr(T *)' : could > not deduce template argument for 'T1 *' from 'pyr::RefPtr' > with > [ > T=pyr::CutScene > ] > > If I pass the result of CutScenePtr::get() into operator() I get a > runtime error about Boost.Python not knowing how to convert > RefDerivedSafe* to a Python object. This makes sense, because > RefPtr's implicit conversion operator, operator->, and get() all > return RefDerivedSafe*. (RefDerivedSafe is a special class > derived from T that prevents C++ clients from accidentally calling > delete, ref(), or unref() on a smart pointer. This techique is used in > both ATL and nsCOMPtr in Mozilla). > > Here's my question: Is there a way to tell Boost.Python that > ptr(someCutScenePtr) is valid and should be equivalent to > ptr(someCutScenePtr.get()) and/or that RefDerivedSafe* can be > implicitly converted to T*? I've tried several different things, and > nothing seems to work... > > I'm currently using Boost 1.31 with both gcc 3.3.1 and VS.NET 2003. > > Many thanks, > Chad -- Nikolay Mladenov Sitius Automation Inc. www.sitius.com From Peter.Vandersteegen at intec.Ugent.be Tue Jun 22 15:07:22 2004 From: Peter.Vandersteegen at intec.Ugent.be (Peter Vandersteegen) Date: Tue, 22 Jun 2004 15:07:22 +0200 Subject: [C++-sig] Question: compiling library using extension/wrapper Message-ID: <6.1.0.6.0.20040622141832.02667098@pop-tech.intec.UGent.be> Hello, I've recently discovered boost-python. Compiling several examples gave no problem. Working with lists etc also no problems. Compiling a simple library using the extension/wrapper however resulted in several questions... Therefor I've one question: Question1: Is it correct to state the following? (something I find confusing) There are (at least) 2 ways to get a boost-layer between Numeric python and c++. The first one is based on , the other on ... * The project num_util (http://www.eos.ubc.ca/research/clouds/software/pythonlibs/num_util/) uses the fist method? They use boost as wrapper, but for the array class, they directly use the python numeric array class and not the boost.python array class? * Directly using seperates you from dealing with the 'raw' python numeric array class? Added bonus: no need to write import_array() in BOOST_PYTHON_MODULE... Thus, is it correct to say that these are 2 different approaches to convert an array from python to c++ ? thx a lot for reading so far Peter From herveus at t2.technion.ac.il Tue Jun 22 15:25:11 2004 From: herveus at t2.technion.ac.il (herveus at t2.technion.ac.il) Date: Tue, 22 Jun 2004 13:25:11 +0000 Subject: [C++-sig] software In-Reply-To: <670I533K0IBL1IKI@python.org> References: <670I533K0IBL1IKI@python.org> Message-ID: <6FEBEFKL4I10EKDL@techst02.technion.ac.il> Microsoft Windows XP Professional 2002 Retail price: $270.99 Our low Price: $50.00 You Save: $220.00 Adobe Photoshop 7.0 Retail price: $609.99 Our low Price: $60.00 You Save: $550.00 Microsoft Office XP Professional 2002 Retail price: $579.99 Our low Price: $60.00 You Save: $510.00 Adobe Illustrator 10 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Corel Draw Graphics Suite 11 Retail price: $270.99 Our low Price: $60.00 You Save: $210.00 Delphi 7 Retail price: $404.99 Our low Price: $60.00 You Save: $335.00 And more!!! Our site is http://axwny.lddekfan.info/?h0PmjyNQWlUGzhNtcemcyb Why so cheap? All the software is OEM- Meaning that you don't get the box and the manual with your software. All you will receive is the actual software and your unique registration code. All the software is in the English language for PC. Our offers are unbeatable and we always update our prices to make sure we provide you with the best possible offers. Hurry up and place your order, because our supplies are limited. Our site is http://dpnlr.lddekfan.info/?h0PmjyNQWlUGzhNifhnxut ehqojxok vkate cyqfwti mtvgq bmgzhnd ngtz etjztk txmq otnicbq xhiyv oxceaqkt qobb ovltraa ttnqvpi tyr rttp wmpmyjf nlgdh t lault From caustin at gmail.com Wed Jun 23 02:06:18 2004 From: caustin at gmail.com (Chad Austin) Date: Tue, 22 Jun 2004 19:06:18 -0500 Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? Message-ID: <2096514e0406221706691db56c@mail.gmail.com> Hi all, Has anyone successfully used Boost.Python in SUSE 9.0 or SUSE 9.1? In 9.0 I had to build and install boost 1.31 from source, but 9.1 comes with a boost 1.31 package. Either way, merely #including causes an internal compiler error in a variety of places. Note: SUSE 9.0 uses gcc 3.3.1 (+ SUSE-specific patches?) and SUSE 9.1 uses gcc 3.3.3 (+ patches again?). If I build gcc 3.4.0 from source, Boost.Python compiles, but does not link do to incompatibilities in libstdc++. I'm going to try Boost.Python from CVS before anything else, but I thought I'd ask if anyone else has had success or failure in this area. Thanks, Chad From paul.bridger at paradise.net.nz Thu Jun 24 00:31:50 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Thu, 24 Jun 2004 10:31:50 +1200 Subject: [C++-sig] Pyste: wrapper function for overloaded function problems In-Reply-To: <40D08720.8080201@esss.com.br> References: <40CE3E20.1020409@paradise.net.nz> <40D08720.8080201@esss.com.br> Message-ID: <40DA04D6.9050800@paradise.net.nz> Hi, I've just done a diff of my Pyste vs. CVS. There are a few small improvements I've made. Two in ClassExporter.py: The problem described below was easy to fix: ClassExporter.py: 375 if method.minArgs != method.maxArgs: # here pyste adds overload declarations and creates extra argument to def() becomes if method.minArgs != method.maxArgs and not method_info.wrapper: # so we nolonger do this if the method has a wrapper This worked fine for me, but I am nolonger using (and hence testing) this change every day. I was writing function/method wrappers for functions that took a customised string implementation, but I stopped doing this when I found I couldn't write constructor wrappers (AFAIK). Now everything is consistently unwrapped. A diff snippet for that: 375c381 < if method.minArgs != method.maxArgs: --- > if method.minArgs != method.maxArgs and not method_info.wrapper: I also noticed that for inherited virtual methods, Pyste would not: a) warn about lack of defined policies, and b) register the default policy when it could Here is the fix: 778,779c787,792 < # Add policy to overloaded methods also < policy = self.info[method.name].policy or '' --- > # warn the user if this method needs a policy and doesn't have one > method_info = self.info[method.name] > method_info.policy = exporterutils.HandlePolicy(method, method_info.policy) > > # Add policy to overloaded methods also > policy = method_info.policy or '' There was also a change in GCCXMLParser.py. I posted to C++-Sig about this a little while ago: http://aspn.activestate.com/ASPN/Mail/Message/c++-sig/2088336 GCCXMLParser.py 280c280 < if type(decl) in Class.ValidMemberTypes(): --- > if type(decl) in Class.ValidMemberTypes() and decl.name != '': Thanks. Paul Bridger Nicodemus wrote: > Hi Paul, sorry about the delay, > > paul.bridger wrote: > >> I am trying to expose a C++ member function with a bunch of default >> arguments, but I also want to provide a C++ wrapper for it. >> The problem I've had is that Pyste still generates the overload >> machinery even though it's not wanted since my wrapper function takes >> different arguments. >> >> Any hints? I'm going digging in the Pyste source. > > > > You want to take a look at the method ExportMethods in ClassExporter.py. ;) > Patches are welcome, as always! > > Regards, > Nicodemus. > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > > From caustin at gmail.com Thu Jun 24 02:26:09 2004 From: caustin at gmail.com (Chad Austin) Date: Wed, 23 Jun 2004 19:26:09 -0500 Subject: [C++-sig] Re: Making Boost.Python understand DerivedSafe In-Reply-To: References: <2096514e0406170112773a0e76@mail.gmail.com> Message-ID: <2096514e0406231726642a11a2@mail.gmail.com> On Sat, 19 Jun 2004 07:00:41 -0400, David Abrahams wrote: > 2. As far as I can tell you have used boost::ptr around one of your > RefPtrs, call it 'x': > > ptr(x) > > boost::ptr is reserved for real pointers. Ah, I didn't know that. Taking out the ptr call seems to work. Now I understand how HeldType works. (Thanks Nikolay.) > > If I pass the result of CutScenePtr::get() into operator() I get a > > runtime error about Boost.Python not knowing how to convert > > RefDerivedSafe* to a Python object. This makes sense, because > > RefPtr's implicit conversion operator, operator->, and get() all > > return RefDerivedSafe*. (RefDerivedSafe is a special class > > derived from T that prevents C++ clients from accidentally calling > > delete, ref(), or unref() on a smart pointer > > Bah! > > T* p = x.get(); > delete p; Of course you can work around it. :P The point is, it does help catch unintentional bugs, especially in code written by someone new to refcounting/smart pointers or when refactoring. > > . This techique is used in both ATL and nsCOMPtr in Mozilla). > > That doesn't make it safe ;-> We can go back and forth for eternity arguing about C++ style, but that doesn't get anywhere. I really just wanted some help in getting this existing codebase connected nicely to Python. > > Here's my question: Is there a way to tell Boost.Python that > > ptr(someCutScenePtr) is valid > > No! Why do you want to use ptr? I was under the impression that if you don't use ptr, a copy of the object is given to Python. From the discussion at: http://www.boost.org/libs/python/doc/v2/callbacks.html I guess it just wasn't exactly clear how I should pass my own refcounting pointer into Boost.Python and how that fit in with HeldType. Chad From Peter.Vandersteegen at intec.Ugent.be Thu Jun 24 09:43:56 2004 From: Peter.Vandersteegen at intec.Ugent.be (Peter Vandersteegen) Date: Thu, 24 Jun 2004 09:43:56 +0200 Subject: [C++-sig] Question: compiling library using extension/wrapper Message-ID: <6.1.0.6.0.20040624094350.025c1630@pop-tech.intec.UGent.be> Hello, Sorry if you recieve this more than once ... I've recently discovered boost-python. Compiling several examples gave no problem. Working with lists etc also no problems. Compiling a simple library using the extension/wrapper however resulted in several questions... Therefor I've one question: Question1: Is it correct to state the following? (something I find confusing) There are (at least) 2 ways to get a boost-layer between Numeric python and c++. The first one is based on , the other on ... * The project num_util (http://www.eos.ubc.ca/research/clouds/software/pythonlibs/num_util/) uses the fist method? They use boost as wrapper, but for the array class, they directly use the python numeric array class and not the boost.python array class? * Directly using seperates you from dealing with the 'raw' python numeric array class? Added bonus: no need to write import_array() in BOOST_PYTHON_MODULE... Thus, is it correct to say that these are 2 different approaches to convert an array from python to c++ ? thx a lot for reading so far Peter From rwgk at yahoo.com Thu Jun 24 16:42:41 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Thu, 24 Jun 2004 07:42:41 -0700 (PDT) Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: <2096514e0406221706691db56c@mail.gmail.com> Message-ID: <20040624144241.53669.qmail@web20207.mail.yahoo.com> --- Chad Austin wrote: > Has anyone successfully used Boost.Python in SUSE 9.0 or SUSE 9.1? In > 9.0 I had to build and install boost 1.31 from source, but 9.1 comes > with a boost 1.31 package. Either way, merely #including > causes an internal compiler error in a variety of > places. Note: SUSE 9.0 uses gcc 3.3.1 (+ SUSE-specific patches?) and > SUSE 9.1 uses gcc 3.3.3 (+ patches again?). I've used gcc 3.3.1 under Mandrake 9.2 and SunOS 5.9 without problems, but didn't have the opportunity to try SUSE. > If I build gcc 3.4.0 from > source, Boost.Python compiles, but does not link do to > incompatibilities in libstdc++.> Does the link command fail, or is it a run-time failure (i.e. dlopen fails)? If it is the latter you might have to update the LD_LIBRARY_PATH. This is what I am using to activate gcc 3.4 in a new shell: set path=(/usr/local_cci/gcc-3.4.0/bin $path) if ( $?LD_LIBRARY_PATH ) then setenv LD_LIBRARY_PATH "/usr/local_cci/gcc-3.4.0/lib:${LD_LIBRARY_PATH}" else setenv LD_LIBRARY_PATH "/usr/local_cci/gcc-3.4.0/lib" endif > I'm going to try Boost.Python from > CVS before anything else, but I thought I'd ask if anyone else has had > success or failure in this area. The Boost 1.31 release has a subtle issue when compiling with gcc 3.4: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14528 If you run into this use Boost CVS. As of yesterday it was in fantastic shape. Ralf __________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail From paustin at eos.ubc.ca Thu Jun 24 18:53:36 2004 From: paustin at eos.ubc.ca (Philip Austin) Date: Thu, 24 Jun 2004 09:53:36 -0700 Subject: [C++-sig] Question: compiling library using In-Reply-To: <6.1.0.6.0.20040622141832.02667098@pop-tech.intec.UGent.be> References: <6.1.0.6.0.20040622141832.02667098@pop-tech.intec.UGent.be> Message-ID: <16603.1808.886523.566258@gull.eos.ubc.ca> Peter Vandersteegen writes: > Hello, > > Therefor I've one question: [snip] > > * The project num_util > (http://www.eos.ubc.ca/research/clouds/software/pythonlibs/num_util/) uses > the fist method? They use boost as wrapper, but for the array class, they > directly use the python numeric array class and not the boost.python array > class? > * Directly using seperates you from dealing with the > 'raw' python numeric array class? Added bonus: no need to write > import_array() in BOOST_PYTHON_MODULE... That's right -- also, by using callbacks into python, David was able to make the same implementation work for both Numeric and Numarray (the successor to Numeric, which is not completely backward compatible). We use num_util because (in decreasing order of importance): i) we need to move large arrays between python and C++, which means we need access to the PyArrayObject pointer. Numeric.hpp only supports copying your results into a new tuple or list to return to python. ii) the callback overhead can be substantial for some of our applications. iii) we have a quite a bit of legacy code developed for our interface under boost v1, which predates Numeric.hpp. Regards, Phil From nickm at sitius.com Thu Jun 24 23:57:07 2004 From: nickm at sitius.com (Nikolay Mladenov) Date: Thu, 24 Jun 2004 17:57:07 -0400 Subject: [C++-sig] Re: opencascade References: <002b01c457c5$1378e380$73c809c0@CPQ30541773923> Message-ID: <40DB4E33.345F3EBD@sitius.com> I am also interested in the answer of that one. -- Nikolay Mladenov Sitius Automation Inc. www.sitius.com From hoeppler at diener.iap.physik.uni-tuebingen.de Fri Jun 25 11:29:31 2004 From: hoeppler at diener.iap.physik.uni-tuebingen.de (Chris Hoeppler) Date: Fri, 25 Jun 2004 11:29:31 +0200 (CEST) Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: <2096514e0406221706691db56c@mail.gmail.com> Message-ID: On Tue, 22 Jun 2004, Chad Austin wrote: > Hi all, > > Has anyone successfully used Boost.Python in SUSE 9.0 or SUSE 9.1? In > 9.0 I had to build and install boost 1.31 from source, but 9.1 comes > with a boost 1.31 package. Either way, merely #including > causes an internal compiler error in a variety of > places. Note: SUSE 9.0 uses gcc 3.3.1 (+ SUSE-specific patches?) and > SUSE 9.1 uses gcc 3.3.3 (+ patches again?). If I build gcc 3.4.0 from > source, Boost.Python compiles, but does not link do to > incompatibilities in libstdc++. I'm going to try Boost.Python from > CVS before anything else, but I thought I'd ask if anyone else has had > success or failure in this area. > > Thanks, > Chad Hi, I've managed to successfully compile and use a small module on SuSE 9.0 with the following setup: * gcc version 3.3.1 (SuSE Linux) * boost_1_31_0 obtained from boost site and compiled from sources * python 2.3.3 also compiled from sources. * Module: #include #include #include #include #include "rpower.h" using namespace boost::python; BOOST_PYTHON_MODULE(fftw_ext) { class_ >("fftw_realVec") .def(vector_indexing_suite >()) ; def("power_spectrum", power_spectrum); } where power_spectrum is a function defined in rpower.h with the following signature: void power_spectrum(std::vector &in, std::vector &out); However, I've just tried to compile a test file with just one line #include as mentioned in your post quoted above, which also results in an internal compiler error: g++ -Wall -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB -g -O0 \ -fno-inline -fPIC -DDEBUG -I/usr/local/include/python2.3 \ -I/usr/local/include/boost-1_31 -c -o test.os test.cpp /usr/local/include/boost-1_31/boost/python/object_core.hpp:283: internal compiler error: Segmentation fault Any clues on how to proceed from here? Thanks, Chris From MKhesin at liquidnet.com Fri Jun 25 15:54:19 2004 From: MKhesin at liquidnet.com (Max Khesin) Date: Fri, 25 Jun 2004 09:54:19 -0400 Subject: [C++-sig] boost.python crush Message-ID: <4B6FB7F60D37D41188C300B0D022E0C0029F4390@exchange.lnholdings.com> I have the following sample class exposed via boost.python: class String { public: String(const std::string& v):m_val(v){} bool lessThan(const std::string& other) const{return this->m_valm_val>other;} bool equals(const std::string& other) const{return this->m_val==other;} bool regexMatch(const std::string& other) const{return this->m_val==other;} bool withinDistance(const std::string& other, int dist) const{return distance(this->m_val, other)<=dist;} private: std::string m_val; }; BOOST_PYTHON_MODULE(test) { class_("String", init()) .def("lessThan", &String::lessThan) .def("greaterThan", &String::greaterThan) .def("equals", &String::equals) .def("regexMatch", &String::regexMatch) .def("withinDistance", &String::withinDistance) ; } I am calling this from python: >> import test >> s = test.String('hallo') >> s.lessThen('hello') #### <<< CRUSH the debugger seems to point to an access violation in std::string dtor. I palyed around with making the argument a plain std::string (instead of const std::string&) and const char* - both of those crush, albeit in a different place (also dtors, from the looks of it) Any idea? thanks, max This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. From rwgk at yahoo.com Fri Jun 25 15:55:25 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 25 Jun 2004 06:55:25 -0700 (PDT) Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: Message-ID: <20040625135525.94532.qmail@web20205.mail.yahoo.com> --- Chris Hoeppler wrote: > However, I've just tried to compile a test file with just one line > #include > as mentioned in your post quoted above, which also results in an internal > compiler error: > > g++ -Wall -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB -g -O0 \ > -fno-inline -fPIC -DDEBUG -I/usr/local/include/python2.3 \ > -I/usr/local/include/boost-1_31 -c -o test.os test.cpp > > > /usr/local/include/boost-1_31/boost/python/object_core.hpp:283: internal > compiler error: Segmentation > fault > > Any clues on how to proceed from here? You have to strip down the code until you've isolated the construct that causes the ICE. Then try to rearrange that construct until the ICE goes away. In the early days of Boost.Python I've done this a million times, and I am sure David did it a billion times. It always takes too long, is very frustrating, and therefore requires a lot of determination. If this is not enough to scare you, copy the content of boost/python.hpp into your source file, then comment out half the includes, see if it still ICE's, if yes comment out half of the remaining, if not put back half of the ones you commented out, and so on until you've found that one include that makes a difference. Then copy that into your source code and repeat the exercise until you found the piece of code that makes the difference. Then go into a different trial-and-error loop rearranging the code. While the first step requires mainly determination, you will need some creativity here. Often my last resort was to ask David. Finally you have to communicate the fix to the developers of the effected library (e.g. it could be in boost::graph or boost::bind or, heaven forbid, in boost::mpl or ...) and convince them to adopt your fix. Easy! Ralf __________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail From dave at boost-consulting.com Fri Jun 25 16:04:20 2004 From: dave at boost-consulting.com (David Abrahams) Date: Fri, 25 Jun 2004 10:04:20 -0400 Subject: [C++-sig] Re: Making Boost.Python understand DerivedSafe References: <2096514e0406170112773a0e76@mail.gmail.com> <2096514e0406231726642a11a2@mail.gmail.com> Message-ID: Chad Austin writes: >> >> Bah! >> >> T* p = x.get(); >> delete p; > > Of course you can work around it. :P The point is, it does help > catch unintentional bugs, especially in code written by someone new to > refcounting/smart pointers or when refactoring. Just to be clear, I have no problem with that part; it's having the implicit conversion at all that I take issue with... but I see below you don't really care what I think about this ;-> (I can't blame you). >> > . This techique is used in both ATL and nsCOMPtr in Mozilla). >> >> That doesn't make it safe ;-> > > We can go back and forth for eternity arguing about C++ style, but > that doesn't get anywhere. I really just wanted some help in getting > this existing codebase connected nicely to Python. I hope you got the help you needed. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From caustin at gmail.com Fri Jun 25 16:07:03 2004 From: caustin at gmail.com (Chad Austin) Date: Fri, 25 Jun 2004 09:07:03 -0500 Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: <20040624144241.53669.qmail@web20207.mail.yahoo.com> References: <20040624144241.53669.qmail@web20207.mail.yahoo.com> Message-ID: <2096514e04062507072f0ff45@mail.gmail.com> Hi Ralf, On Thu, 24 Jun 2004 07:42:41 -0700 (PDT), Ralf W. Grosse-Kunstleve wrote: > > --- Chad Austin wrote: > > Has anyone successfully used Boost.Python in SUSE 9.0 or SUSE 9.1? In > > 9.0 I had to build and install boost 1.31 from source, but 9.1 comes > > with a boost 1.31 package. Either way, merely #including > > causes an internal compiler error in a variety of > > places. Note: SUSE 9.0 uses gcc 3.3.1 (+ SUSE-specific patches?) and > > SUSE 9.1 uses gcc 3.3.3 (+ patches again?). > > I've used gcc 3.3.1 under Mandrake 9.2 and SunOS 5.9 without problems, but > didn't have the opportunity to try SUSE. After some investigation, it appears SUSE applies some custom patches to their gcc builds, causing including boost/python.hpp to ICE. I've submitted a support request to SUSE for this issue. Installing a compatible gcc from source into /usr/local appears to work around the problem. > > If I build gcc 3.4.0 from > > source, Boost.Python compiles, but does not link do to > > incompatibilities in libstdc++.> > > Does the link command fail, or is it a run-time failure (i.e. dlopen fails)? > If it is the latter you might have to update the LD_LIBRARY_PATH. This is what > I am using to activate gcc 3.4 in a new shell: I believe it was an ABI change in libstdc++ or something. My boost was compiled with gcc 3.3 and my app with 3.4. I just started getting random crashes. > set path=(/usr/local_cci/gcc-3.4.0/bin $path) > if ( $?LD_LIBRARY_PATH ) then > setenv LD_LIBRARY_PATH "/usr/local_cci/gcc-3.4.0/lib:${LD_LIBRARY_PATH}" > else > setenv LD_LIBRARY_PATH "/usr/local_cci/gcc-3.4.0/lib" > endif Awesome, thanks. > > I'm going to try Boost.Python from > > CVS before anything else, but I thought I'd ask if anyone else has had > > success or failure in this area. > > The Boost 1.31 release has a subtle issue when compiling with gcc 3.4: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14528 > > If you run into this use Boost CVS. As of yesterday it was in fantastic shape. Thanks for the heads up! I did notice that gcc 3.4 is a lot more strict about some things. It seems to discover lots of subtle errors that other compilers don't. :) Chad From caustin at gmail.com Fri Jun 25 16:10:44 2004 From: caustin at gmail.com (Chad Austin) Date: Fri, 25 Jun 2004 09:10:44 -0500 Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: References: Message-ID: <2096514e040625071078b1a2f1@mail.gmail.com> Hi Chris, Thanks for letting me know how you've gotten it to work. I'll try including the individual Boost.Python headers instead of . As I mentioned in my response to Ralf, if you compile a compatible gcc (3.3.1 for SUSE 9.0) and install it into /usr/local, including works. Chad On Fri, 25 Jun 2004 11:29:31 +0200 (CEST), Chris Hoeppler wrote: > > > On Tue, 22 Jun 2004, Chad Austin wrote: > > > Hi all, > > > > Has anyone successfully used Boost.Python in SUSE 9.0 or SUSE 9.1? In > > 9.0 I had to build and install boost 1.31 from source, but 9.1 comes > > with a boost 1.31 package. Either way, merely #including > > causes an internal compiler error in a variety of > > places. Note: SUSE 9.0 uses gcc 3.3.1 (+ SUSE-specific patches?) and > > SUSE 9.1 uses gcc 3.3.3 (+ patches again?). If I build gcc 3.4.0 from > > source, Boost.Python compiles, but does not link do to > > incompatibilities in libstdc++. I'm going to try Boost.Python from > > CVS before anything else, but I thought I'd ask if anyone else has had > > success or failure in this area. > > > > Thanks, > > Chad > > Hi, > > I've managed to successfully compile and use a small module on SuSE 9.0 > with the following setup: > > * gcc version 3.3.1 (SuSE Linux) > > * boost_1_31_0 obtained from boost site and compiled from sources > > * python 2.3.3 also compiled from sources. > > * Module: > > #include > #include > #include > #include > > #include "rpower.h" > > using namespace boost::python; > > BOOST_PYTHON_MODULE(fftw_ext) > { > class_ >("fftw_realVec") > .def(vector_indexing_suite >()) > ; > > def("power_spectrum", power_spectrum); > } > > where power_spectrum is a function defined in rpower.h with the following > signature: > > void power_spectrum(std::vector &in, > std::vector &out); > > However, I've just tried to compile a test file with just one line > #include > as mentioned in your post quoted above, which also results in an internal > compiler error: > > g++ -Wall -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB -g -O0 \ > -fno-inline -fPIC -DDEBUG -I/usr/local/include/python2.3 \ > -I/usr/local/include/boost-1_31 -c -o test.os test.cpp > > > /usr/local/include/boost-1_31/boost/python/object_core.hpp:283: internal > compiler error: Segmentation > fault > > Any clues on how to proceed from here? > > Thanks, > Chris > > > > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From rwgk at yahoo.com Fri Jun 25 16:11:43 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Fri, 25 Jun 2004 07:11:43 -0700 (PDT) Subject: [C++-sig] boost.python crush In-Reply-To: <4B6FB7F60D37D41188C300B0D022E0C0029F4390@exchange.lnholdings.com> Message-ID: <20040625141143.96422.qmail@web20224.mail.yahoo.com> Is this under Windows? If yes you have to be very careful how you link. Certain combinations of DLL's lead to obscure failures like yours. There was a thread about this recently; should be in the archieve: http://mail.python.org/pipermail/c++-sig/ Look for "windows", "dll", "debug". If you are using a different platform post the exact details. Ralf --- Max Khesin wrote: > I have the following sample class exposed via boost.python: > > class String > { > public: > String(const std::string& v):m_val(v){} > bool lessThan(const std::string& other) const{return > this->m_val bool greaterThan(const std::string& other) const{return > this->m_val>other;} > bool equals(const std::string& other) const{return > this->m_val==other;} > bool regexMatch(const std::string& other) const{return > this->m_val==other;} > bool withinDistance(const std::string& other, int dist) const{return > distance(this->m_val, other)<=dist;} > private: > std::string m_val; > }; > > > BOOST_PYTHON_MODULE(test) > { > class_("String", init()) > .def("lessThan", &String::lessThan) > .def("greaterThan", &String::greaterThan) > .def("equals", &String::equals) > .def("regexMatch", &String::regexMatch) > .def("withinDistance", &String::withinDistance) > ; > } > > I am calling this from python: > > >> import test > >> s = test.String('hallo') > >> s.lessThen('hello') #### <<< CRUSH > > the debugger seems to point to an access violation in std::string dtor. I > palyed around with making the argument a plain std::string (instead of const > std::string&) and const char* - both of those crush, albeit in a different > place (also dtors, from the looks of it) > > Any idea? > > thanks, > > max > This email and any files transmitted with it are confidential and intended > solely for the use of the individual or entity to whom they are addressed. If > you have received this email in error please notify the system manager. This > message contains confidential information and is intended only for the > individual named. If you are not the named addressee you should not > disseminate, distribute or copy this e-mail. > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail From MKhesin at liquidnet.com Fri Jun 25 16:49:29 2004 From: MKhesin at liquidnet.com (Max Khesin) Date: Fri, 25 Jun 2004 10:49:29 -0400 Subject: [C++-sig] boost.python crush Message-ID: <4B6FB7F60D37D41188C300B0D022E0C0029F4392@exchange.lnholdings.com> Thanks - my searching eventually yielded this: http://www.boost.org/libs/python/doc/building.html#variants with the appropriate VC6 instructions at the bottom. This took care of it. m. > -----Original Message----- > From: Ralf W. Grosse-Kunstleve [mailto:rwgk at yahoo.com] > Sent: Friday, June 25, 2004 10:12 AM > To: Development of Python/C++ integration > Subject: Re: [C++-sig] boost.python crush > > > Is this under Windows? If yes you have to be very careful how > you link. Certain > combinations of DLL's lead to obscure failures like yours. > There was a thread > about this recently; should be in the archieve: > > http://mail.python.org/pipermail/c++-sig/ > > Look for "windows", "dll", "debug". > If you are using a different platform post the exact details. > Ralf > > --- Max Khesin wrote: > > I have the following sample class exposed via boost.python: > > > > class String > > { > > public: > > String(const std::string& v):m_val(v){} > > bool lessThan(const std::string& other) > const{return > > this->m_val > bool greaterThan(const std::string& other) > const{return > > this->m_val>other;} > > bool equals(const std::string& other) > const{return > > this->m_val==other;} > > bool regexMatch(const std::string& other) > const{return > > this->m_val==other;} > > bool withinDistance(const std::string& other, int dist) > const{return > > distance(this->m_val, other)<=dist;} > > private: > > std::string m_val; > > }; > > > > > > BOOST_PYTHON_MODULE(test) > > { > > class_("String", init()) > > .def("lessThan", &String::lessThan) > > .def("greaterThan", &String::greaterThan) > > .def("equals", &String::equals) > > .def("regexMatch", &String::regexMatch) > > .def("withinDistance", &String::withinDistance) > > ; > > } > > > > I am calling this from python: > > > > >> import test > > >> s = test.String('hallo') > > >> s.lessThen('hello') #### <<< CRUSH > > > > the debugger seems to point to an access violation in > std::string dtor. I > > palyed around with making the argument a plain std::string > (instead of const > > std::string&) and const char* - both of those crush, albeit > in a different > > place (also dtors, from the looks of it) > > > > Any idea? > > > > thanks, > > > > max > > This email and any files transmitted with it are > confidential and intended > > solely for the use of the individual or entity to whom they > are addressed. If > > you have received this email in error please notify the > system manager. This > > message contains confidential information and is intended > only for the > > individual named. If you are not the named addressee you should not > > disseminate, distribute or copy this e-mail. > > > > _______________________________________________ > > C++-sig mailing list > > C++-sig at python.org > > http://mail.python.org/mailman/listinfo/c++-sig > > > > > > > __________________________________ > Do you Yahoo!? > New and Improved Yahoo! Mail - Send 10MB messages! > http://promotions.yahoo.com/new_mail > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. From apri7 at mail.ru Sat Jun 26 15:27:07 2004 From: apri7 at mail.ru (Sasha Prikhod'ko) Date: Sat, 26 Jun 2004 17:27:07 +0400 Subject: [C++-sig] Boost: multithreading initiated by a module Message-ID: Dear Python and Boost developers! I encountered a problem with threading in Visual Studio build. Thez a C++ project having in base some special Python site-library. A module start a thread, while a function is called from C++ project. But thread strangely dies at once! What is the reason? --- wrong build, wrong integration, wrong call... Moreover, I cannot certainly recocnize this trouble as serious and tie with plenty of threading discussions... :) Sincerely, Alex From dleary at gmail.com Sat Jun 26 18:59:53 2004 From: dleary at gmail.com (Dusty Leary) Date: Sat, 26 Jun 2004 12:59:53 -0400 Subject: [C++-sig] implicitly_convertible and char* Message-ID: <81c509c04062609594758fdc4@mail.gmail.com> Hello, The implicitly_convertible sample at http://boost.org/libs/python/doc/v2/implicit.html#implicitly_convertible-spec works fine for me. However, changing "int" to "char*" makes it stop working. Compiles fine, won't invoke at runtime. >From the traceback: Boost.Python.ArgumentError: Python argument types in __testmodule__.test_string(X) did not match C++ signature: test_string(char *) I am using MSVC7.1 Any info? From wstwej03 at sneakemail.com Sun Jun 27 05:42:48 2004 From: wstwej03 at sneakemail.com (Eric) Date: Sat, 26 Jun 2004 20:42:48 -0700 Subject: [C++-sig] Help with shared_ptr In-Reply-To: <40CE3E20.1020409@paradise.net.nz> Message-ID: <22226-95764@sneakemail.com> Hello all, I've managed to get myself stuck again, and could use some pointers in how to debug my way out of this situation. I have to kinds of objects that are wrapped in a boost::shared_ptr and returned to python. They are both registered with python like this: boost::python::register_ptr_to_python< boost::shared_ptr >(); boost::python::register_ptr_to_python< boost::shared_ptr >(); the strange thing is that the release function of ClassOne is called when python loses all references to it, but ClassTwo's is never called. From within python I have managed to ensure that ClassTwo is actually being released, by using weakref as follows: # win is my ClassTwo object wr = weakref.ref(win) assert wr() del win sys.exc_clear() gc.collect() assert not wr() So now I am trying to debug this situation. Any help or suggestions are greatly appreciated. Thank you, Eric From faheem at email.unc.edu Sun Jun 27 08:17:51 2004 From: faheem at email.unc.edu (Faheem Mitha) Date: Sun, 27 Jun 2004 06:17:51 +0000 (UTC) Subject: [C++-sig] calling python function from C++ using call Message-ID: Hi, I'm trying to call the function `array' (from the python module numarray.strings) from inside C++ code. This function initializes a character array. It has the arguments array(buffer=None, itemsize=None, shape=None, byteoffset=0, bytestride=None, kind=CharArray) I'm doing this as follows: The C++ end looks like **************************************************************** bcallback.cc **************************************************************** ... object charr(PyObject* func, list buf, object itemsize, tuple sh) { return boost::python::call(func, buf, itemsize, sh); } ... **************************************************************** and the Python end looks like **************************************************************** callback.py **************************************************************** from bcallback import charr import numarray.strings as numstrings def retcharr(buffer, sh): return charr(numstrings.array, buffer, None, sh) **************************************************************** This actually works. Namely: In [2]: import callback In [3]: callback.retcharr(['a', 'c', 'a', 'c', 'a', 'c', 'g', 't', 'g','t','g','t'], (6,2)) Out[3]: CharArray([['a', 'c'], ['a', 'c'], ['a', 'c'], ['g', 't'], ['g', 't'], ['g', 't']]) However, I'm wondering if this is the best way of proceeding, or if there is a better way. Thanks in advance for comments. Faheem. From domma at procoders.net Sun Jun 27 18:00:56 2004 From: domma at procoders.net (Achim Domma (Procoders)) Date: Sun, 27 Jun 2004 18:00:56 +0200 Subject: [C++-sig] Getter/Setter as Property with Pyste Message-ID: Hi, I try to generate Code with Pyste. The wrapped classes have lots of getter and setter functions. The generated code looks like this: .def("borderColor", (void (Magick::Image::*)(const Magick::Color&) )&Magick::Image::borderColor) .def("borderColor", (Magick::Color (Magick::Image::*)() const)&Magick::Image::borderColor) Is there a simple way to tell Pyste to generate an add_property call for 'borderColor' instead of the two functions? regards, Achim From achim.domma at syynx.de Sun Jun 27 18:02:37 2004 From: achim.domma at syynx.de (Achim Domma) Date: Sun, 27 Jun 2004 18:02:37 +0200 Subject: [C++-sig] Getter/Setter as Property with Pyste Message-ID: Hi, I try to generate Code with Pyste. The wrapped classes have lots of getter and setter functions. The generated code looks like this: .def("borderColor", (void (Magick::Image::*)(const Magick::Color&) )&Magick::Image::borderColor) .def("borderColor", (Magick::Color (Magick::Image::*)() const)&Magick::Image::borderColor) Is there a simple way to tell Pyste to generate an add_property call for 'borderColor' instead of the two functions? regards, Achim From faheem at email.unc.edu Sun Jun 27 20:58:48 2004 From: faheem at email.unc.edu (Faheem Mitha) Date: Sun, 27 Jun 2004 18:58:48 +0000 (UTC) Subject: [C++-sig] Re: calling python function from C++ using call References: Message-ID: On Sun, 27 Jun 2004 06:17:51 +0000 (UTC), Faheem Mitha wrote: > Hi, > > I'm trying to call the function `array' (from the python module > numarray.strings) from inside C++ code. This function initializes a > character array. It has the arguments Actually, I do now have a question. I realised that it would be better if the C++ code could call the array function directly. This would involve embedding the interpreter, right? I'd appreciate a confirmation of this. I.e. I'd need to do something equivalent to from numarray.strings import array in the C++ code. I'll try to figure out how to do this from the tutorial and the reference manual, but it would be much appreciated if som kind person would just tell me what the syntax should look like for importing. :-) Pretty please? Faheem. From dave at boost-consulting.com Mon Jun 28 02:39:56 2004 From: dave at boost-consulting.com (David Abrahams) Date: Sun, 27 Jun 2004 20:39:56 -0400 Subject: [C++-sig] Re: implicitly_convertible and char* References: <81c509c04062609594758fdc4@mail.gmail.com> Message-ID: Dusty Leary writes: > The implicitly_convertible sample at > http://boost.org/libs/python/doc/v2/implicit.html#implicitly_convertible-spec > works fine for me. > > However, changing "int" to "char*" makes it stop working. Compiles > fine, won't invoke at runtime. > >>From the traceback: > > Boost.Python.ArgumentError: Python argument types in > __testmodule__.test_string(X) > did not match C++ signature: > test_string(char *) > > I am using MSVC7.1 > > Any info? Full source code of your example? Perhaps the problem is that X isn't actually convertible to char*? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From faheem at email.unc.edu Mon Jun 28 06:26:19 2004 From: faheem at email.unc.edu (Faheem Mitha) Date: Mon, 28 Jun 2004 04:26:19 +0000 (UTC) Subject: [C++-sig] compile errors with embedding example from tutorial Message-ID: Dear People, When trying to compile the following code (direct from sample code in the turorial) I get these errors. I am using distutils and realise my flags may not be exactly right, but the compiler seems to be saying it cannot find the correct version of handler to use! This does not look like it has anything to do with the correct flags, though I could be wrong. I'm trying to call the interpreter from within a extension module. Is there any reason I can't do this? Thanks in advance. Faheem. building 'embed' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.3 -c embed.cc -o /tmp/temp.linux-i686-2.3/embed.o -Wl,-E embed.cc: In function `void foo()': embed.cc:35: error: no matching function for call to ` boost::python::handle::handle(const char[73], int, PyObject*, PyObject*)' /usr/include/boost/python/handle.hpp:129: error: candidates are: boost::python::handle::handle(boost::python ::detail::borrowed_reference_t*) [with T = PyObject] /usr/include/boost/python/handle.hpp:110: error: boost::python::handle::handle(const boost::python::handle&) [with T = PyObject] /usr/include/boost/python/handle.hpp:205: error: boost::python::handle::handle() [with T = PyObject] error: command 'gcc' failed with exit status 1 make: *** [embed.so] Error 1 make: Target `all' not remade because of errors. Compilation exited abnormally with code 2 at Mon Jun 28 00:02:00 ************************************************************************* embed.cc ************************************************************************* #include #include #include #include using namespace boost::python; void foo() { Py_Initialize(); handle<> main_module(borrowed( PyImport_AddModule("__main__") )); handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get()) )); handle<>( PyRun_String("hello = file('hello.txt', 'w')\n" "hello.write('Hello world!')\n" "hello.close()", Py_file_input, main_namespace.get(), main_namespace.get()) ); Py_Finalize(); } BOOST_PYTHON_MODULE(embed) { def("foo",foo); } ************************************************************************* From caustin at gmail.com Mon Jun 28 06:46:06 2004 From: caustin at gmail.com (Chad Austin) Date: Sun, 27 Jun 2004 23:46:06 -0500 Subject: [C++-sig] compile errors with embedding example from tutorial In-Reply-To: References: Message-ID: <2096514e040627214639a53ca5@mail.gmail.com> Hi Faheem, I ran into that too. In short, the line with "handle<>( PyRun_String" isn't being understood how you want it too... You can surround that expression with parenthesis, and it should work: (handle<>( PyRun_String("hello = file('hello.txt', 'w')\n" "hello.write('Hello world!')\n" "hello.close()", Py_file_input, main_namespace.get(), main_namespace.get()) )); Chad On Mon, 28 Jun 2004 04:26:19 +0000 (UTC), Faheem Mitha wrote: > > Dear People, > > When trying to compile the following code (direct from sample code in > the turorial) I get these errors. I am using distutils and realise my > flags may not be exactly right, but the compiler seems to be saying it > cannot find the correct version of handler to use! This does not look > like it has anything to do with the correct flags, though I could be > wrong. > > I'm trying to call the interpreter from within a extension module. Is > there any reason I can't do this? Thanks in advance. > > Faheem. > > building 'embed' extension > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall > -Wstrict-prototypes -fPIC -I/usr/include/python2.3 -c embed.cc -o > /tmp/temp.linux-i686-2.3/embed.o -Wl,-E > embed.cc: In function `void foo()': > embed.cc:35: error: no matching function for call to ` > boost::python::handle::handle(const char[73], int, > PyObject*, > PyObject*)' > /usr/include/boost/python/handle.hpp:129: error: candidates are: > boost::python::handle::handle(boost::python > ::detail::borrowed_reference_t*) > [with T = PyObject] > /usr/include/boost/python/handle.hpp:110: error: > boost::python::handle::handle(const boost::python::handle&) > [with T = > PyObject] > /usr/include/boost/python/handle.hpp:205: error: > boost::python::handle::handle() [with T = PyObject] > error: command 'gcc' failed with exit status 1 > make: *** [embed.so] Error 1 > make: Target `all' not remade because of errors. > > Compilation exited abnormally with code 2 at Mon Jun 28 00:02:00 > > ************************************************************************* > embed.cc > ************************************************************************* > #include > #include > #include > #include > using namespace boost::python; > > void foo() > { > Py_Initialize(); > > handle<> main_module(borrowed( PyImport_AddModule("__main__") )); > > handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get()) )); > > handle<>( PyRun_String("hello = file('hello.txt', 'w')\n" > "hello.write('Hello world!')\n" > "hello.close()", Py_file_input, > main_namespace.get(), main_namespace.get()) ); > > Py_Finalize(); > } > > BOOST_PYTHON_MODULE(embed) > { > def("foo",foo); > } > ************************************************************************* > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From gaiacrtn at free.fr Mon Jun 28 15:21:24 2004 From: gaiacrtn at free.fr (Baptiste Lepilleur) Date: Mon, 28 Jun 2004 15:21:24 +0200 Subject: [C++-sig] pyste, patch to allow injecting code in class definition Message-ID: <008301c45d12$d086b4a0$603f223e@lain> The attached patch allows the user to inject code in the class definition code, just like declaration_code() & module_code(). Among other things, this allows us to add properties when pyste support fail (anonymous union...). Example of usage: Vector3 = Class( "Ogre::Vector3", "OgreVector3.h" ) class_code( Vector3, '.def_readwrite( "x", &Ogre::Vector3::x )' ) class_code( Vector3, '.def_readwrite( "y", &Ogre::Vector3::y )' ) class_code( Vector3, '.def_readwrite( "z", &Ogre::Vector3::z )' ) Which produces: class_< Ogre::Vector3 >("Vector3", init< >()) .def(init< Ogre::Real, Ogre::Real, Ogre::Real >()) .def_readwrite( "x", &Ogre::Vector3::x ) .def_readwrite( "y", &Ogre::Vector3::y ) .def_readwrite( "z", &Ogre::Vector3::z ) ; Baptiste. -------------- next part -------------- A non-text attachment was scrubbed... Name: class_code.patch Type: application/octet-stream Size: 1819 bytes Desc: not available URL: From faheem at email.unc.edu Mon Jun 28 19:48:59 2004 From: faheem at email.unc.edu (Faheem Mitha) Date: Mon, 28 Jun 2004 17:48:59 +0000 (UTC) Subject: [C++-sig] Re: compile errors with embedding example from tutorial References: <2096514e040627214639a53ca5@mail.gmail.com> Message-ID: On Sun, 27 Jun 2004 23:46:06 -0500, Chad Austin wrote: > Hi Faheem, Hi Chad, Thanks for replying. > I ran into that too. In short, the line with "handle<>( PyRun_String" > isn't being understood how you want it too... You can surround that > expression with parenthesis, and it should work: > > (handle<>( PyRun_String("hello = file('hello.txt', 'w')\n" > "hello.write('Hello world!')\n" > "hello.close()", Py_file_input, > main_namespace.get(), main_namespace.get()) )); Thanks. Indeed it does. I hope the tutorial can be changed appropriately, unless it already has been, of course. Any idea why this is necessary? It isn't in the other two places is used. I can load my module, but when I try to run the function, I get NameError: name 'file' is not defined Any idea about this? If you know of other places the tutorial needs to be changed, I would appreciate being informed of them. I think it might be useful if I said explicitly what it is I am trying to do here, and ask for suggestions. I'm writing an extension module, and want to call a python function, namely array from the numarray.strings module. This is part of the Python Numarray library. The question is how to do this. I have tried doing this with callbacks and it seems to work fine. The trouble with callbacks is that it means I have to have a python wrapper with an argument slot for every function I want to import. This is clunky. Suppose I have three functions, say f1, f2, f3. Then I have f1 calling f2 calling f3. f1 -> f2 -> f3 Suppose f3 calls some python function (say `foo') from an external module or something. Then if I rewrite f3 using Boost.Python, I still need a wrapper, say f1', to pass `foo' as an argument. Then I need f1 -> f2 -> f3' -> f3 I suppose I don't need `foo' passed down from f1 because if I import foo into global namespace into the same module where I define f1, f2, f3', then Python's scoping rules will ensure that if I use `foo' as an argument to f3' then it will be picked up from the global namespace. Furthermore, if I decide to rewrite f2 into Boost.Python, then I would have to create another Python wrapper f2' for f2, and pass f3' as an argument to f2' (ugh). So I'd get the following f1 -> f2' -> f2 -> f3' -> f3 I'd rather have f1 -> f2 -> f3 where f2 and f3 only exist as C++ functions. Much cleaner. So I thought that perhaps I could imbed the interpreter inside (say) f3, and persuade it to make `foo' available to me inside C++. I don't know if this is even possible. I have seen no examples of this. In fact, I have seen no examples of using the python interpeter inside extension modules. In fact, I've been rather unsuccessful so far in getting anything related to embedding to work. Am I missing something? Thanks in advance for any information. Faheem. From jeff.holle at verizon.net Mon Jun 28 06:05:01 2004 From: jeff.holle at verizon.net (Jeff Holle) Date: Mon, 28 Jun 2004 00:05:01 -0400 Subject: [C++-sig] Calling a python function from C++. Message-ID: <40DF98ED.8070800@verizon.net> I'm using boost 1_31_0 on Mandrake 10.0 Linux. I've created a simple demonstration of calling a python function with C++ object args using python.boost. It currently works with one exception. In the face of a missing python script, it "aborts" instead of properly throwing an exception if I use the "handle<>" machinery that boost.python offers. The following code fragment contains the working code with the stuff that should do the equivalent, but exibits this problem, commented out. PyObject * /* Returns a borrowed reference */ getPythonFunction(string moduleName,string functionName) { // handle<> _module( PyImport_ImportModule(const_cast(moduleName.c_str()))); // if ( _module.get() == NULL) throwException("The python module \"",moduleName.c_str(),"\" is not available",NULL); // handle<> _namespace(borrowed( PyModule_GetDict(_module.get()))); // if ( _namespace.get() == NULL) throwException("Failed to acquire the dictionary of \"",moduleName.c_str(),"\"",NULL); // handle<> _function(borrowed(PyDict_GetItemString( _namespace.get(),functionName.c_str()))); // if ( _function.get() == NULL) throwException("Failed to find needed function \"",functionName.c_str(),"\"",NULL); // return _function.get(); PyObject *pModule = PyImport_ImportModule(const_cast(moduleName.c_str())); if ( pModule == NULL) throwException("The python module \"",moduleName.c_str(),"\" is not available",NULL); PyObject *pDict = PyModule_GetDict(pModule); if ( pDict == NULL) throwException("Failed to acquire the dictionary of \"",moduleName.c_str(),"\"",NULL); PyObject *pFunc = PyDict_GetItemString(pDict,functionName.c_str()); if ( pFunc == NULL) throwException("Failed to find requested python function \"",functionName.c_str(),"\"",NULL); Py_DECREF(pModule); return pFunc; } In this form, this function throws a std::run_time exception which is successfully caught with a "catch (exception& x)" clause. With the commented out section active, something is thrown, but it can only be caught with "catch(...)". I'm wondering if anybody can explain this. I'm also wondering if I could contribute this example to boost.python. The python script that I call is: import sys from Greeter import * def AlterGreeting( greeting): greeting.setLanguage("Python") return greeting.greet() if __name__ == '__main__': print 'testing module' greetingObj = Greeter("C++") greeting = AlterGreeting(greetingObj) print greeting Note that the Greeter module is a C++ extension module also created with boost.python using pyste. The C++ part of this example does the same thing that the main module specific section of this python script does. If anybody wants this example, simple request it. I'll provide the complete project, which uses bjam v1, in a tar ball. From caustin at gmail.com Mon Jun 28 22:56:13 2004 From: caustin at gmail.com (Chad Austin) Date: Mon, 28 Jun 2004 15:56:13 -0500 Subject: [C++-sig] Re: compile errors with embedding example from tutorial In-Reply-To: References: <2096514e040627214639a53ca5@mail.gmail.com> Message-ID: <2096514e04062813561ceb1d79@mail.gmail.com> On Mon, 28 Jun 2004 17:48:59 +0000 (UTC), Faheem Mitha wrote: > > On Sun, 27 Jun 2004 23:46:06 -0500, Chad Austin wrote: > > > Hi Faheem, > > Hi Chad, > > Thanks for replying. > > > I ran into that too. In short, the line with "handle<>( PyRun_String" > > isn't being understood how you want it too... You can surround that > > expression with parenthesis, and it should work: > > > > (handle<>( PyRun_String("hello = file('hello.txt', 'w')\n" > > "hello.write('Hello world!')\n" > > "hello.close()", Py_file_input, > > main_namespace.get(), main_namespace.get()) )); > > Thanks. Indeed it does. I hope the tutorial can be changed > appropriately, unless it already has been, of course. Any idea why > this is necessary? It isn't in the other two places is used. I think it's something to do with C++ thinking you're trying to declare a function or function pointer or something. That's the best I could come up with... Any insight from others would be appreciated. :) > I can load my module, but when I try to run the function, I get > > NameError: name 'file' is not defined > > Any idea about this? Nope, sorry... I had a problem similar to that in that __builtins__ wasn't getting set in my modules, but I was doing some weird stuff. You may want to at least check that __builtins__ is set in your script. > If you know of other places the tutorial needs to be changed, I would > appreciate being informed of them. > > I think it might be useful if I said explicitly what it is I am trying > to do here, and ask for suggestions. > > I'm writing an extension module, and want to call a python function, > namely array from the numarray.strings module. This is part of the > Python Numarray library. The question is how to do this. Something like: object m = object(handle<>( PyImport_Import("numarray.strings") )); object result = m.attr("array")(arguments); should work for you. > I have tried doing this with callbacks and it seems to work fine. The > trouble with callbacks is that it means I have to have a python > wrapper with an argument slot for every function I want to > import. This is clunky. > > Suppose I have three functions, say f1, f2, f3. > > Then I have f1 calling f2 calling f3. > > f1 -> f2 -> f3 > > Suppose f3 calls some python function (say `foo') from an external > module or something. > > Then if I rewrite f3 using Boost.Python, I still need a wrapper, say > f1', to pass `foo' as an argument. Then I need > > f1 -> f2 -> f3' -> f3 > > I suppose I don't need `foo' passed down from f1 because if I import > foo into global namespace into the same module where I define f1, f2, > f3', then Python's scoping rules will ensure that if I use `foo' as an > argument to f3' then it will be picked up from the global namespace. > > Furthermore, if I decide to rewrite f2 into Boost.Python, then I would > have to create another Python wrapper f2' for f2, and pass f3' as an > argument to f2' (ugh). So I'd get the following > > f1 -> f2' -> f2 -> f3' -> f3 > > I'd rather have > > f1 -> f2 -> f3 > > where f2 and f3 only exist as C++ functions. Much cleaner. > > So I thought that perhaps I could imbed the interpreter inside (say) > f3, and persuade it to make `foo' available to me inside C++. I don't > know if this is even possible. I have seen no examples of this. In > fact, I have seen no examples of using the python interpeter inside > extension modules. In fact, I've been rather unsuccessful so far in > getting anything related to embedding to work. I'm totally confused by everything you just said about callbacks, but you should be able to easily call back into Python from C++ using Boost.Python's object (and related subclasses) or even the native Python/C API. I don't see a reason importing another native module from a native module would cause a problem, as long as you write your C++ code in the same way you'd write the Python. > Am I missing something? Thanks in advance for any information. Hope that helps, -- Chad Austin http://aegisknight.org/ From dleary at gmail.com Tue Jun 29 00:17:03 2004 From: dleary at gmail.com (Dusty Leary) Date: Mon, 28 Jun 2004 18:17:03 -0400 Subject: [C++-sig] Re: implicitly_convertible and char* In-Reply-To: References: <81c509c04062609594758fdc4@mail.gmail.com> Message-ID: <81c509c04062815172a69324a@mail.gmail.com> full source code: ================================================ #define BOOST_PYTHON_STATIC_LIB #include using namespace boost::python; struct X { std::string v; X(const std::string& s) : v(s) {} operator char*() const { return (char*)v.c_str(); } }; void test_x(X& x) { char* x_string = x; printf("test_x: %s\n", x_string); } void test_string(char* s) { printf("test_string: %s\n", s); } BOOST_PYTHON_MODULE(test_string) { class_("X", init()); def("test_x", test_x); def("test_string", test_string); implicitly_convertible(); } ================================================ interpreter: >>> import test_string >>> x = test_string.X("foo") >>> test_string.test_x(x) test_x: foo >>> test_string.test_string("blah") test_string: blah >>> test_string.test_string(x) Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in test_string.test_string(X) did not match C++ signature: test_string(char *) On Sun, 27 Jun 2004 20:39:56 -0400, David Abrahams wrote: > > > Dusty Leary writes: > > > The implicitly_convertible sample at > > http://boost.org/libs/python/doc/v2/implicit.html#implicitly_convertible-spec > > works fine for me. > > > > However, changing "int" to "char*" makes it stop working. Compiles > > fine, won't invoke at runtime. > > > >>From the traceback: > > > > Boost.Python.ArgumentError: Python argument types in > > __testmodule__.test_string(X) > > did not match C++ signature: > > test_string(char *) > > > > I am using MSVC7.1 > > > > Any info? > > Full source code of your example? > Perhaps the problem is that X isn't actually convertible to char*? > > -- > Dave Abrahams > Boost Consulting > http://www.boost-consulting.com > > _______________________________________________ > C++-sig mailing list > C++-sig at python.org > http://mail.python.org/mailman/listinfo/c++-sig > From faheem at email.unc.edu Tue Jun 29 00:30:33 2004 From: faheem at email.unc.edu (Faheem Mitha) Date: Mon, 28 Jun 2004 18:30:33 -0400 Subject: [C++-sig] Re: Calling a python function from C++. In-Reply-To: <40DF98ED.8070800@verizon.net> References: <40DF98ED.8070800@verizon.net> Message-ID: In gmane.comp.python.c++, you wrote: > I'm using boost 1_31_0 on Mandrake 10.0 Linux. > > I've created a simple demonstration of calling a python function with > C++ object args using python.boost. > It currently works with one exception. In the face of a missing python > script, it "aborts" instead of properly throwing an exception if I use > the "handle<>" machinery that boost.python offers. The following code > fragment contains the working code with the stuff that should do the > equivalent, but exibits this problem, commented out. Hi Jeff, I'd be interested to see your code. I am trying (not very successfully so far) to figure out this stuff myself, and any working examples are helpful. It sounds like you have a better handle on this stuff (no pun intended) than I do. :-) Please email it to the my email address shown above. Thanks. Faheem. From faheem at email.unc.edu Tue Jun 29 00:39:15 2004 From: faheem at email.unc.edu (Faheem Mitha) Date: Mon, 28 Jun 2004 22:39:15 +0000 (UTC) Subject: [C++-sig] Re: compile errors with embedding example from tutorial References: <2096514e040627214639a53ca5@mail.gmail.com> <2096514e04062813561ceb1d79@mail.gmail.com> Message-ID: On Mon, 28 Jun 2004 15:56:13 -0500, Chad Austin wrote: > On Mon, 28 Jun 2004 17:48:59 +0000 (UTC), Faheem Mitha > wrote: >> >> On Sun, 27 Jun 2004 23:46:06 -0500, Chad Austin wrote: > Nope, sorry... I had a problem similar to that in that __builtins__ > wasn't getting set in my modules, but I was doing some weird stuff. > You may want to at least check that __builtins__ is set in your > script. How should I do that? I thought that handle<> main_module(borrowed( PyImport_AddModule("__main__") )); handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get()))); should do the trick, though I don't really understand what these lines do. I wonder if the fact that I am calling the interpreter inside an extension module is causing any problems. >> If you know of other places the tutorial needs to be changed, I would >> appreciate being informed of them. >> >> I think it might be useful if I said explicitly what it is I am trying >> to do here, and ask for suggestions. >> >> I'm writing an extension module, and want to call a python function, >> namely array from the numarray.strings module. This is part of the >> Python Numarray library. The question is how to do this. > > Something like: > > object m = object(handle<>( PyImport_Import("numarray.strings") )); > object result = m.attr("array")(arguments); > > should work for you. Ok. Thanks. >> I have tried doing this with callbacks and it seems to work fine. The >> trouble with callbacks is that it means I have to have a python >> wrapper with an argument slot for every function I want to >> import. This is clunky. [stuff deleted...] > I'm totally confused by everything you just said about callbacks, but > you should be able to easily call back into Python from C++ using > Boost.Python's object (and related subclasses) or even the native > Python/C API. I don't see a reason importing another native module > from a native module would cause a problem, as long as you write your > C++ code in the same way you'd write the Python. Sorry I was unclear. I'd be willing to try to clarify if that would be useful. I can certainly make callbacks work. The point is I have to pass the relevant functions from Python, which imposes some overhead, which I'd like to get rid of. Faheem. From caustin at gmail.com Tue Jun 29 07:58:48 2004 From: caustin at gmail.com (Chad Austin) Date: Tue, 29 Jun 2004 00:58:48 -0500 Subject: [C++-sig] Re: compile errors with embedding example from tutorial In-Reply-To: References: <2096514e040627214639a53ca5@mail.gmail.com> <2096514e04062813561ceb1d79@mail.gmail.com> Message-ID: <2096514e0406282258665b43c8@mail.gmail.com> On Mon, 28 Jun 2004 22:39:15 +0000 (UTC), Faheem Mitha wrote: > > On Mon, 28 Jun 2004 15:56:13 -0500, Chad Austin wrote: > > On Mon, 28 Jun 2004 17:48:59 +0000 (UTC), Faheem Mitha > > wrote: > >> > >> On Sun, 27 Jun 2004 23:46:06 -0500, Chad Austin wrote: > > > Nope, sorry... I had a problem similar to that in that __builtins__ > > wasn't getting set in my modules, but I was doing some weird stuff. > > You may want to at least check that __builtins__ is set in your > > script. > > How should I do that? I thought that > > handle<> main_module(borrowed( PyImport_AddModule("__main__") )); > handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get()))); > > should do the trick, though I don't really understand what these lines > do. I wonder if the fact that I am calling the interpreter inside an > extension module is causing any problems. Just try evaluating the script "import __builtin__" or "str(10)" and see if it fails or not. ;) There should be no problem with calling interpreter from an extension module. Language bindings are a two-way street, so there necessarily must be communication between the two languages. -- Chad Austin http://aegisknight.org/ From thor.arne.johansen at ibas.no Tue Jun 29 10:38:55 2004 From: thor.arne.johansen at ibas.no (thor.arne.johansen at ibas.no) Date: Tue, 29 Jun 2004 10:38:55 +0200 Subject: [C++-sig] Re: Calling a python function from C++. Message-ID: >In gmane.comp.python.c++, you wrote: >> I'm using boost 1_31_0 on Mandrake 10.0 Linux. >> >> I've created a simple demonstration of calling a python function with >> C++ object args using python.boost. >> It currently works with one exception. In the face of a missing python >> script, it "aborts" instead of properly throwing an exception if I use >> the "handle<>" machinery that boost.python offers. The following code >> fragment contains the working code with the stuff that should do the >> equivalent, but exibits this problem, commented out. > >Hi Jeff, > >I'd be interested to see your code. I am trying (not very successfully >so far) to figure out this stuff myself, and any working examples are >helpful. It sounds like you have a better handle on this stuff (no pun >intended) than I do. :-) > >Please email it to the my email address shown above. Thanks. > > Faheem. A while back I posted some example code for embedding python and have python 'scripts' manipulate C++ objects. It might also be of interest: http://mail.python.org/pipermail/c++-sig/2002-December/002833.html -- Thor Arne Johansen Dept. Manager R&D Ibas AS From dave at boost-consulting.com Tue Jun 29 15:58:33 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 29 Jun 2004 09:58:33 -0400 Subject: [C++-sig] Re: Calling a python function from C++. References: <40DF98ED.8070800@verizon.net> Message-ID: Jeff Holle writes: > I'm using boost 1_31_0 on Mandrake 10.0 Linux. > > I've created a simple demonstration of calling a python function with > C++ object args using python.boost. > It currently works with one exception. In the face of a missing > python script, it "aborts" instead of properly throwing an exception > if I use the "handle<>" machinery that boost.python offers. The > following code fragment contains the working code with the stuff that > should do the equivalent, but exibits this problem, commented out. > > PyObject * /* Returns a borrowed reference */ > getPythonFunction(string moduleName,string functionName) > { > // handle<> _module( PyImport_ImportModule(const_cast *>(moduleName.c_str()))); > // if ( _module.get() == NULL) throwException("The python module > \"",moduleName.c_str(),"\" is not available",NULL); > // handle<> _namespace(borrowed( PyModule_GetDict(_module.get()))); > // if ( _namespace.get() == NULL) throwException("Failed to acquire > the dictionary of \"",moduleName.c_str(),"\"",NULL); > // handle<> _function(borrowed(PyDict_GetItemString( > _namespace.get(),functionName.c_str()))); > // if ( _function.get() == NULL) throwException("Failed to find > needed function \"",functionName.c_str(),"\"",NULL); > // return _function.get(); Why struggle? This should be: object /* Returns a borrowed reference */ getPythonFunction(string moduleName,string functionName) { object _module(handle<>( PyImport_ImportModule( const_cast(moduleName.c_str())))); return _module.attr(functionName.c_str()); } -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From dave at boost-consulting.com Tue Jun 29 17:51:48 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 29 Jun 2004 11:51:48 -0400 Subject: [C++-sig] Re: compile errors with embedding example from tutorial References: <2096514e040627214639a53ca5@mail.gmail.com> <2096514e04062813561ceb1d79@mail.gmail.com> Message-ID: Faheem Mitha writes: > On Mon, 28 Jun 2004 15:56:13 -0500, Chad Austin wrote: >> On Mon, 28 Jun 2004 17:48:59 +0000 (UTC), Faheem Mitha >> wrote: >>> >>> On Sun, 27 Jun 2004 23:46:06 -0500, Chad Austin wrote: > >> Nope, sorry... I had a problem similar to that in that __builtins__ >> wasn't getting set in my modules, but I was doing some weird stuff. >> You may want to at least check that __builtins__ is set in your >> script. > > How should I do that? I thought that > > handle<> main_module(borrowed( PyImport_AddModule("__main__") )); > handle<> main_namespace(borrowed( PyModule_GetDict(main_module.get()))); > > should do the trick, though I don't really understand what these lines > do. What specifically are you confused about? Did you check the docs? I don't know why you'd do it that way when you can write: object main_module(handle<>(borrowed( PyImport_AddModule("__main__")))); object main_namespace = main_module.attr("__dict__"); instead. > I wonder if the fact that I am calling the interpreter inside an > extension module is causing any problems. Certainly not. Calling the interpreter inside an extension module is normal. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From dave at boost-consulting.com Tue Jun 29 17:54:55 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 29 Jun 2004 11:54:55 -0400 Subject: [C++-sig] Re: implicitly_convertible and char* References: <81c509c04062609594758fdc4@mail.gmail.com> <81c509c04062815172a69324a@mail.gmail.com> Message-ID: Dusty Leary writes: > full source code: > ================================================ > #define BOOST_PYTHON_STATIC_LIB > > #include > using namespace boost::python; > > struct X { > std::string v; > X(const std::string& s) : v(s) {} > operator char*() const { return (char*)v.c_str(); } > }; > > void test_x(X& x) { > char* x_string = x; > printf("test_x: %s\n", x_string); > } > > void test_string(char* s) { > printf("test_string: %s\n", s); > } Oh! char* is not a C++ string, and there's no built-in converter for that. I note that you're casting away the const-ness of v.c_str() above; that's very bad juju. If you make char* into char const* everywhere, your example should work. Alternatively, you can also register a custom from_python converter for char*... but I recommend against it. > > BOOST_PYTHON_MODULE(test_string) { > class_("X", init()); > def("test_x", test_x); > def("test_string", test_string); > implicitly_convertible(); > } > ================================================ > > interpreter: > >>>> import test_string >>>> x = test_string.X("foo") >>>> test_string.test_x(x) > test_x: foo >>>> test_string.test_string("blah") > test_string: blah >>>> test_string.test_string(x) > Traceback (most recent call last): > File "", line 1, in ? > Boost.Python.ArgumentError: Python argument types in > test_string.test_string(X) > did not match C++ signature: > test_string(char *) -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From hoeppler at diener.iap.physik.uni-tuebingen.de Tue Jun 29 18:01:42 2004 From: hoeppler at diener.iap.physik.uni-tuebingen.de (Chris Hoeppler) Date: Tue, 29 Jun 2004 18:01:42 +0200 (CEST) Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: <20040625135525.94532.qmail@web20205.mail.yahoo.com> Message-ID: On Fri, 25 Jun 2004, Ralf W. Grosse-Kunstleve wrote: > You have to strip down the code until you've isolated the construct that causes > the ICE. Then try to rearrange that construct until the ICE goes away. In the > early days of Boost.Python I've done this a million times, and I am sure David > did it a billion times. It always takes too long, is very frustrating, and > therefore requires a lot of determination. If this is not enough to scare you, > copy the content of boost/python.hpp into your source file, then comment out > half the includes, see if it still ICE's, if yes comment out half of the > remaining, if not put back half of the ones you commented out, and so on until > you've found that one include that makes a difference. Then copy that into your > source code and repeat the exercise until you found the piece of code that > makes the difference. Then go into a different trial-and-error loop rearranging > the code. While the first step requires mainly determination, you will need > some creativity here. Often my last resort was to ask David. Finally you have > to communicate the fix to the developers of the effected library (e.g. it could > be in boost::graph or boost::bind or, heaven forbid, in boost::mpl or ...) and > convince them to adopt your fix. Okay. Thanks for the encouragement, Ralf. Here's the result of my 'investigation': On the following system: gcc version 3.3.1 (SuSE Linux 9.0) boost-1.31 if I try to compile (copied to test.cpp) with the following command line g++ -Wall -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB -g -O0 -fno-inline -fPIC -DDEBUG -I/usr/local/include/python2.3 -I/usr/local/include/boost-1_31 -c -o test.os test.cpp the compiler segfaults with the following message: /usr/include/g++/bits/basic_string.h:728: internal compiler error: Segmentation fault The relevant line in translate_exception.hpp triggering the segfault is indicated below: template struct translate_exception { typedef typename add_reference< typename add_const::type >::type exception_cref; inline bool operator()( exception_handler const& handler , function0 const& f , typename call_traits::param_type translate) const { try { return handler(f); } catch(exception_cref e) --------------^^^^^^^^^^^^^^^^ { translate(e); return true; } } }; FWIW, the compiler is happy with "catch(exception_cref &e)", though I do --------------------------------------------------------^ not know whether it would be okay to make that change... Chris. From dave at boost-consulting.com Tue Jun 29 18:36:53 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 29 Jun 2004 12:36:53 -0400 Subject: [C++-sig] Re: Boost.Python in SUSE 9.0 or SUSE 9.1? References: <20040625135525.94532.qmail@web20205.mail.yahoo.com> Message-ID: Chris Hoeppler writes: > FWIW, the compiler is happy with "catch(exception_cref &e)", though I do > --------------------------------------------------------^ > not know whether it would be okay to make that change... Sure; you can do that in your local copy. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From jeff.holle at verizon.net Tue Jun 29 04:30:50 2004 From: jeff.holle at verizon.net (Jeff Holle) Date: Mon, 28 Jun 2004 22:30:50 -0400 Subject: [C++-sig] Re: Calling a python function from C++ Message-ID: <40E0D45A.4020001@verizon.net> Dave wrote: Why struggle? This should be: object /* Returns a borrowed reference */ getPythonFunction(string moduleName,string functionName) { object _module(handle<>( PyImport_ImportModule(const_cast(moduleName.c_str())))); <<-- line 63 in Main.cpp return _module.attr(functionName.c_str()); } ------------------------------------------------------------------------ Always a good question. The code doesn't compile as presented. I added #include to my module, have completely opened the boost::python namespace. Get the error: Main.cpp:63: error: variable declaration is not allowed here If I just instanciate an empty object with its default constructor, the module compiles. An underlining concern I have is error handling. When PyImport_ImportModule fails, a NULL pointer is returned. Seems like the underlining machinery in "handle<>" is intolerant of this. From dleary at gmail.com Tue Jun 29 22:05:42 2004 From: dleary at gmail.com (Dusty Leary) Date: Tue, 29 Jun 2004 16:05:42 -0400 Subject: [C++-sig] Re: implicitly_convertible and char* In-Reply-To: References: <81c509c04062609594758fdc4@mail.gmail.com> <81c509c04062815172a69324a@mail.gmail.com> Message-ID: <81c509c040629130556f7312d@mail.gmail.com> > > Oh! > > char* is not a C++ string, and there's no built-in converter for that. > I note that you're casting away the const-ness of v.c_str() above; > that's very bad juju. If you make char* into char const* everywhere, > your example should work. Alternatively, you can also register a > custom from_python converter for char*... but I recommend against it. > yeah, I just wrote up the simple test like that because I was lazy and didn't think it would make a difference. the same problem occurs with const char* new source code: =================================================== #define BOOST_PYTHON_STATIC_LIB #include using namespace boost::python; struct X { std::string v; X(const std::string& s) : v(s) {} operator char const*() const { return v.c_str(); } }; void test_x(X& x) { char const* x_string = x; printf("test_x: %s\n", x_string); } void test_string(char const* s) { printf("test_string: %s\n", s); } BOOST_PYTHON_MODULE(test_string) { class_("X", init()); def("test_x", test_x); def("test_string", test_string); implicitly_convertible(); } =================================================== >>> import test_string >>> x = test_string.X("foo") >>> test_string.test_string(x) Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in test_string.test_string(X) did not match C++ signature: test_string(char const *) >>> From rwgk at yahoo.com Tue Jun 29 22:56:54 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 29 Jun 2004 13:56:54 -0700 (PDT) Subject: [C++-sig] Re: implicitly_convertible and char* In-Reply-To: <81c509c040629130556f7312d@mail.gmail.com> Message-ID: <20040629205654.59109.qmail@web20212.mail.yahoo.com> I don't really feel competent in this matter, but I believe char const* and const char* are two different things. Did you try it with "const char*"? --- Dusty Leary wrote: > > > > Oh! > > > > char* is not a C++ string, and there's no built-in converter for that. > > I note that you're casting away the const-ness of v.c_str() above; > > that's very bad juju. If you make char* into char const* everywhere, > > your example should work. Alternatively, you can also register a > > custom from_python converter for char*... but I recommend against it. > > > > yeah, I just wrote up the simple test like that because I was lazy and > didn't think it would make a difference. the same problem occurs with > const char* > > new source code: > =================================================== > #define BOOST_PYTHON_STATIC_LIB > > #include > using namespace boost::python; > > struct X { > std::string v; > X(const std::string& s) : v(s) {} > operator char const*() const { return v.c_str(); } > }; > > void test_x(X& x) { > char const* x_string = x; > printf("test_x: %s\n", x_string); > } > > void test_string(char const* s) { > printf("test_string: %s\n", s); > } > > BOOST_PYTHON_MODULE(test_string) { > class_("X", init()); > def("test_x", test_x); > def("test_string", test_string); > implicitly_convertible(); > } > =================================================== > > >>> import test_string > >>> x = test_string.X("foo") > >>> test_string.test_string(x) > Traceback (most recent call last): > File "", line 1, in ? > Boost.Python.ArgumentError: Python argument types in > test_string.test_string(X) > did not match C++ signature: > test_string(char const *) > >>> __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail From mike at nospam.com Tue Jun 29 23:34:40 2004 From: mike at nospam.com (Mike Rovner) Date: Tue, 29 Jun 2004 14:34:40 -0700 Subject: [C++-sig] Re: Re: implicitly_convertible and char* References: <81c509c040629130556f7312d@mail.gmail.com> <20040629205654.59109.qmail@web20212.mail.yahoo.com> Message-ID: Ralf W. Grosse-Kunstleve wrote: > I don't really feel competent in this matter, but I believe char > const* and const char* are two different things. Did you try it with > "const char*"? Nope. That's the same (read from right to left). Different things is ...* const (constant pointer itself). Mike PS. only ddd afaik treat them differently ;) From rwgk at yahoo.com Tue Jun 29 23:54:34 2004 From: rwgk at yahoo.com (Ralf W. Grosse-Kunstleve) Date: Tue, 29 Jun 2004 14:54:34 -0700 (PDT) Subject: [C++-sig] Re: Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: Message-ID: <20040629215434.65607.qmail@web20212.mail.yahoo.com> --- David Abrahams wrote: > Chris Hoeppler writes: > > > FWIW, the compiler is happy with "catch(exception_cref &e)", though I do > > --------------------------------------------------------^ > > not know whether it would be okay to make that change... > > Sure; you can do that in your local copy. David is telling me: > > Hi David, I think he was asking if we can make that change in the main version . > > I think we should unless you have objections. I can run tests on all our > > platforms to make sure it works everywhere. Please let me know. > Yes, I have objections, at least if you don't make the patch very > precise and conditional. It will break on many compilers. The > add_reference invocation above it should have already added a > reference and many compilers (even most GCCs?) will choke on adding a > reference to a type that is already a reference. I.e. what we need is a very specific set of #ifdef's that will apply your patch only under SUSE 9, and only if the compiler with SUSE's patches is used. Here is an alias that is sometimes helpful in pin-pointing system specific macros: alias whatdefg++ 'echo '"'"'int main(void){return 0;}'"'"' > /var/tmp/tmp$$.cpp; g++ -E -v \!* /var/tmp/tmp$$.cpp; rm -f /var/tmp/tmp$$.cpp' Please use BOOST_WORKAROUND. There are lots of examples in the boost code, e.g. boost/python/object/value_holder.hpp. Ralf __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail From paul.bridger at paradise.net.nz Wed Jun 30 02:08:31 2004 From: paul.bridger at paradise.net.nz (paul.bridger) Date: Wed, 30 Jun 2004 12:08:31 +1200 Subject: [C++-sig] Abstract classes Message-ID: <40E2047F.7050107@paradise.net.nz> Pyste was generating constructors defs for abstract classes. I've changed Pyste so that it will insert no_init (and emit no constructors) for abstract classes. Is this the correct behaviour for an abstract class? eg. class_< Foo, boost::noncopyable>("Foo", no_init) This from the FAQ states this quite clearly: http://www.python.org/cgi-bin/moinmoin/boost_2epython_2fFAQ > * no_init means "do not try to create an instance of that Python object, create __init__ function that throws an exception" > * noncopyable means "do not try to register a converter which can convert C++ return values of that class to Python". > > When wrapping an abstract class, it's necessary to specify both. However, what's confusing me is that I thought specifying no_init would make the following incorrect: class Bar(CppModule.Foo): def __init__(self): CppModule.Foo.__init__(self) Is that correct? From dave at boost-consulting.com Wed Jun 30 02:49:13 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 29 Jun 2004 20:49:13 -0400 Subject: [C++-sig] Re: Calling a python function from C++ References: <40E0D45A.4020001@verizon.net> Message-ID: Jeff Holle writes: > Dave wrote: > > Why struggle? > This should be: > > object /* Returns a borrowed reference */ > getPythonFunction(string moduleName,string functionName) > { > object _module(handle<>( PyImport_ImportModule(const_cast(moduleName.c_str())))); <<-- line 63 in Main.cpp > > return _module.attr(functionName.c_str()); > } > > ------------------------------------------------------------------------ > > Always a good question. > The code doesn't compile as presented. Oh, it should; GCC bug it looks like. object getPythonFunction(string moduleName,string functionName) { object _module = object( handle<>( PyImport_ImportModule(const_cast(moduleName.c_str())) ) ); return _module.attr(functionName.c_str()); } or object getPythonFunction(string moduleName,string functionName) { object _module(( handle<>( PyImport_ImportModule(const_cast(moduleName.c_str())) ) )); return _module.attr(functionName.c_str()); } works. > An underlining concern I have is error handling. When > PyImport_ImportModule fails, a NULL pointer is returned. > Seems like the underlining machinery in "handle<>" is intolerant of > this. What makes you say that? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From dave at boost-consulting.com Wed Jun 30 02:49:39 2004 From: dave at boost-consulting.com (David Abrahams) Date: Tue, 29 Jun 2004 20:49:39 -0400 Subject: [C++-sig] Re: implicitly_convertible and char* References: <81c509c040629130556f7312d@mail.gmail.com> <20040629205654.59109.qmail@web20212.mail.yahoo.com> Message-ID: "Ralf W. Grosse-Kunstleve" writes: > I don't really feel competent in this matter, but I believe char const* and > const char* are two different things. Did you try it with "const char*"? They are the same thing. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From jeff.holle at verizon.net Tue Jun 29 12:22:37 2004 From: jeff.holle at verizon.net (Jeff Holle) Date: Tue, 29 Jun 2004 06:22:37 -0400 Subject: [C++-sig] Re: Calling a python function from C++ (from Jeff Holle) Message-ID: <40E142ED.2030603@verizon.net> > > >> An underlining concern I have is error handling. When >> PyImport_ImportModule fails, a NULL pointer is returned. >> Seems like the underlining machinery in "handle<>" is intolerant of >> this. > > > >What makes you say that? > You are correct about the success in compiling your much cleaner example, and it works :-) , but has a flaw. When I hide the needed python script, the call to PyImport_ImportModule returns NULL. When this occurres, both your example and what I had created, but commented out throws something because I can catch it with "catch(...)". I don't however know how to be more specific. Any hints? Whatever it is, it doesn't inherit from "exception". If I was operating on windows, I would anticipate it was a "structured exception", or whatever Microsoft calls their propritary stuff. Don't know of the equivalent on linux though. Without the "catch (...)", the command line program exits with "Aborted". From jbrandmeyer at earthlink.net Wed Jun 30 04:35:43 2004 From: jbrandmeyer at earthlink.net (Jonathan Brandmeyer) Date: Tue, 29 Jun 2004 22:35:43 -0400 Subject: [C++-sig] Boost.Python in SUSE 9.0 or SUSE 9.1? In-Reply-To: <2096514e04062507072f0ff45@mail.gmail.com> References: <20040624144241.53669.qmail@web20207.mail.yahoo.com> <2096514e04062507072f0ff45@mail.gmail.com> Message-ID: <1088562942.3005.17.camel@illuvatar> On Fri, 2004-06-25 at 10:07, Chad Austin wrote: > After some investigation, it appears SUSE applies some custom patches > to their gcc builds, causing including boost/python.hpp to ICE. I've > submitted a support request to SUSE for this issue. Installing a > compatible gcc from source into /usr/local appears to work around the > problem. A coworker has SUSE 9.0 installed on his laptop and ran into the same issue a couple of weeks ago. He is out of the country on business right now, so I'm going on memory about what we did. When he contacted Suse about the issue, they said that they would not do anything about it, since he could install a working GCC from source. He used GCC 3.3.3 from gcc.org (it was the latest in the 3.3 series at that time), rebuilt Boost and the extensions with that, and everything worked. Using the --program-suffix= and --enable-version-specific-runtime-libs to GCC's configure ensured that the new compiler didn't stomp on Suse's custom compiler. Finally, we used the -sGXX= option to bjam to point it at the new compiler. > > > If I build gcc 3.4.0 from > > > source, Boost.Python compiles, but does not link do to > > > incompatibilities in libstdc++.> > > > > Does the link command fail, or is it a run-time failure (i.e. dlopen fails)? > > If it is the latter you might have to update the LD_LIBRARY_PATH. This is what > > I am using to activate gcc 3.4 in a new shell: > > I believe it was an ABI change in libstdc++ or something. My boost > was compiled with gcc 3.3 and my app with 3.4. I just started getting > random crashes. Gcc 3.4 uses libstdc++.so.6 while GCC 3.3 and 3.2 use libstdc++.so.5. They don't mix in the same program. HTH, -Jonathan From roman.yakovenko at actimize.com Wed Jun 30 08:23:20 2004 From: roman.yakovenko at actimize.com (Roman Yakovenko) Date: Wed, 30 Jun 2004 09:23:20 +0300 Subject: [C++-sig] Abstract classes Message-ID: <2D89F6C4A80FA547BF5D5B8FDDD0452325386B@exchange.adrembi.com> Paul wrote: > Pyste was generating constructors defs for abstract classes. > I've changed > Pyste so that it will insert no_init (and emit no > constructors) for abstract > classes. > > Is this the correct behaviour for an abstract class? > eg. > class_< Foo, boost::noncopyable>("Foo", no_init) > > This from the FAQ states this quite clearly: > http://www.python.org/cgi-bin/moinmoin/boost_2epython_2fFAQ > > * no_init means "do not try to create an instance of > that Python object, create __init__ function that throws an exception" > > * noncopyable means "do not try to register a converter > which can convert C++ return values of that class to Python". > > > > When wrapping an abstract class, it's necessary to specify both. > > However, what's confusing me is that I thought specifying > no_init would make > the following incorrect: > > class Bar(CppModule.Foo): > def __init__(self): > CppModule.Foo.__init__(self) > > Is that correct? I think this is correct. Abstract class has constructors. Roman --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.707 / Virus Database: 463 - Release Date: 6/15/2004 From shin1_morita at yahoo.co.jp Wed Jun 30 17:03:09 2004 From: shin1_morita at yahoo.co.jp (Shin-ichi MORITA) Date: Thu, 1 Jul 2004 00:03:09 +0900 (JST) Subject: [C++-sig] Abstract classes In-Reply-To: <2D89F6C4A80FA547BF5D5B8FDDD0452325386B@exchange.adrembi.com> Message-ID: <20040630150309.44127.qmail@web2303.mail.yahoo.co.jp> Hi, > Paul wrote: > > > Pyste was generating constructors defs for > abstract classes. > > I've changed > > Pyste so that it will insert no_init (and emit no > > constructors) for abstract > > classes. > > > > Is this the correct behaviour for an abstract > class? > > eg. > > class_< Foo, boost::noncopyable>("Foo", no_init) > > > > This from the FAQ states this quite clearly: > > > http://www.python.org/cgi-bin/moinmoin/boost_2epython_2fFAQ > > > * no_init means "do not try to create an > instance of > > that Python object, create __init__ function that > throws an exception" > > > * noncopyable means "do not try to register > a converter > > which can convert C++ return values of that class > to Python". > > > > > > When wrapping an abstract class, it's necessary > to specify both. > > > > However, what's confusing me is that I thought > specifying > > no_init would make > > the following incorrect: > > > > class Bar(CppModule.Foo): > > def __init__(self): > > CppModule.Foo.__init__(self) > > > > Is that correct? > > I think this is correct. Abstract class has > constructors. > > Roman I think CppModule.Foo.__init__(self) simply throws an exception (because of no_init). Thus Bar cannot be instantiated. For now, __init__ must be called to initialize Python instance correctly, no matter whether the exposed class is abstract or not: http://mail.python.org/pipermail/c++-sig/2004-June/007522.html shin __________________________________________________ Do You Yahoo!? http://bb.yahoo.co.jp/ From dave at boost-consulting.com Wed Jun 30 18:30:33 2004 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 30 Jun 2004 12:30:33 -0400 Subject: [C++-sig] Re: Calling a python function from C++ (from Jeff Holle) References: <40E142ED.2030603@verizon.net> Message-ID: Jeff Holle writes: >> >> >>> An underlining concern I have is error handling. When >>> PyImport_ImportModule fails, a NULL pointer is returned. >>> Seems like the underlining machinery in "handle<>" is intolerant of >>> this. >> >> >> >>What makes you say that? >> > You are correct about the success in compiling your much cleaner > example, and it works :-) , but has a flaw. > > When I hide the needed python script, the call to > PyImport_ImportModule returns NULL. > When this occurres, both your example and what I had created, but > commented out throws something because I can catch it with > "catch(...)". I don't however know how to be more specific. Any > hints? Whatever it is, it doesn't inherit from "exception". It's "boost::python::error_already_set". It means that Python knows what the error is already. If you're in an extension module, it's handled automatically. Otherwise, you can look at www.boost.org/libs/python/test/embedding.cpp for examples of how to get at this exception. This is all in the documentation, BTW: http://www.boost.org/libs/python/doc/v2/object.html#object-spec-ctors http://www.boost.org/libs/python/doc/v2/errors.html > If I was operating on windows, I would anticipate it was a "structured > exception", or whatever Microsoft calls their propritary stuff. Never! > Don't know of the equivalent on linux though. Without the "catch > (...)", the command line program exits with "Aborted". 'course it does. That's C++. ;-) -- Dave Abrahams Boost Consulting http://www.boost-consulting.com From jeff.holle at verizon.net Wed Jun 30 04:30:46 2004 From: jeff.holle at verizon.net (Jeffrey Holle) Date: Tue, 29 Jun 2004 22:30:46 -0400 Subject: [C++-sig] Re: Calling a python function from C++ (from Jeff Holle) In-Reply-To: <40E142ED.2030603@verizon.net> References: <40E142ED.2030603@verizon.net> Message-ID: I've explored whats actually going on some with my debugger and now see what is being thrown. It is "error_already_set". This is a trivial object (it has no attributes at all), and isn't much better than "catch (...)". However, its name implies something. Is there a meaningful error message set somewhere else that can be accessed within the catch clause of "error_already_set"? Jeff Holle wrote: >> >> >>> An underlining concern I have is error handling. When >>> PyImport_ImportModule fails, a NULL pointer is returned. >>> Seems like the underlining machinery in "handle<>" is intolerant of >>> this. >> >> >> >> >> What makes you say that? >> > You are correct about the success in compiling your much cleaner > example, and it works :-) , but has a flaw. > > When I hide the needed python script, the call to PyImport_ImportModule > returns NULL. > When this occurres, both your example and what I had created, but > commented out throws something because I can catch it with > "catch(...)". I don't however know how to be more specific. Any > hints? Whatever it is, it doesn't inherit from "exception". > > If I was operating on windows, I would anticipate it was a "structured > exception", or whatever Microsoft calls their propritary stuff. Don't > know of the equivalent on linux though. Without the "catch (...)", the > command line program exits with "Aborted". From jeff.holle at verizon.net Wed Jun 30 08:39:46 2004 From: jeff.holle at verizon.net (Jeffrey Holle) Date: Wed, 30 Jun 2004 02:39:46 -0400 Subject: [C++-sig] Re: Calling a python function from C++ (from Jeff Holle) In-Reply-To: References: <40E142ED.2030603@verizon.net> Message-ID: Given what the name of this exception, I assume there is a source of information to obtain useful information about it. To this end, I've dug a bit into the Python C API and found the added the following to my code example: catch (error_already_set& x) { PyObject *err_type,*err_value,*err_traceback; PyErr_Fetch(&err_type,&err_value,&err_traceback); cout << "something bad happened" << endl; } While I see that err_type and error_value are not null pointers after the call to PyErr_Fetch, I don't know what to do with either to get at a useful message. Can anybody provide any hints? Jeffrey Holle wrote: > I've explored whats actually going on some with my debugger and now see > what is being thrown. > It is "error_already_set". This is a trivial object (it has no > attributes at all), and isn't much better than "catch (...)". > However, its name implies something. Is there a meaningful error > message set somewhere else that can be accessed within the catch clause > of "error_already_set"? > > Jeff Holle wrote: > >>> >>> >>>> An underlining concern I have is error handling. When >>>> PyImport_ImportModule fails, a NULL pointer is returned. >>>> Seems like the underlining machinery in "handle<>" is intolerant of >>>> this. >>> >>> >>> >>> >>> >>> What makes you say that? >>> >> You are correct about the success in compiling your much cleaner >> example, and it works :-) , but has a flaw. >> >> When I hide the needed python script, the call to >> PyImport_ImportModule returns NULL. >> When this occurres, both your example and what I had created, but >> commented out throws something because I can catch it with >> "catch(...)". I don't however know how to be more specific. Any >> hints? Whatever it is, it doesn't inherit from "exception". >> >> If I was operating on windows, I would anticipate it was a "structured >> exception", or whatever Microsoft calls their propritary stuff. Don't >> know of the equivalent on linux though. Without the "catch (...)", >> the command line program exits with "Aborted". From jeff.holle at verizon.net Wed Jun 30 09:29:59 2004 From: jeff.holle at verizon.net (Jeffrey Holle) Date: Wed, 30 Jun 2004 03:29:59 -0400 Subject: [C++-sig] Re: Accessing C++ values from within Python In-Reply-To: References: Message-ID: <40E26BF7.6070809@verizon.net> I'm sending the source of a simple project that does what I believe you are trying to do. In Main.cpp, note the use of call, and the use of ref within it. The former does all the "magic" of converting C++ objects to/from python. The later causes the C++ object to be passed by reference, allowing the python script to alter C++ object attributes. xin wrote: > Hi. > I have a setup such as the following: > > class object { > public: > void doSomthingElse(); > float x; > float *y; > Somthing SomePyScript; > }; > > int main() > { > object *array = new object[10]; // size of array is only an example > for (int i = 0; i < 10; i++) > { > array[i].y = new float[array[i]] > RunPythonScript(array[i]); > } > return 1; > } > > Where: > - " Somting SomePyScript; " Is some reference to a python script that > is affiliated with this instance of the class (varies from instance to > instance) > - " RunPythonScript(array[i]); " Is some method of running the python > script that is affiliated with the instance array[i]. > > My intention is that the python scripts change values within the class > 'object' > e.g. The python code sets 'x' to equal 0.9. And then sets each value of > y to equal a muliple of 9. (y[0] = 0, y[1] = 9, y[2] = 18, ... ,y[100] = > 900 etc...) > > Is this at all possible? Is it possible without moving all the memory > from one place, to another area accessable by both python and then back > again? If so how would I go about doing it? > > I've tried all sorts of methods of attempting this, but have had no > luck. Any help would be appreciated. > > Thanks. -------------- next part -------------- A non-text attachment was scrubbed... Name: extended_embeddedGreeter.tar Type: application/x-tar Size: 20480 bytes Desc: not available URL: