On Sun, Jun 3, 2012 at 6:33 PM, Paul Emsley <paul.ems...@bioch.ox.ac.uk> wrote:
>
> OK, thanks again.
>
> I have done some reading about boost.python.  I understand now (as you
> imply) that the idea is not to (have to) use PyObject *s.  OK, let's try
> with that for the moment.

Yeah, the real problem is that I'm really not sure how to build a
PyObject * for an RDKit object that would actually play well with the
rest of the boost.python wrapped code. If we have to do this it's
probably going to require a deep-dive into the boost.python source;
that's unlikely to be a fun experience.

> I have put the code for how I understand the boost interface should work
> into the repo now, but it doesn't compile for me.  I can't determine
> what to do from the compile message - perhaps this is the informative
> compiler message to which you refer.. :)
>
> So my question is: is this the pointer ownership message to which you
> refer?  If so, what do I do?  Please tell me to RTFM if appropriate...

Indeed it is. The error you're getting includes this:
home/paule/autobuild/build-coot+rdkit-pre-release-gtk2-python/include/boost/python/detail/invoke.hpp:75:82:
error: no match for call to '(const
boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<RDKit::ROMol*>)
(RDKit::ROMol*)'
(this error actually used to be somewhat more informative... they seem
to have changed something)

What it's telling you is that you need to specify a
return_value_policy -- something that tells boost.python what to do
about ownership of the pointer you return. There's an explanation
here:
http://www.boost.org/doc/libs/1_49_0/libs/python/doc/tutorial/doc/html/python/functions.html#python.call_policies

some reference material here:
http://www.boost.org/doc/libs/1_49_0/libs/python/doc/v2/return_value_policy.html

or you could just do this:
    def("new_regularize",  coot::new_regularize,
return_value_policy<manage_new_object>());

That assumes that you want python to take over ownership of the
returned molecule.

> If/when we get this to work, I will try also passing a PyObject * (for
> the target geometry description - that may not work - so I may also try
> simply boosting my target geometry class - hmmm!)

If you are going to want people to be able to make changes to that
class from Python you'll probably need to wrap the class. If you just
want to return an opaque pointer (so that you have access to the
pointer from Python but can't do anything with it), then you can just
use this:
http://www.boost.org/doc/libs/1_49_0/libs/python/doc/v2/return_opaque_pointer.html

Best,
-greg

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rdkit-devel mailing list
Rdkit-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-devel

Reply via email to