 |
19-01-2009, 04:40 PM
|
#1 (permalink)
|
|
The Smaller Bang
Join Date: Sep 2007
Location: Gautham City
Posts: 7,492
|
Creating Binary Python Executables
There are a handful of python programs I find really useful but they are all in *.py format. Often I need to use them in a distro which has no package for python installed or is barebones. In such cases, is there a way to make binary python executables ? How ?
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
|
|
|
|
Advertisements. Register and be a member of the community to get rid of them.
|
|
Advertisement
|
|
19-01-2009, 04:50 PM
|
#2 (permalink)
|
|
Sami Hyypiä, LFC legend
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
|
Re: Creating Binary Python Executables
Quote:
Originally Posted by MetalheadGautham
There are a handful of python programs I find really useful but they are all in *.py format. Often I need to use them in a distro which has no package for python installed or is barebones. In such cases, is there a way to make binary python executables ? How ?
|
Yes. It is called creating Frozen Binaries. In frozen binaries, they bundle the byte code of your program with the interpreter into a single binary. Keep note you have to account for size of the interpreter in this case. A typical python source .py will cost just few KB will take a few more MBs.
Anyway PyInstaller will do the job.
http://pyinstaller.python-hosting.com/
If you wan't to target Microsoft Windows alone, then there's py2exe:
http://www.py2exe.org/
|
|
|
19-01-2009, 05:42 PM
|
#3 (permalink)
|
|
The Smaller Bang
Join Date: Sep 2007
Location: Gautham City
Posts: 7,492
|
Re: Creating Binary Python Executables
Thanks. Does py2exe work for all python files effectively ?
And I also need something for linux. I prefer an official built-in method if there exists one.
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
|
|
|
19-01-2009, 06:09 PM
|
#4 (permalink)
|
|
Sami Hyypiä, LFC legend
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
|
Re: Creating Binary Python Executables
Quote:
Originally Posted by MetalheadGautham
Thanks. Does py2exe work for all python files effectively ?
And I also need something for linux. I prefer an official built-in method if there exists one.
|
PyInstaller works for Linux, I have not tested it though. But there's no "official built-in" method AFAIK.
In Linux it is rare if one needs a binary eg. your case in which there's no python (which distro it is BTW?)
It is more practical to create a bash script or creating a launcher if python's installed.
Either:
OR
Create a bash script: (if you want to make things harder,  )
Code:
#!/usr/bin/env bash
python code.py
read -p "Press any key to exit"
|
|
|
19-01-2009, 07:30 PM
|
#5 (permalink)
|
|
I see right through you.
Join Date: Sep 2005
Location: Chennai
Posts: 597
|
Re: Creating Binary Python Executables
Every self-respecting mainstream linux distribution comes with python, so there's no need for you to worry about whether that will be there.
As far as an installation method is concerned, the general python way of producing an installer is using the python disutils module. Check that one out.
__________________
I didn't make the world, I only try to live in it.
http://lucentbeing.com
-- Sykora --
|
|
|
19-01-2009, 07:37 PM
|
#6 (permalink)
|
|
The Smaller Bang
Join Date: Sep 2007
Location: Gautham City
Posts: 7,492
|
Re: Creating Binary Python Executables
I am not talking about mainstream distros. I am talking about certain use and forget live distros.
And yeah, is there something similar for perl ? I want a binary of powerpill so that I can use it in a barebones systemto start installing software.
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
|
|
|
27-01-2009, 03:11 PM
|
#7 (permalink)
|
|
The Smaller Bang
Join Date: Sep 2007
Location: Gautham City
Posts: 7,492
|
Re: Creating Binary Python Executables
bump.
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
|
|
|
27-01-2009, 07:27 PM
|
#9 (permalink)
|
|
The Smaller Bang
Join Date: Sep 2007
Location: Gautham City
Posts: 7,492
|
Re: Creating Binary Python Executables
hmm... perlcc is what I am looking for.
Does it attach an interpreter like python or does it create REAL executable code ?
And is there a way to create REAL executable code from Python, like in C++ ?
__________________
http://TheSmallerBang.wordpress.com
eMachines E725 - T4400 2.2GHz, 1GB, 160GB
Nokia 5130XM * T-Sonic 610 2GB
Nokia 2323C * Samsung Galaxy Y
Apple iPad 2 16GB WiFi
|
|
|
27-01-2009, 07:49 PM
|
#10 (permalink)
|
|
Sami Hyypiä, LFC legend
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
|
Re: Creating Binary Python Executables
Quote:
Originally Posted by MetalheadGautham
hmm... perlcc is what I am looking for.
Does it attach an interpreter like python or does it create REAL executable code ?
|
I think it attaches an interpreter like Python.
Quote:
|
And is there a way to create REAL executable code from Python, like in C++ ?
|
NO.
However...There is Shedskin C++ Translator which attempts to translate Python Code to C++.. However it is still at infancy and limits python to being "statically typed" and may not work for all scripts.
If indeed Python could be totally compiled to machine level code, nobody would have used C/C++.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|