Compile python code into a dll

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
0
9/10/2012 12:15:03 PM
comp.lang.python 74766 articles. 15 followers. Post Follow

4 Replies
407 Views

Similar Articles

[PageSpeed] 32
On Monday, 10 September 2012 17:45:11 UTC+5:30, Rolf Wester  wrote:
> 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

http://docs.python.org/extending/embedding.html is the official docs for this thing
Embedding is similar to extending.
0
maniandram01 (167)
9/10/2012 1:08:04 PM
> 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/)
0
miki.tebeka (424)
9/10/2012 1:11:02 PM
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

0
tjreedy (5459)
9/10/2012 4:06:42 PM
Thank you all for your help. I'm going to try Cython.

Regards
Rolf


On 10/09/12 14:15, Rolf Wester wrote:
> 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

0
9/11/2012 7:05:00 AM
Reply:
Similar Artilces:

Catalog of Compiler Construction Products
Archive-name: compilers/construction-tools Last-modified: 2001/08/28 Version: 18 Catalog of Compiler Construction Products - Eighteenth Issue This posting may be reproduced in any form without further permission, as long as it is left unchanged. August 2001, transformal GmbH, Berlin. EIGHTEENTH ISSUE This catalog lists products and services for the construction of programming language compilers and related programming tools. It covers compiler generators, corresponding grammars, reusable parts of compilers, reusable parts of other programming tools and related consulting or programming ser...

US-TX-Round Rock: Programmer, Java, Debug Code, 9mo (45392732401)
US-TX-Round Rock: Programmer, Java, Debug Code, 9mo (45392732401) ================================================================== Position: Programmer Reference: ALM00048 Location: Round Rock TX Duration: 9mo Skills: Java Debug Code Programming Languages XML Software Developer Development Test Scripting JavaScript Programmer Macromedia Flash Macromedia C++ Testing Methodologies ...

