f



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 77009 articles. 3 followers. Post Follow

4 Replies
752 Views

Similar Articles

[PageSpeed] 25

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:

python is a python
python is a python ...

Parsing Python code with a Python Program
Hello, I would like to pass strings to a Python application and have them executed as though they were lines of code. Is 'exec()' the function that I am looking for and/or is there an example of this somewhere? Thanks, Seaweed Hello, I had my quotes wrong is all. EXAMPLE: exec 'print "Hello"' OR: s = 'print "hello"' exec s Thanks anyway, Seaweed pgw wrote: > Hello, > > I would like to pass strings to a Python > application and have them executed as though > they were lines of code. > > Is 'exec()' th...

ANN: pyc -- python compiler in python
Hi. pyc is a compiler that compiles source code to bytecode and it's written entirely in python. It's based on the compiler package from the stdlib but the parser/lexer are implemented in python. Moreover, it does some optimizations on the bytecode. http://students.ceid.upatras.gr/~sxanth/pyc/ Feedback is most welcome. Stelios ...

Licensing Python code under the Python license
I'm currently working on a Python program, and was wondering if it's possible to license the program, some associated tools, and a few other libraries I've written under the Python license. I had a look at the new PSF Python license on the list of OSI-approved licenses, but it makes numerous direct mentions of Python and the PSF. Is there any acceptable way to simply say that a particular source file is under the PSF license (like you can w/ the GPL/LGPL), and would it even apply? Or am I just on the completely wrong track, and should I look elsewhere? :P Thanks. -- Daniel ...

I could use some help making this Python code run faster using only Python code.
I am new to Python however I would like some feedback from those who know more about Python than I do at this time. def scrambleLine(line): s = '' for c in line: s += chr(ord(c) | 0x80) return s def descrambleLine(line): s = '' for c in line: s += chr(ord(c) & 0x7f) return s def scrambleFile(fname,action=1): if (path.exists(fname)): try: f = open(fname, "r") toks = fname.split('.') while (len(toks) > 2): toks.pop() fname = '.'.j...

compiling python code
Hi, I have a python file inside a zip file. I'd like to compile it and add the resulting .pyc file into the zip. I tryed reading the source and compiling it using compile(), but I don't know how to write .pyc file. Can someone give me some help? bye, gabriele Gabriele *Darkbard* Farina wrote: > I have a python file inside a zip file. I'd like to compile it and add > the resulting .pyc file into the zip. I tryed reading the source and > compiling it using compile(), but I don't know how to write .pyc file. > Can someone give me some help? a PYC file consists ...

RE: [Python-Dev] Python Coding Tools
> From: Aki Kubota [mailto:akubota@ntsp.nec.co.jp] > > Im new to this mailing list. And Im interested in Python tools. > Stuff you use to make coding easier. like Eclipse for Java. This is not appropriate for Python-Dev, which is for discussion of the = development *of* Python, not development *with* python. I have copied your message to the appropriate list - python-list. Tim Delaney ...

Compiling Python extensions for different Python installation
Hello: I have a machine that already has Python 2.2 installed. Since I do not have root access to the machine, I have installed Python 2.3 from source to my own private directory. I can use this fine. When I build my own C module extension and try to run it from Python 2.3 however, I get this message: /test-wrk/test_manager/commonlib.py:12: RuntimeWarning: Python C API version mismatch for module elxml: This Python has API version 1012, module elxml has version 1011. Could this be because the compilation was made against 2.2 and run from 2.3? If so, is there a way to force my module comp...

Need compile python code
Need compile python code, source is in html and starts with parameters: #!/bin/sh - "exec" "python" "-O" "$0" "$@" I have installed ActivePython for windows. mistral wrote: > Need compile python code, source is in html and starts with > parameters: Excuse me? > #!/bin/sh - > "exec" "python" "-O" "$0" "$@" Is the line break intended? > I have installed ActivePython for windows. What exactly do you want? Python code is always compiled (to byte code) before it's run. ...

Embedding Python in Python
Hi, I've been programming in Python for a couple of weeks now and am quite impressed with the language - it was very easy to learn (it actually reminds me a lot of programming in BASIC many many years ago - it's very fast to hack together a couple lines of code in interactive mode). I'm throwing together a simple little game (sort of a MUD-type thing) as my first 'big' project, and I thought it would be cool to be able to script the game in Python. Basically, I want to be able to type scripts in from within the game and attach them to objects, monsters, rooms, whatever. N...

Serializing Python compiled code.
Hi everyone, In a C++ application having a Python interpreter embedded, is it possible to compile a small Python snippet into object code and serialize the compiled object code to, for example, a database? I am exploring the possibility of writing a data driven application, where small-sized object code can be read from a database and executed. Keeping aside all other considerations such as security, etc for a moment, is this feasible? Please do reply. Thanks, -/renji --- renjipanicker@gmail.com wrote: > In a C++ application having a Python interpreter > embedded, is it > possibl...

