Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compile python code into a dll

9,199 views
Skip to first unread message

Rolf Wester

unread,
Sep 10, 2012, 8:15:03 AM9/10/12
to
Hi,

I have Python code that I would like to compile into a dll (I have to
deliver a C/C++ callable dll and I don't want to reimpelement the Python
code in C/C++). It's not for extending Python but I want to call the
Python functions and classes from C/C++. It's more like extending C/C++
with Python. I would be very appreciative for any help.

Thank you in advance

Regards
Rolf

Ramchandra Apte

unread,
Sep 10, 2012, 9:08:04 AM9/10/12
to
http://docs.python.org/extending/embedding.html is the official docs for this thing
Embedding is similar to extending.

Miki Tebeka

unread,
Sep 10, 2012, 9:11:02 AM9/10/12
to
> I have Python code that I would like to compile into a dll (I have to
See http://docs.python.org/extending/embedding.html. You can pack your code in a zip file and load it from the DLL entry point (something like what py2exe does).

See also the Freeze tool - http://wiki.python.org/moin/Freeze.

HTH,
--
Miki (http://pythonwise.blogspot.com/)

Terry Reedy

unread,
Sep 10, 2012, 12:06:42 PM9/10/12
to pytho...@python.org
On 9/10/2012 8:15 AM, Rolf Wester wrote:

> I have Python code that I would like to compile into a dll (I have to
> deliver a C/C++ callable dll and I don't want to reimpelement the Python
> code in C/C++). It's not for extending Python but I want to call the
> Python functions and classes from C/C++. It's more like extending C/C++
> with Python. I would be very appreciative for any help.

Cython compiles CPython to C which can be compiled by and c/c++
compiler. I believe it can do the above. "This makes Cython the ideal
language for wrapping external C libraries, embedding CPython into
existing applications, ". I think the latter is what you want to do.

http:cython.org

--
Terry Jan Reedy

Rolf Wester

unread,
Sep 11, 2012, 3:05:00 AM9/11/12
to
Thank you all for your help. I'm going to try Cython.

Regards
Rolf
0 new messages