You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(3) |
Aug
(7) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(12) |
2009 |
Jan
(2) |
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(2) |
Apr
(16) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(5) |
Oct
(5) |
Nov
(1) |
Dec
(2) |
2011 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
(5) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(2) |
Dec
|
2015 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(3) |
Oct
|
Nov
(4) |
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(2) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(11) |
From: Barry S. <ba...@ba...> - 2008-12-30 20:18:38
|
On 30 Dec 2008, at 16:28, William Newbery wrote: > > You can start with the python object and then get the C++ object > that implements it: > > > ExtensionObject<MyClass> obj( args[0] ); // exception thrown > > if wrong type > > MyClass *p = obj.extensionObject(); // get C++ pointer > > Ok, so basicly I just pass the ExtensionObject<T> around, and can > use th extensionObject() method to get a pointer to the c++ object. > > One thing I cant work out though, what do I construct the > ExtensionObject class with if I have not yet created an object to > store in it? > I need to have the Py::ExtensionObject<Input> input in the D3D > classes deffinition, but I cant actauly create an Input instance > untill later in the constructor > > class D3d : public Py::PythonExtension<D3d> > { > ... > Py::ExtensionObject<Input> input; > ... > } > > D3d::D3d(...) > {//error C2512: 'Py::ExtensionObject<T>' : no appropriate default > constructor available > ...create window and dx stuff > input = new Input(this, hwnd);//cant create the Input instance > untill after some other stuff is created > } In cases like this I use a pointer: Py::ExtensionObject<Input> *input_ptr; and new a Py::ExtensionObject<Input>( input ) when I have it available. You need to create the the Py::Object to pass it back to python like this: Py::ExtensionObject<Input> an_input_object( Py::asObject( new Input(this, hwnd) ) ) ); I've been looking at allowing Py::Object to hold NULL for V6.0.0 - but that targeted at Python 3.0. Barry Barry |
From: William N. <fir...@ho...> - 2008-12-30 16:28:04
|
> You can start with the python object and then get the C++ object that implements it: > ExtensionObject<MyClass> obj( args[0] ); // exception thrown > if wrong type > MyClass *p = obj.extensionObject(); // get C++ pointer Ok, so basicly I just pass the ExtensionObject<T> around, and can use th extensionObject() method to get a pointer to the c++ object. One thing I cant work out though, what do I construct the ExtensionObject class with if I have not yet created an object to store in it? I need to have the Py::ExtensionObject<Input> input in the D3D classes deffinition, but I cant actauly create an Input instance untill later in the constructor class D3d : public Py::PythonExtension<D3d> { ... Py::ExtensionObject<Input> input; ... } D3d::D3d(...) {//error C2512: 'Py::ExtensionObject<T>' : no appropriate default constructor available ...create window and dx stuff input = new Input(this, hwnd);//cant create the Input instance untill after some other stuff is created } _________________________________________________________________ Get a bird’s eye view of the world with Multimap http://clk.atdmt.com/GBL/go/115454059/direct/01/ |
From: Barry S. <ba...@ba...> - 2008-12-30 11:12:47
|
> It seems that your questions are not about python C++ but about how to control object life time. PyCXX is not going to solve your C++ object life time issues. What I think you are saying is that when the python object is deleted the C++ objects it uses may need to live longer. You need to find a solution to your object life time problems. There are smart pointer classes that will help with your object life time issues. But its not PyCXX goal to solve that problem, only the Python interface problem. > Ok but how exactly do I do that since the class has both c++ and > python stuff? > If I pass a pointer around to the object in the c++ code then either > the object will get deleted before I want (ie when theres no python > stuff refrencing it anymore), or it never gets deleted it seems, and > if I use the extesion object template class to hold the pointer then > I cant access the c++ stuff. You can start with the python object and then get the C++ object that implements it: ExtensionObject<MyClass> obj( args[0] ); // exception thrown if wrong type MyClass *p = obj.extensionObject(); // get C++ pointer > > > Is there some other class that just acts as a smart pointer, allows > me to access my c++ class directly with -> but also handles the > stuff python needs like refrence counting. Barry |
From: William N. <fir...@ho...> - 2008-12-30 10:30:40
|
> From: cxx...@li... > Subject: CXX-Users Digest, Vol 10, Issue 5 > To: cxx...@li... > Date: Sun, 28 Dec 2008 12:09:36 +0000 > > Send CXX-Users mailing list submissions to > cxx...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/cxx-users > or, via email, send a message with subject or body 'help' to > cxx...@li... > > You can reach the person managing the list at > cxx...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of CXX-Users digest..." > > > Today's Topics: > > 1. Re:Python objects not deleted (Barry Scott) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 28 Dec 2008 11:00:48 +0000 > From: Barry Scott <ba...@ba...> > Subject: Re: Python objects not deleted > To: Discuss PyCXX use and improvement > <cxx...@li...> > Message-ID: <451...@ba...> > Content-Type: text/plain; charset="us-ascii" > > > On 24 Dec 2008, at 00:15, William Newbery wrote: > > > > Cannot be done. Python can only call C code that meets its API > > > specification. C++ loses on two counts its not C and its not > > python API. > > > > I think you missed what I meant. I dont want python to touch that > > stuff, I want it only for other c++ objects in the same project ie: > > > > class Direct3D : public Py::ExtensionObject<Direct3D> > > { > > ... > > Py::Object Render(const Py::Tuple &args);//--- method for use by > > python > > ... > > IDirect3DDevice9* GetDevice();//--- ONLY used by other c++ > > objects in this project, like say the sprite class that needs to do: > > "d3d->GetDevice()->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2)" etc > > }; > > > > So basicly what I'm saying is that within the c++ code can I use the > > Direct3D* object directly, and ignore the python stuff all together > > except for maintaining the refrence count so it cant get deleted > > while its still used by c++ objects. I dont want python to even know > > about the GetDevice method and IDirect3DDevice9 interface, thats > > soley for internal use by my c++ project. > > The error you made was not letting Python handle the ref counting. Fix > that as I suggested and you will be good. > > If you have private objects that Python does not need to see manage > them in C++ way. > > Barry > > > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > ------------------------------------------------------------------------------ > > > ------------------------------ > > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users > > > End of CXX-Users Digest, Vol 10, Issue 5 > **************************************** Ok but how exactly do I do that since the class has both c++ and python stuff? If I pass a pointer around to the object in the c++ code then either the object will get deleted before I want (ie when theres no python stuff refrencing it anymore), or it never gets deleted it seems, and if I use the extesion object template class to hold the pointer then I cant access the c++ stuff. Is there some other class that just acts as a smart pointer, allows me to access my c++ class directly with -> but also handles the stuff python needs like refrence counting. _________________________________________________________________ Imagine a life without walls. See the possibilities. http://clk.atdmt.com/UKM/go/122465943/direct/01/ |
From: Barry S. <ba...@ba...> - 2008-12-28 11:01:08
|
On 24 Dec 2008, at 00:15, William Newbery wrote: > > Cannot be done. Python can only call C code that meets its API > > specification. C++ loses on two counts its not C and its not > python API. > > I think you missed what I meant. I dont want python to touch that > stuff, I want it only for other c++ objects in the same project ie: > > class Direct3D : public Py::ExtensionObject<Direct3D> > { > ... > Py::Object Render(const Py::Tuple &args);//--- method for use by > python > ... > IDirect3DDevice9* GetDevice();//--- ONLY used by other c++ > objects in this project, like say the sprite class that needs to do: > "d3d->GetDevice()->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2)" etc > }; > > So basicly what I'm saying is that within the c++ code can I use the > Direct3D* object directly, and ignore the python stuff all together > except for maintaining the refrence count so it cant get deleted > while its still used by c++ objects. I dont want python to even know > about the GetDevice method and IDirect3DDevice9 interface, thats > soley for internal use by my c++ project. The error you made was not letting Python handle the ref counting. Fix that as I suggested and you will be good. If you have private objects that Python does not need to see manage them in C++ way. Barry |
From: William N. <fir...@ho...> - 2008-12-24 00:17:04
|
> Cannot be done. Python can only call C code that meets its API > specification. C++ loses on two counts its not C and its not python API. I think you missed what I meant. I dont want python to touch that stuff, I want it only for other c++ objects in the same project ie: class Direct3D : public Py::ExtensionObject<Direct3D> { ... Py::Object Render(const Py::Tuple &args);//--- method for use by python ... IDirect3DDevice9* GetDevice();//--- ONLY used by other c++ objects in this project, like say the sprite class that needs to do: "d3d->GetDevice()->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2)" etc }; So basicly what I'm saying is that within the c++ code can I use the Direct3D* object directly, and ignore the python stuff all together except for maintaining the refrence count so it cant get deleted while its still used by c++ objects. I dont want python to even know about the GetDevice method and IDirect3DDevice9 interface, thats soley for internal use by my c++ project. _________________________________________________________________ Get Windows Live Messenger on your Mobile http://clk.atdmt.com/UKM/go/msnnkmgl0010000001ukm/direct/01/ |
From: Barry S. <ba...@ba...> - 2008-12-23 21:15:47
|
On 23 Dec 2008, at 11:28, William Newbery wrote: > How is that going to work with stuff Ive not got python versions > for, like tons of com objects (ie the D3d classes GetDevice() method > that returns IDirect3DDevice9*). To do what your sugessting ive > either got to cast that to a Py::Int for the GetDevice method which > is both messy and looses all type safty, or I spend ages writiing > python wrappers for every single Direct3D object... > > Is there no way to use a c++ class directly at all? I'm not massivly > fussed about having refrence counting done for me on the c++ side > providing it is cleared up if I change the count to zero. Cannot be done. Python can only call C code that meets its API specification. C++ loses on two counts its not C and its not python API. So yes you have to wrap ever object that you expose. That is exactly what I did to implement pysvn that uses PyCXX. > > > What about something like what ive got but useing: the onyl objects > I'll be doing this with are ones I allocated with new anyway so the > matching new/delete rule is still followed. > > if(!--obj->ob_refcnt)delete obj; Python would have no idea what to do with the returned object. For example how would python know what methods are supported? For COM have you looked at using WIN32COM of pywin32 provides? See http://sourceforge.net/projects/pywin32/ I have used pywin32 to access COM objects. Also you be able to use swig to automate generating wrappers. Barry |
From: William N. <fir...@ho...> - 2008-12-23 11:29:02
|
How is that going to work with stuff Ive not got python versions for, like tons of com objects (ie the D3d classes GetDevice() method that returns IDirect3DDevice9*). To do what your sugessting ive either got to cast that to a Py::Int for the GetDevice method which is both messy and looses all type safty, or I spend ages writiing python wrappers for every single Direct3D object... Is there no way to use a c++ class directly at all? I'm not massivly fussed about having refrence counting done for me on the c++ side providing it is cleared up if I change the count to zero. What about something like what ive got but useing: the onyl objects I'll be doing this with are ones I allocated with new anyway so the matching new/delete rule is still followed. if(!--obj->ob_refcnt)delete obj; _________________________________________________________________ Live Search presents Big Snap II - win John Lewis vouchers http://clk.atdmt.com/UKM/go/117442309/direct/01/ |
From: Barry S. <ba...@ba...> - 2008-12-22 22:43:17
|
On 19 Dec 2008, at 08:09, William Newbery wrote: > I looked at the sample and played around with Py::ExtensionObject > but in nethier case can I see anyway to use the object it contains... > > The only methods avaible on it are the standrd ones like isTuple, > as_string, etc. > How do I gain access to the classes own methods and data (including > those not visible to python, like Sound's the internal SoundData* > data object which contains data required internally by the sound > system (eg the PCM wav data), and is also not a python object. Implement getattr and return an appropriate object for each name. Barry |
From: William N. <fir...@ho...> - 2008-12-19 08:09:32
|
I looked at the sample and played around with Py::ExtensionObject but in nethier case can I see anyway to use the object it contains... The only methods avaible on it are the standrd ones like isTuple, as_string, etc. How do I gain access to the classes own methods and data (including those not visible to python, like Sound's the internal SoundData* data object which contains data required internally by the sound system (eg the PCM wav data), and is also not a python object. _________________________________________________________________ Live Search presents Big Snap II - win John Lewis vouchers http://clk.atdmt.com/UKM/go/117442309/direct/01/ |
From: Barry S. <ba...@ba...> - 2008-12-18 19:47:00
|
On 15 Dec 2008, at 20:58, William Newbery wrote: > For some reason the python extension object is not deleted when > finished with. It is python that causes the delete when the ref count hits zero. You are bypassing python when you modify ob_refcnt. For the automatic ref count handling you have to put your C++ objects into a Py::Object. Look at Demo/rangetest.cpp for examples of using Py::ExtensionObject. > > > //clear up finished sounds > for(std::vector<SourceVoice*>::iterator it=finished.begin();it! > =finished.end();++it) > { > playing.erase(*it); > (*it)->ob_refcnt--;//remove the refrence we added when we > got the voice Must not touch the ref cnt it is only to be done by python code via its API or via PyCXX that uses the python API. > > std::cout << "finished voice refrence: " << (*it)->ob_refcnt > << std::endl; //prints 0 > } > > class SourceVoice : public Py::PythonExtension<SourceVoice> > { > IXAudio2SourceVoice *voice; > Sound *sound; Use: Py::ExtensionObject<Sound> sound; > public: > static void init_type(); > SourceVoice(IXAudio2SourceVoice *voice, Sound *sound); > virtual ~SourceVoice(); > > IXAudio2SourceVoice *GetVoice(){return voice;} > private: > Py::Object GetVolume(const Py::Tuple &args); > Py::Object SetVolume(const Py::Tuple &args); > Py::Object Stop (const Py::Tuple &args); > Py::Object ExitLoop (const Py::Tuple &args); > }; > > SourceVoice::SourceVoice(IXAudio2SourceVoice *_voice, Sound *_sound) > :voice(_voice), sound(_sound) > { > sound->ob_refcnt++; Need to pass in a Py::Object for _sound. > } > SourceVoice::~SourceVoice()//not called > { > std::cout << "voice destroyed" << std::endl; > sound->ob_refcnt--; when Py::ExtensionObject d'tor is called it will drop the ref cnt for you. > > voice->DestroyVoice(); > } > > Is there some reason why an object is not deleted even when the > refcnt hits zero, in fact the objects are not even getting deleted > when the python program ends, leaving windows to clear up 100's of > MB's of sound data... Barry |
From: William N. <fir...@ho...> - 2008-12-15 20:59:04
|
For some reason the python extension object is not deleted when finished with. //clear up finished sounds for(std::vector<SourceVoice*>::iterator it=finished.begin();it!=finished.end();++it) { playing.erase(*it); (*it)->ob_refcnt--;//remove the refrence we added when we got the voice std::cout << "finished voice refrence: " << (*it)->ob_refcnt << std::endl; //prints 0 } class SourceVoice : public Py::PythonExtension<SourceVoice> { IXAudio2SourceVoice *voice; Sound *sound; public: static void init_type(); SourceVoice(IXAudio2SourceVoice *voice, Sound *sound); virtual ~SourceVoice(); IXAudio2SourceVoice *GetVoice(){return voice;} private: Py::Object GetVolume(const Py::Tuple &args); Py::Object SetVolume(const Py::Tuple &args); Py::Object Stop (const Py::Tuple &args); Py::Object ExitLoop (const Py::Tuple &args); }; SourceVoice::SourceVoice(IXAudio2SourceVoice *_voice, Sound *_sound) :voice(_voice), sound(_sound) { sound->ob_refcnt++; } SourceVoice::~SourceVoice()//not called { std::cout << "voice destroyed" << std::endl; sound->ob_refcnt--; voice->DestroyVoice(); } Is there some reason why an object is not deleted even when the refcnt hits zero, in fact the objects are not even getting deleted when the python program ends, leaving windows to clear up 100's of MB's of sound data... _________________________________________________________________ Get a bird’s eye view of the world with Multimap http://clk.atdmt.com/GBL/go/115454059/direct/01/ |
From: Barry S. <ba...@ba...> - 2008-11-27 15:58:59
|
On 21 Nov 2008, at 21:53, William Newbery wrote: > I want add attributes to my c++ classes that can be used from > python. I know ive got to use the getattr method, however my > implementation crashes on the second access with an error about a > negative reference count. virtual Py::Object getattr(const char *name) { if(std::string("cls2")==name)return Py::asObject(cls2); else return getattr_methods(name); } asObject takes ownership of cls2. And when the ref count drops to 0 cls2 is deleted. You then pass a pointer to a deleted object ot asObject as get a crash. I suggest that you keep cls2 is a Py::Object so that you keep a ref count of 1 so long as Cls() exists. I added std::cout to the c'tor and d'tor of your objects to prove this was the case. Barry |
From: Barry S. <ba...@ba...> - 2008-11-21 19:36:17
|
On 18 Nov 2008, at 23:10, William Newbery wrote: > I couldnt see any area on the sourcefordge stie for posting support > requests, since the new group seems to be read only... Join the PyCXX user list. What is the "new group" you refer to? > > > Anyway the basic question is how do I create member varibles for > classes that can be accessed from python. The basic answer is you implement getattr and setattr. > > > eg I have a Window class, that on creation creates a Input class: > class Window... > { > Input *input; > ... > }; > > I want the user to be able to access this as a varible to the window > instance, ie "mywindow.input.GetMousePos()". > > On the module class you provided a moduleDictionary() to retur a > dict, that i can assign varibles to, however classes dont seem to > have this, I tried implementing it through the getattr method, but > this seems to not work. Try building the examples from the Demo folder. range.cxx implements getattr and works. If you want to look at a substantial example look at the source of http://pysvn.tigris.org that uses lots of PyCXX features. > > > Theres nothing in the docs I can see for doing this, is it something > yet to be implemented or am i going about it the wrong way? You picked the right method getattr. We just need to help you get it working. Barry |
From: Barry S. <ba...@ba...> - 2008-10-11 20:53:43
|
Version 5.4.2 (11-Oct-2008) Add support for rich compare. Add the simplest code for a module with a single function and a single class (Demo/simple.cxx) Fix long standing bugs with Dict::iterator Barry |
From: Barry S. <ba...@ba...> - 2008-10-05 18:48:18
|
Just updating with current status Python 2.6 does not need a new PyCXX release. I have added a new example called simple that shows the minimum code needed to write an extension. Simple is in svn on trunk and the V5 maint branch. PyCXX trunk is now building and passing its tests against Python 3.0 rc1. The tests run by example.test() have been substantially updated and improved. They are now unit tests of the PyCXX API. I have also started writting docs to porting to python 3.0 in the Docs folder on trunk. My testing of pysvn using PyCXX trunk is showing problems that I'm working on at the moment. Barry |
From: Barry S. <ba...@ba...> - 2008-08-06 22:18:32
|
On Aug 3, 2008, at 17:59, <hap...@ho...> <hap...@ho...> wrote: > I am using Python 2.5 and VC++ 9.0. What the product called? VC++ 9.0 isn't Microsoft name is it? > > It works for the release version. Sounds like the options for Debug are missing something important that is in Release options. > > I improved what I was doing and attempted with the debug version, > but I get "ImportError: No module named example_d". My > improvements are that I compiled Python 2.5 using VC++ 9.0 and ran > the debug version of Python interpreter, then I tried "import > example_d". > Python adds _d to the name of file to load is you compile python with Py_DEBUG defined. You also have to compile your extension with Py_DEBUG defined. This is because the C API changes when Py_DEBUG is defined. Personally I compile python Debug but not with Py_DEBUG defined. If you do want to run with Py_DEBUG defined then your extension must define initexample_d in a file called example_d.pyd. Use python -v to see teh details of the files attempted to be loaded when you say import. Barry > > From: ba...@ba... > Subject: Re: Unable to init function during import of debug version > of extension > Date: Sun, 3 Aug 2008 13:59:40 +0100 > To: cxx...@li... > > > On Aug 2, 2008, at 22:17, <hap...@ho...> wrote: > > Yes, even though you have "/export:initexample" in the vcproj file > for the provided example, the problem is still there when importing > the compiled DEBUG version of module in the python interpreter. > I'll state again what that problem is: > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: dynamic module does not define init function > (initexample) > > Which version of python are you using? > Which compiler are you using to build the example? > > Does it work for Release version? > > When Python is compiled for debug it changes the name of the entry > point to initexample_d. Since > that is not being asked for I guess you have a Release build of > python. > > try python -vv to see the path used to find the example.pyd file. > Make sure that it is importing > the one you are building. > > Barry > > > > > > > > From: ba...@ba... > Subject: Re: Unable to init function during import of debug version > of extension > Date: Sat, 2 Aug 2008 13:59:41 +0100 > To: cxx...@li... > > In the vcproj file for example I have the following: > > <Tool > Name="VCLinkerTool" > AdditionalOptions="/export:initexample" > > Make sure you are also have this /export:initcinterpreter in your > vcproj file. > > Barry > > > > > On Aug 1, 2008, at 08:13, <hap...@ho...> > <hap...@ho...> wrote: > > An update: > The same import error also happens with the debug versions of the > example module in the Demo. So I added > extern "C" void initexample_d(); > to python.cxx. This built, but when import example_d with python, > same problem. > So then I added initexample_d to the EXPORTS in the export > definition file, which built fine, but same problem. > This is on Vista, with Visual C++. > > > > > From: hap...@ho... > To: cxx...@li... > Subject: > Date: Thu, 31 Jul 2008 17:04:17 -0700 > > Below is a very simple extension, mostly cut from the provided > example. It compiles and builds the cinterpreter.pyd without > error, but when I do the following in python: > import cinterpreter > > I get this result: > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: dynamic module does not define init function > (initcinterpreter) > > I looked over the example again and again, and I simply cannot see > what the problem is. What is wrong? > > *********************************************************** > > #ifdef _MSC_VER > // disable warning C4786: symbol greater than 255 character, > // nessesary to ignore as <map> causes lots of warning > #pragma warning(disable: 4786) > #endif > > > #include "CXX/Objects.hxx" > #include "CXX/Extensions.hxx" > > > > #include <assert.h> > > > #include <algorithm> > #include <iostream> > > > class cinterpreter_module : public > Py::ExtensionModule<cinterpreter_module> > { > public: > cinterpreter_module() > : Py::ExtensionModule<cinterpreter_module>( "cinterpreter" ) > { > add_varargs_method("test", &cinterpreter_module::c_test, > "test() is just a test."); > > initialize( "cinterpreter module initialize." ); > > Py::Dict d( moduleDictionary() ); > } > > virtual ~cinterpreter_module() {} > > private: > > Py::Object c_test(const Py::Tuple &args) { > std::cout << "c_test() called." << std::endl; > return Py::None(); > } > }; > > extern "C" void initcinterpreter() > { > #if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL) > Py::InitialisePythonIndirectPy::Interface(); > #endif > > static cinterpreter_module* cinterpreter = new > cinterpreter_module; > } > > // symbol required for the debug version > extern "C" void initcinterpreter_d() > { initcinterpreter(); } > > > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users |
From: <hap...@ho...> - 2008-08-03 16:59:42
|
I am using Python 2.5 and VC++ 9.0. It works for the release version. I improved what I was doing and attempted with the debug version, but I get "ImportError: No module named example_d". My improvements are that I compiled Python 2.5 using VC++ 9.0 and ran the debug version of Python interpreter, then I tried "import example_d". From: ba...@ba... Subject: Re: Unable to init function during import of debug version of extension Date: Sun, 3 Aug 2008 13:59:40 +0100 To: cxx...@li... On Aug 2, 2008, at 22:17, <hap...@ho...> wrote: Yes, even though you have "/export:initexample" in the vcproj file for the provided example, the problem is still there when importing the compiled DEBUG version of module in the python interpreter. I'll state again what that problem is: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (initexample) Which version of python are you using?Which compiler are you using to build the example? Does it work for Release version? When Python is compiled for debug it changes the name of the entry point to initexample_d. Sincethat is not being asked for I guess you have a Release build of python. try python -vv to see the path used to find the example.pyd file. Make sure that it is importingthe one you are building. Barry From: ba...@ba... Subject: Re: Unable to init function during import of debug version of extension Date: Sat, 2 Aug 2008 13:59:41 +0100 To: cxx...@li... In the vcproj file for example I have the following: <Tool Name="VCLinkerTool" AdditionalOptions="/export:initexample" Make sure you are also have this /export:initcinterpreter in your vcproj file. Barry On Aug 1, 2008, at 08:13, <hap...@ho...> <hap...@ho...> wrote: An update: The same import error also happens with the debug versions of the example module in the Demo. So I added extern "C" void initexample_d(); to python.cxx. This built, but when import example_d with python, same problem. So then I added initexample_d to the EXPORTS in the export definition file, which built fine, but same problem. This is on Vista, with Visual C++. From: hap...@ho... To: cxx...@li... Subject: Date: Thu, 31 Jul 2008 17:04:17 -0700 Below is a very simple extension, mostly cut from the provided example. It compiles and builds the cinterpreter.pyd without error, but when I do the following in python: import cinterpreter I get this result: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (initcinterpreter) I looked over the example again and again, and I simply cannot see what the problem is. What is wrong? *********************************************************** #ifdef _MSC_VER // disable warning C4786: symbol greater than 255 character, // nessesary to ignore as <map> causes lots of warning #pragma warning(disable: 4786) #endif #include "CXX/Objects.hxx" #include "CXX/Extensions.hxx" #include <assert.h> #include <algorithm> #include <iostream> class cinterpreter_module : public Py::ExtensionModule<cinterpreter_module> { public: cinterpreter_module() : Py::ExtensionModule<cinterpreter_module>( "cinterpreter" ) { add_varargs_method("test", &cinterpreter_module::c_test, "test() is just a test."); initialize( "cinterpreter module initialize." ); Py::Dict d( moduleDictionary() ); } virtual ~cinterpreter_module() {} private: Py::Object c_test(const Py::Tuple &args) { std::cout << "c_test() called." << std::endl; return Py::None(); } }; extern "C" void initcinterpreter() { #if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL) Py::InitialisePythonIndirectPy::Interface(); #endif static cinterpreter_module* cinterpreter = new cinterpreter_module; } // symbol required for the debug version extern "C" void initcinterpreter_d() { initcinterpreter(); } -------------------------------------------------------------------------This SF.Net email is sponsored by the Moblin Your Move Developer's challengeBuild the coolest Linux based applications with Moblin SDK & win great prizesGrand prize is a trip for two to an Open Source event anywhere in the worldhttp://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________CXX-Users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/cxx-users -------------------------------------------------------------------------This SF.Net email is sponsored by the Moblin Your Move Developer's challengeBuild the coolest Linux based applications with Moblin SDK & win great prizesGrand prize is a trip for two to an Open Source event anywhere in the worldhttp://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________CXX-Users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/cxx-users _________________________________________________________________ If you like crossword puzzles, then you'll love Flexicon, a game which combines four overlapping crossword puzzles into one! http://g.msn.ca/ca55/208 |
From: Barry S. <ba...@ba...> - 2008-08-03 13:00:31
|
On Aug 2, 2008, at 22:17, <hap...@ho...> wrote: > Yes, even though you have "/export:initexample" in the vcproj file > for the provided example, the problem is still there when importing > the compiled DEBUG version of module in the python interpreter. > I'll state again what that problem is: > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: dynamic module does not define init function > (initexample) Which version of python are you using? Which compiler are you using to build the example? Does it work for Release version? When Python is compiled for debug it changes the name of the entry point to initexample_d. Since that is not being asked for I guess you have a Release build of python. try python -vv to see the path used to find the example.pyd file. Make sure that it is importing the one you are building. Barry > > > > > From: ba...@ba... > Subject: Re: Unable to init function during import of debug version > of extension > Date: Sat, 2 Aug 2008 13:59:41 +0100 > To: cxx...@li... > > In the vcproj file for example I have the following: > > <Tool > Name="VCLinkerTool" > AdditionalOptions="/export:initexample" > > Make sure you are also have this /export:initcinterpreter in your > vcproj file. > > Barry > > > > > On Aug 1, 2008, at 08:13, <hap...@ho...> > <hap...@ho...> wrote: > > An update: > The same import error also happens with the debug versions of the > example module in the Demo. So I added > extern "C" void initexample_d(); > to python.cxx. This built, but when import example_d with python, > same problem. > So then I added initexample_d to the EXPORTS in the export > definition file, which built fine, but same problem. > This is on Vista, with Visual C++. > > > > > From: hap...@ho... > To: cxx...@li... > Subject: > Date: Thu, 31 Jul 2008 17:04:17 -0700 > > Below is a very simple extension, mostly cut from the provided > example. It compiles and builds the cinterpreter.pyd without > error, but when I do the following in python: > import cinterpreter > > I get this result: > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: dynamic module does not define init function > (initcinterpreter) > > I looked over the example again and again, and I simply cannot see > what the problem is. What is wrong? > > *********************************************************** > > #ifdef _MSC_VER > // disable warning C4786: symbol greater than 255 character, > // nessesary to ignore as <map> causes lots of warning > #pragma warning(disable: 4786) > #endif > > > #include "CXX/Objects.hxx" > #include "CXX/Extensions.hxx" > > > > #include <assert.h> > > > #include <algorithm> > #include <iostream> > > > class cinterpreter_module : public > Py::ExtensionModule<cinterpreter_module> > { > public: > cinterpreter_module() > : Py::ExtensionModule<cinterpreter_module>( "cinterpreter" ) > { > add_varargs_method("test", &cinterpreter_module::c_test, > "test() is just a test."); > > initialize( "cinterpreter module initialize." ); > > Py::Dict d( moduleDictionary() ); > } > > virtual ~cinterpreter_module() {} > > private: > > Py::Object c_test(const Py::Tuple &args) { > std::cout << "c_test() called." << std::endl; > return Py::None(); > } > }; > > extern "C" void initcinterpreter() > { > #if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL) > Py::InitialisePythonIndirectPy::Interface(); > #endif > > static cinterpreter_module* cinterpreter = new > cinterpreter_module; > } > > // symbol required for the debug version > extern "C" void initcinterpreter_d() > { initcinterpreter(); } > > > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users |
From: <hap...@ho...> - 2008-08-02 21:17:12
|
Yes, even though you have "/export:initexample" in the vcproj file for the provided example, the problem is still there when importing the compiled DEBUG version of module in the python interpreter. I'll state again what that problem is: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (initexample) From: ba...@ba... Subject: Re: Unable to init function during import of debug version of extension Date: Sat, 2 Aug 2008 13:59:41 +0100 To: cxx...@li... In the vcproj file for example I have the following: <Tool Name="VCLinkerTool" AdditionalOptions="/export:initexample" Make sure you are also have this /export:initcinterpreter in your vcproj file. Barry On Aug 1, 2008, at 08:13, <hap...@ho...> <hap...@ho...> wrote: An update: The same import error also happens with the debug versions of the example module in the Demo. So I added extern "C" void initexample_d(); to python.cxx. This built, but when import example_d with python, same problem. So then I added initexample_d to the EXPORTS in the export definition file, which built fine, but same problem. This is on Vista, with Visual C++. From: hap...@ho... To: cxx...@li... Subject: Date: Thu, 31 Jul 2008 17:04:17 -0700 Below is a very simple extension, mostly cut from the provided example. It compiles and builds the cinterpreter.pyd without error, but when I do the following in python: import cinterpreter I get this result: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (initcinterpreter) I looked over the example again and again, and I simply cannot see what the problem is. What is wrong? *********************************************************** #ifdef _MSC_VER // disable warning C4786: symbol greater than 255 character, // nessesary to ignore as <map> causes lots of warning #pragma warning(disable: 4786) #endif #include "CXX/Objects.hxx" #include "CXX/Extensions.hxx" #include <assert.h> #include <algorithm> #include <iostream> class cinterpreter_module : public Py::ExtensionModule<cinterpreter_module> { public: cinterpreter_module() : Py::ExtensionModule<cinterpreter_module>( "cinterpreter" ) { add_varargs_method("test", &cinterpreter_module::c_test, "test() is just a test."); initialize( "cinterpreter module initialize." ); Py::Dict d( moduleDictionary() ); } virtual ~cinterpreter_module() {} private: Py::Object c_test(const Py::Tuple &args) { std::cout << "c_test() called." << std::endl; return Py::None(); } }; extern "C" void initcinterpreter() { #if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL) Py::InitialisePythonIndirectPy::Interface(); #endif static cinterpreter_module* cinterpreter = new cinterpreter_module; } // symbol required for the debug version extern "C" void initcinterpreter_d() { initcinterpreter(); } -------------------------------------------------------------------------This SF.Net email is sponsored by the Moblin Your Move Developer's challengeBuild the coolest Linux based applications with Moblin SDK & win great prizesGrand prize is a trip for two to an Open Source event anywhere in the worldhttp://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________CXX-Users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/cxx-users _________________________________________________________________ |
From: Barry S. <ba...@ba...> - 2008-08-02 13:00:09
|
In the vcproj file for example I have the following: <Tool Name="VCLinkerTool" AdditionalOptions="/export:initexample" Make sure you are also have this /export:initcinterpreter in your vcproj file. Barry On Aug 1, 2008, at 08:13, <hap...@ho...> <hap...@ho...> wrote: > An update: > The same import error also happens with the debug versions of the > example module in the Demo. So I added > extern "C" void initexample_d(); > to python.cxx. This built, but when import example_d with python, > same problem. > So then I added initexample_d to the EXPORTS in the export > definition file, which built fine, but same problem. > This is on Vista, with Visual C++. > > > > > From: hap...@ho... > To: cxx...@li... > Subject: > Date: Thu, 31 Jul 2008 17:04:17 -0700 > > Below is a very simple extension, mostly cut from the provided > example. It compiles and builds the cinterpreter.pyd without > error, but when I do the following in python: > import cinterpreter > > I get this result: > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: dynamic module does not define init function > (initcinterpreter) > > I looked over the example again and again, and I simply cannot see > what the problem is. What is wrong? > > *********************************************************** > > #ifdef _MSC_VER > // disable warning C4786: symbol greater than 255 character, > // nessesary to ignore as <map> causes lots of warning > #pragma warning(disable: 4786) > #endif > > > #include "CXX/Objects.hxx" > #include "CXX/Extensions.hxx" > > > > #include <assert.h> > > > #include <algorithm> > #include <iostream> > > > class cinterpreter_module : public > Py::ExtensionModule<cinterpreter_module> > { > public: > cinterpreter_module() > : Py::ExtensionModule<cinterpreter_module>( "cinterpreter" ) > { > add_varargs_method("test", &cinterpreter_module::c_test, > "test() is just a test."); > > initialize( "cinterpreter module initialize." ); > > Py::Dict d( moduleDictionary() ); > } > > virtual ~cinterpreter_module() {} > > private: > > Py::Object c_test(const Py::Tuple &args) { > std::cout << "c_test() called." << std::endl; > return Py::None(); > } > }; > > extern "C" void initcinterpreter() > { > #if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL) > Py::InitialisePythonIndirectPy::Interface(); > #endif > > static cinterpreter_module* cinterpreter = new > cinterpreter_module; > } > > // symbol required for the debug version > extern "C" void initcinterpreter_d() > { initcinterpreter(); } > > > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users |
From: <hap...@ho...> - 2008-08-01 07:13:51
|
An update: The same import error also happens with the debug versions of the example module in the Demo. So I added extern "C" void initexample_d(); to python.cxx. This built, but when import example_d with python, same problem. So then I added initexample_d to the EXPORTS in the export definition file, which built fine, but same problem. This is on Vista, with Visual C++. From: hap...@ho...To: cxx...@li...Subject: Date: Thu, 31 Jul 2008 17:04:17 -0700 Below is a very simple extension, mostly cut from the provided example. It compiles and builds the cinterpreter.pyd without error, but when I do the following in python:import cinterpreterI get this result: Traceback (most recent call last): File "<stdin>", line 1, in <module>ImportError: dynamic module does not define init function (initcinterpreter)I looked over the example again and again, and I simply cannot see what the problem is. What is wrong?***********************************************************#ifdef _MSC_VER// disable warning C4786: symbol greater than 255 character,// nessesary to ignore as <map> causes lots of warning#pragma warning(disable: 4786)#endif#include "CXX/Objects.hxx"#include "CXX/Extensions.hxx"#include <assert.h>#include <algorithm>#include <iostream>class cinterpreter_module : public Py::ExtensionModule<cinterpreter_module>{public: cinterpreter_module() : Py::ExtensionModule<cinterpreter_module>( "cinterpreter" ) { add_varargs_method("test", &cinterpreter_module::c_test, "test() is just a test."); initialize( "cinterpreter module initialize." ); Py::Dict d( moduleDictionary() ); } virtual ~cinterpreter_module() {}private: Py::Object c_test(const Py::Tuple &args) { std::cout << "c_test() called." << std::endl; return Py::None(); }};extern "C" void initcinterpreter(){#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL) Py::InitialisePythonIndirectPy::Interface();#endif static cinterpreter_module* cinterpreter = new cinterpreter_module;}// symbol required for the debug versionextern "C" void initcinterpreter_d(){ initcinterpreter(); } _________________________________________________________________ If you like crossword puzzles, then you'll love Flexicon, a game which combines four overlapping crossword puzzles into one! http://g.msn.ca/ca55/208 |
Below is a very simple extension, mostly cut from the provided example. It compiles and builds the cinterpreter.pyd without error, but when I do the following in python: import cinterpreter I get this result: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dynamic module does not define init function (initcinterpreter) I looked over the example again and again, and I simply cannot see what the problem is. What is wrong? *********************************************************** #ifdef _MSC_VER // disable warning C4786: symbol greater than 255 character, // nessesary to ignore as <map> causes lots of warning #pragma warning(disable: 4786) #endif #include "CXX/Objects.hxx" #include "CXX/Extensions.hxx" #include <assert.h> #include <algorithm> #include <iostream> class cinterpreter_module : public Py::ExtensionModule<cinterpreter_module> { public: cinterpreter_module() : Py::ExtensionModule<cinterpreter_module>( "cinterpreter" ) { add_varargs_method("test", &cinterpreter_module::c_test, "test() is just a test."); initialize( "cinterpreter module initialize." ); Py::Dict d( moduleDictionary() ); } virtual ~cinterpreter_module() {} private: Py::Object c_test(const Py::Tuple &args) { std::cout << "c_test() called." << std::endl; return Py::None(); } }; extern "C" void initcinterpreter() { #if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL) Py::InitialisePythonIndirectPy::Interface(); #endif static cinterpreter_module* cinterpreter = new cinterpreter_module; } // symbol required for the debug version extern "C" void initcinterpreter_d() { initcinterpreter(); } _________________________________________________________________ Try Chicktionary, a game that tests how many words you can form from the letters given. Find this and more puzzles at Live Search Games! http://g.msn.ca/ca55/207 |
From: Barry S. <ba...@ba...> - 2008-07-20 08:48:55
|
PyCXX sources have been forked so that python 2.6 and earlier can be supported as well as python 3.0 onwards. PyCXX 6.0 will support Python 3.0 and will be developed on the trunk. svn co https://cxx.svn.sourceforge.net/svnroot/cxx/trunk PyCXX 5.4.x will suppport Python before 3.0 (finally version 2.6.x) on branch pycxx-5-maint. svn co https://cxx.svn.sourceforge.net/svnroot/cxx/branches/ pycxx-5-maint Barry Scott |
From: Sven A. <sv...@gm...> - 2008-07-07 15:51:53
|
Hello Barry, Thanks for that reply. I tried the same things in boost.python and it works. As I saw the boost.python - library and how she call Python-Function I looked for that in PyCXX too and did not found it. Thanks for your help. Now I can use PyCXX also. regards, Sven Am Sonntag 06 Juli 2008 09:50 schrieb Barry Scott: > On May 18, 2008, at 16:57, Sven Alisch wrote: > > Hi members! > > > > I am new to this list, so sorry for my bad english. I hope you > > understand me. > > > > First of all: Thanks for your great and well documented project. It > > is very > > simple to start programming a wrapper. I tried a little bit and it > > works. > > > > Now I want to do following. I want to program a callback function. > > This means > > I want to give my C++-Methods a Python-Function (like a c function > > pointer). > > Then I want to call this Python-Function like a callback-function > > in C. But > > how to do this? Could anybody be so sind to give me a hint? > > Sorry for the long time in replying... > > Do you want to call python code from C++? > > Create a Py::Callable object and use its apply() method to call > the python code. > > The pysvn project uses pycxx and uses a lot of its features. > Its project page is http://pysvn.tigris.org. It may have examples > that an useful to you. > > Barry > > > ------------------------------------------------------------------------- > Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! > Studies have shown that voting for your favorite open source project, > along with a healthy diet, reduces your potential for chronic lameness > and boredom. Vote Now at http://www.sourceforge.net/community/cca08 > _______________________________________________ > CXX-Users mailing list > CXX...@li... > https://lists.sourceforge.net/lists/listinfo/cxx-users |