compiling to python byte codes
Hi, I remembered reading a MSc thesis about compiling Perl to Java bytecodes (as in java class files). At least, it seems that someone had compiled scheme to java class files quite successfully. I'm wondering if something of such had been attempted in python, as in compiling X language into .pyc. I do not understand the schematics of .pyc files but I assume that they are the so called python bytecode files. Or is there any documentation or books that is the python equivalent of "Programming for the Java Virtual Machine" by Joshua Engel? Thanks Maurice -- Maurice Han Ton...

Compiling snippets of python code
I need some advice on compiling snippets of python source at runtime. So perhaps some python experts can point the way. I am rewriting an old Java app in python. It tries to find solutions to computational problems based on the idea of genetic evolution. The Java version just used an array of bytes for the genomes. These byte sequences were bytecode which told a rudimentary VM (virtual machine) which maths functions to call. It used another array as a small chunk of virtual memory for doing the calculations. Having seen the docs on python's compile module, I'm thinking of doing it d...

compiling mysql-python for python 2.3 on windows
Hello, I need mysql-python for python 2.3 on windows. I downloaded the source and tried to build it myself, but I get linker errors: mysqlclient.lib(password.obj) : error LNK2001: unresolved external symbol __ftol2 The problem seems to be, that the mysql lib is build with VC7, but distutils tries to compile with VC6 (which are both on my machine). Can I force distutils to use VC7? Or has somebody prebuild binaries for windows? Or has somebody another hint on how to get it working on windows? I have also mingw 3.2 installed, if it would be helpfull!? regards, Achim ...

Invoking Python from Python
Hi all, I have a need to create a Python script on the fly from another Python program and then execute the script so created. Do I need to invoke Python through os.spawnl or is there a better way? Thanks, -- John Am Tue, 08 Nov 2005 08:10:25 -0800 schrieb John Henry: > Hi all, > > I have a need to create a Python script on the fly from another Python > program and then execute the script so created. Do I need to invoke > Python through os.spawnl or is there a better way? Hi, creating source code with a script, is no good solution. Once I had to maintain lisp code which stored its data in lisp code, too (incl. conditions and loops). It was a nightmare. Please explain what you want to do, and we will find a better solution. HTH, Thomas -- Thomas G�ttler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de Spam Catcher: niemand.leermann@thomas-guettler.de In article <pan.2005.11.08.16.21.11.472836@thomas-guettler.de>, Thomas Guettler <niemand.leermann@thomas-guettler.de> wrote: . . . >creating source code with a script, is no good solution. > >Once I had to maintain lisp code which stored its data in lisp code, too >(incl. conditions and loops). It was a nightmare. > >Please explain what you want to do, and we will find a better solution. . . . Yes and no. There are times when it's justified. I ENTIRELY agree, though, that many people who *think* that's what they...

How to use internal python c funtions, from python code
Hi I'm coming from this link ( https://groups.google.com/forum/#!topic/python-ideas/cBFvxq1LQHM), which proposes to use long_to_decimal_string(), int_to_decimal_string() functions for printing integers in different bases. Now is there anyway i can use such internal functions from pure python code, passing ctypes when the arguments are c datatypes. For competitive programming purposes I really want to use those functions for speed. ...

Popular Python projects with lots of pure Python code
For my thesis (once the bloody thing stops throwing bugs at me) I am going to need to collect stats on the frequency that atomic types in local variables are applied to various opcodes and methods. That means that I need something to collect stats off of. So I am trying to come up with a list of projects I can use to get my stats from. the stdlib is a no-brainer. Also plan to use Docutils. But beyond those most of the big Python projects I can think of have a ton of C code which is of no use to me. I don't need to be able to run it, just going to be compiling to .py files. Any...

Make Python Compilable, convert to Python source to Go
Make Python Compilable This tool can be called 'Python to GoLang', which translate Python source t= o Golang source. And then you can compile the Go files to executable binary= .. (btw: Go is a new C-like compilable language, open source). Generally, people consider Python as a script language. It has high develop= ment efficiency, but run too slowly, interpret running, and can not compile= .. It depends to Python environment, can not employ alone. For years, many people have do a lot of job try to improve running speed of= Python, include Pypy, Cython. But all of these ...

Python mascot? How about a Pythoneer?
I've been thinking that a good Python mascot might help in raising public awareness of Python. The problem with a snake as a mascot is that it is not anthropomorphic enough. An effective mascot has to have something approximating two arms, two legs, and a head, so that he can be put into various interesting situations and adventures. (At the very least, he has to be able to work a keyboard and a mouse!) Good examples can be found in some of the imaginative things that have been done with Linux's Tux. So a snake is out. So are Terry Gilliam's wonderful cartoons for the Flyin...