Python Fractions issue.
(From: http://paddy3118.blogspot.com/2008/09/python-fractions-issue.html) There seems to be a problem/difference in calculating with the new fractions module when comparing Python 26rc2 and 30rc1 I was reading the paper "Interval Arithmetic: Python Implementation and Applications" and thought to try the first example function f(x,y), which needs more precision than Python floating point provides (on my Windows PC), to calculate a sensible answer. Ahah, I thought, lets try this with Fractions - so I first installed Python 30rc1, typed in the Function - saw the rubbish result, then ...

Sun CC compiler: function overloads
Hi, I apologize in case this is not a good newsgroup for this question. I have a compilation problem with "CC: Sun C++ 5.8 Patch 121017-01 2005/12/11". The following example code illustrates the problem: #include <iostream> void f (int a) { std::cout << "f1\n"; } void f (int a, int b) { std::cout << "f2\n"; } void g (int a, int b) { std::cout << "g2\n"; } void g (int a) { std::cout << "g1\n"; } void select (void (*fp) (int)) { if (static_cast <void (*) (int)> (f) == fp) // line 9 s...

Oracle package coding standard advise seeked
I have written my first Oracle package. Older package in my company make use of the PRAGMA directive. I've just read that this directive have been replaced with function hints PARALLEL_ENABLE and DETERMINISTIC. But my package rely on the fact that a global variable contain a user+session unique list of permissions, so it is my understanding that these hints cannot be used in my particular case. So my question is, to make my package state of the coding art, do I need to do anything else than this: (code modified for public posting) CREATE OR REPLACE PACKAGE PI_MY_NEW_PACKAGE IS TYPE T_M...

compile error in wxWidgets SVN
I just updated svn version and got following error: =2E/src/unix/utilsunx.cpp: In=20 constructor =E2=80=98<unnamed>::ArgsArray::ArgsArray(wchar_t**)=E2=80=99: =2E./src/unix/utilsunx.cpp:395: error: request for member =E2=80=98release= =E2=80=99=20 in =E2=80=98*(((wchar_t**)(((unsigned int)i) * 4u)) + wargv)=E2=80=99, whic= h is of non-class=20 type =E2=80=98wchar_t*=E2=80=99 make: *** [basedll_utilsunx.o] Error 1 Source: svn Happens with GTK2 & Console builds (below are configure options) Using Kubuntu hardy 2.6.24 GTK2 configure:=20 =2E./configure \ ...

Dislin compilation
Hi everybody I want to recompile the DISLIN graphics module for Python under Linux, because I think it is one of the best graphics libraries at present. The included module was for version 2.0 and I want it for 2.2 or maybe 2.3. The problem is, that I use the small make_py script which only calls the gcc compiler CC="gcc -fPIC -c -O" PYTH_INC="/usr/local/include/python2.0" PYTH_CONF="/usr/local/lib/python2.0/config" gcc -shared -Wl,-soname,dislinmodule.so -o dislinmodule.so *.o \ -L$DISLIN -ldislnc but I think many variables arent configured, so a l...

Re: SQL code to keep all fields in data set
try something like this Proc SQL ; Create Table Need As Select *, Max( A ) As A , B , Max( C ) As C From foo Group By B ; Quit ; * in the front would give you all obeservations thanks On 5/29/07, Tom White <tw2@mail.com> wrote: > > Proc SQL ; > Create Table Need As > Select Max( A ) As A , B , Max( C ) As C > From foo > Group By B ; > Quit ; > > > > Hello, > > The above SQL code works with fields A, B, and C found in the foo data > set. > > But this foo data set has many more fields besides A, B, and C. > > I wis...

CVS error compiling MT
I have this problem Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland Error: Unresolved external '__endthreadex' referenced from D:\LENGUAJE \XHARBOUR\ LIB\VMMT.LIB|thread Error: Unresolved external '__beginthreadex' referenced from D: \LENGUAJE\XHARBOU R\LIB\VMMT.LIB|thread ...

Weird C++ Compiler Ignores Errors
C++ Compiler looks weird. It will succeed to compile if your source code has some errors. I wrote an example of generic class. I commented Errors.Print() in the main function body. Errors.Print() has two variables _x and _y, but class definition only shows two variables x and y. Go ahead and try to compile. Read my comments below. template< typename T > class IgnoreErrors { public: IgnoreErrors() : x( 1 ), y( 2 ) {} ~IgnoreErrors() {} void Print(); T x; T y; }; template< typename T > void IgnoreErrors< T >::Print() { _x =3D 5; _y =3D ...

Re: [tao-users] strange compiling problem with AMI
Hi, To ensure that we have proper version/platform/compiler information, please make sure you fill out the appropriate problem report form (PRF), which is in $ACE_ROOT/PROBLEM-REPORT-FORM $TAO_ROOT/PROBLEM-REPORT-FORM or in $ACE_ROOT/BUG-REPORT-FORM $TAO_ROOT/BUG-REPORT-FORM in older versions of ACE+TAO. Make sure to include this information when asking any questions about ACE+TAO since otherwise we have to "guess" what version/platform/compiler/options you've using, which is error-prone and slows down our responsiveness. There have been AMI changes arou...

10USD to remotelly logon on my PC and compile a GIT project (pure in Java)
10USD for a help. That is.. remotely compile a pure Java project (traccar),= from git source. Instructions: I have installed on my host, this web service: (http://goo.gl/sXGT8K) (use demo, demo) About my server specs: ------------------------------- //from ssh// java -version (returns this..) java version "1.6.0_30" OpenJDK Runtime Environment (IcedTea6 1.13.1) (rhel-3.1.13.1.el6_5-x86_64) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode) uname -a (return this..) Linux web370.webfaction.com 2.6.32-458.23.2.lve1.2.45.el6.x86_64 #1 SMP Fri= Nov 22 08:02:49 ES...

help me compiling
hi i need help for compiling mfile and GUI, i try some cases as below: 1) i compile a simple mfile(function) which has no figure easily by using mcc -m myfun.m and then by copying win folder of matlab with my exe file. it works with no problem. ( Using Matlab 6.5 ) 2) now i am trying to compile a simple mfile which contains plot comman. here i use mcc -B -sgl myfunc when i get the result, it only do the simple part and can not plot the figures, i also copy the win folder of matlab with my exe file, but it does not work. ( using matlab 6.5) 3) when i use matlab 7 with compiler 4, ...