compiling the python mathlink module on python 2.3+
I'm wondering whether someone succesfully managed to compile the python mathlink for python 2.3+ with the free MS toolkit compiler? http://www.vrplumber.com/programming/mstoolkit/ is a useful link concering this... i managed to compile the module, but it'll crash as soon as i import it... cheers, Jelle. ...

Python to Python communication
Hello, I have a group of Python programms which I want to teach to "talk to each other". All run on Windows, on the same computer or in the same intranet. Security of communication is not an issue (encryption on lower level protocols / intra computer communication). Partially these programs are using wxPython. It is important that the communcation is "only an added feature", I am not willing to spend big memory / computing ressources on it. So I googled and came up with at least the following opportunities: XMLRPC - quite "simple" to implement within python, contained in my favourite web framework Quixote / medusa SOAP - around the same amount of work as XMLRPC ----> these two are fully buzzword compatible to enterprise communication needs. But are they really lightwight and needed? Banana - within the twisted framework. Is described as high performance with very litte ressources. From my scanning of twisted it is meanwhile possible to integrate it within wxPython and you only need to sell the soul of your firstborn for it; but I got the impression twisted rather needs a total commitment than a "I just need some banana, man" pyro - Python Remote Objects. Irmen de Jong has a "get Firefox" icon on it's page and he plays with the name "pyro", which makes a good impression. It looks rather "ripe", but: he is talking about "pyro 4.0" which will be incompatible with pyro ...

Object Oriented vs Pythonic Code, and Pythonic standards
It seems the more I come to learn about Python as a langauge and the way its used I've come across several discussions where people discuss how to do things using an OO model and then how to design software in a more "Pythonic" way. My question is, should we as python developers be trying to write code that follows more of a python standard or should we try to spend our efforts to stick to a more traditional OO model? For example, in C++ I might make a file that defines a class and all its methods, at which point I create an object and do things with it. My interpretat...

Creat a DLL File from python code, and use that DLL file in other Platform (Labview, Java .NET etc)
Hi, I would like to request your attention for this very specific issue: I have several classes in Python, and now I want simply re-use it, in other language. The closest to solution I think I came was with this site: http://www.py2exe.org/index.cgi/Py2exeAndCtypesComExeServer?highlight=%28%28Py2exeAndCtypesComDllServer%29%29 but I not able to solve questions related with TLB files and __init__.py files. So, could anyone give a tip about HOW TO CREAT a dll file from Python? thank in advance AMMS macedo.silva@gmail.com wrote: > Hi, > > I would like to request your attention ...

Re: compiling the python mathlink module on python 2.3+
I've been having this same problem with Python 2.2. Any suggestions? Cheers, Mitch Stonehocker -----Original Message----- From: jelle [mailto:jelleferinga@gmail.com] Subject: compiling the python mathlink module on python 2.3+ I'm wondering whether someone succesfully managed to compile the python mathlink for python 2.3+ with the free MS toolkit compiler? http://www.vrplumber.com/programming/mstoolkit/ is a useful link concering this... i managed to compile the module, but it'll crash as soon as i import it... cheers, Jelle. Actually Mitch, I wa...

Web resources about - Compile python code into a dll - comp.lang.python

Compile time - Wikipedia, the free encyclopedia
In computer science , compile time refers to either the operations performed by a compiler (the "compile-time operations"), programming language ...

Information Is Power: Facebook Develops ThreatData To Compile Data On Web Threats
Part of being able to combat malware, phishing, and other online threats is gathering and consolidating as much data on those threats as possible, ...

Credit Suisse compiles yuan winners and losers list: report
... the lowers. A list of Australian winners and losers from the decision by China’s government to devalue the renminbi has reportedly been compiled ...

Beijing residents compile own death toll in flooding
Beijing residents fed up with a lack of official updates are compiling their own death tolls for last weekend's deadly floods in the capital, ...

New report compiles 25 years of UFO sightings in Canada
A Winnipeg group called Ufology Research has compiled and analyzed reported sightings of UFOs across Canada over the last 25 years.

China to compile new edition of cancer atlas
China to compile new edition of cancer atlas People's Daily Online ... Chinese Academy of Sciences and Chinese Center for Disease Control and ...

Googlers compile holiday search tips in rap video to help Santa with flight
Google is in full holiday swing (what, you haven't heard?). They just posted, on YouTube, a rap video that was put together by its employees, ...

Popular Dating Site Compiles 15 Stupid Reasons To Date A Lawyer
A new listicle describes a really horrible person to date and then says, "We think lawyers are probably this awful, go date them!"

Author Compiles Lively L.A. Times History Lesson
Long before Eli Broad , Rupert Murdoch and people willing to pay $140 million for the Las Vegas Review-Journal, there was Harrison Gray Otis ...

Japan, China compile written pledge to improve ties ahead of summit
Japan and China reached a rare written agreement on Nov. 7 to improve relations strained by a territorial dispute over the Senkaku Islands in ...

Resources last updated: 3/4/2016 10:20:01 AM