Is it possible to read array variable from C code?
Hello everyone There is a file.tcl : set tclTable(1) "91" set tclTable(2) "92" set tclTable(3) "93" It is executed in C code by proper use of Tcl_Eval() Now, I am able to get size of this table by executing command "array size tclTable" and reading the result (result "3") I am also able to ensure that this variable is an array 'type' by "array exists tclTable" (result "1") The question is: How is it possible to get some info about this tclTable without executing command, but with Tcl_ListObjGetElements(interp, l...

Compiled or not compiled
I need to distinguish between two situations: one when a Matlab function is run from Matlab command window and the other one when it is run in compiled mode. Any ideas how to do this? Thanks Tomy Duby "Tomy Duby" <tomy.duby@agilent.com> wrote in message news:idq8q8$85k$1@fred.mathworks.com... > I need to distinguish between two situations: one when a Matlab function > is run from Matlab command window and the other one when it is run in > compiled mode. > Any ideas how to do this? HELP ISDEPLOYED. -- Steve Lord slord@mathworks.com comp.s...

Windows Compilation Madness
No point in keeping this discussion in the Zed thread... On Jan 2, 2008, at 10:55 AM, M. Edward (Ed) Borasky wrote: > Thufir wrote: >> Completely off topic, but what's the equivalent for Linux? >> > There is a compiler, usually gcc but others exist. It translates the C > code to an object file. Then there is a linker which collects all > of the > object files and translates them to a "shared library", which usually > has a name ending in ".so". At run time, the shared library is brought > into working memory the first time a Ruby prog...

error with Borland's command line compiler
comp.os.ms-windows.programmer.win32 error with Borland's command line compiler What is required to make a program originally written for Microsoft's C compiler workable with Borland'c command line compiler? This uses a "int WINAPI WinMain(...)" labeled initial function and the linker complains it can' t find _main() requested by c0x32.obj. Does Borland have the initializing code that is apparently neccessary for this? If not, can the required routine(s) be had from Microsoft? Any suggestions appreciated. Hul Hul Tytus wrote: > comp.os.ms-wind...

BASIC compiler
Hi, Is there any BASIC compiler for Digital unix 4.0? It will be best if it is free. Thanks, Anno Domini 12-4-2004 20:00, Haifang Li sprak aldus: > Hi, > > Is there any BASIC compiler for Digital unix 4.0? It will be best if it is > free. > > Thanks, > > No, DEC BASIC is for OpenVMS. There does not seem to be an interpretor/compiler specificly for Tru64 available. You could try download sources and compile BASIC yourself. A few links from sourceforge: https://sourceforge.net/projects/bwbasic/ https://sourceforge.net/projects/hbasi...

compiling using native compiler
When I try to compile python 2.3.4 using SGI's native compiler ../configure --without-gcc followed by make I get error make c++ -o python \ Modules/python.o \ libpython2.3.a -ldl -lpthread -lmpc -lm ld32: WARNING 84 : /usr/lib32/libdl.so is not used for resolving any symbol. ld32: FATAL 9 : I/O error (-lmpc): No such file or directory collect2: ld returned 32 exit status *** Error code 1 (bu21) but I see it in /usr/lib ls -l /usr/lib/mpc -rwxrwxr-x 1 root sys 598996 May 20 17:10 /usr/lib/mpc "SS" ...

Web site for sharing code, controls, etc.
Hello all wxWindow'ers ! I was wondering if there were some web site where users share source code... Some equivalent to www.codeguru.com or www.codeproject.com which are dedicated to Microsoft tools and products. This might be useful. Have a nice day Gilles Gilles wrote: > > I was wondering if there were some web site where users share > source code... > > Some equivalent to www.codeguru.com or www.codeproject.com which are > dedicated to Microsoft tools and products. > > This might be useful. It would be very useful. All the b...

Re: Why does this compile? 472421
On Fri, 30 Nov 2007 15:53:26 CST, Bart van Ingen Schenau wrote: >> Consider the following code: > /* 1 */ >> template<class T> >> class A{ >> T x_; >> public: >> A():x_(0){}; >> A(T x):x_(xx){}; // Note typo: 'xx' instead of 'x' in argument [...] >> Why doesn't the compiler detect this typo? > Probably because your compiler does not implement the rules for > name-lookup in a template correctly. > > According to the rules, the compiler should try to resolve the name 'xx' > as soon ...

5.3 Compiler not compiling all modules under Windows
This is a strange one, and I'm at my wit's end. For some reason, on my laptop (Win98se) Clipper will not compile all modules, instead stopping after about 50% of the program. There are no error messages, and Clipper acts as though all is normal, like the modules weren't even there. The program compiles normally on the same computer under DOS, as well as my desktop under a similar configuration. Any suggestions? This is going to be a pain when I have to travel next. John John Sounds like you don't have enough memory for your DOS sessions. What tweaks if any have you don...

Best tools for compiling Ruby (Windows)?
------=_Part_1895_1822748.1141424270957 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi I'd like to figure out how I can download and compile the latest version of Ruby on Windows. I know I can get Curt's one-click installer, but I'd quit= e like the ability to compile it for myself. Question is, which is the best (free) compiler for the job? Visual C++ or Borland? Or another? I have tried to use the MS VC++ Toolkit 2003, with NMAKE 1.5 - both freely downloadable from MS but as soon as I issue a win32\con...

Re: Compile error with Java
Eric, Did you remember to save the file as Non-Qedit format? regards, Robert W.Mills Systems Development Manager Windsong Services (01689) 870622 x3005 Eric Therrien <mailto:TheJumpinJackFlash@HOTMAIL.COM> wrote on 17 February 2004 15:34: > Hi, > > We are looking at having our HP3000 talk with a client station using > Java on both sides. > > When I compile the simple "Hello World" program on the 3000, I get the > following error: > > error: compiler message file broken: > key=compiler.err.java.io.IOException: File &g...

Should this compile?
for (int i=0;i<10;++i) { int i = -1; cout<<i<<endl; } As far as I understand, the int declaration in the for statement makes it declared for the scope of the for loop. So it would not be possible to declare another int i. On gcc-3.2.3, the above code does compile and displays 10 lines of -1. Is it a standard compliant behaviour? -- +-------------------------------------------------+ | Xavier D�coret - Post Doct | | Graphics Lab (LCS) - MIT | | mailto: decoret@graphics.lcs.mit.edu | | home : http://www.graphics.lcs.mit.edu/~decoret| +-------------------...