473,695 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python executables?

How can I make executables with python?
I found some utilities that claim they can do something like that like
Installer and py2exe but they actualy pack the code in a huge arhive!
This solves the problem of giving python programs to users who don't
have python but doesn't solve the problem of the source "secrecy"
(copyright).
And the programs also run much slower and become extremely big compared
to a normal C++ program for example. I made a test and a 2 programs
doing the same thing where 400 KB with C Builder (static linked) and
2.80 MB with python+installe r in an arhive packed with upx and 6.9 MB
with py2exe(unpacked ). And the speed difference was huge.
So can a python program become a "real" executable(I am refering both to
windows and unix platforms)?
If this is imposible with python is it possible with jpython?
Jul 18 '05 #1
7 4995
Catalin wrote:
How can I make executables with python?
I found some utilities that claim they can do something like that like
Installer and py2exe but they actualy pack the code in a huge arhive!
This solves the problem of giving python programs to users who don't
have python but doesn't solve the problem of the source "secrecy"
(copyright).
And the programs also run much slower and become extremely big compared
to a normal C++ program for example. I made a test and a 2 programs
doing the same thing where 400 KB with C Builder (static linked) and
2.80 MB with python+installe r in an arhive packed with upx and 6.9 MB
with py2exe(unpacked ). And the speed difference was huge.
So can a python program become a "real" executable(I am refering both to
windows and unix platforms)?
If this is imposible with python is it possible with jpython?


Here you expose 3 different problems :

1/ source "secrecy" (copyright) :
It's the wrong problem. *Any* binary code can be subject to
reverse-engineering. There are even tools to do this quite easily for
Java. The right way to protect your property is via copyright and licence.

2/ Size of "packed" programs :
Realize that the pack must include the whole Python interpreter and
librairies. BTW, I personnaly never used such tools, but I think I
remember that some of them allow you to specify which parts you really need.

3/ 'Slowness' :
I don't believe that 'packing' the program makes it slower.

Are you sure your Python code is really Pythonic ? There are tips and
tricks in how to 'optimize' Python code, and it can be very different
from low-level (C/C++ etc) languages techniques. You may want to have a
look at :
http://manatee.mojam.com/~skip/python/fastpython.html

Now if you really need smallest possible footprint and blazing-fast
execution speed (which are antagonist needs anyway), and your program is
about low-level stuff, you may not have choosen the right tool !-)

Bruno

Jul 18 '05 #2
Catalin wrote:
How can I make executables with python?
I found some utilities that claim they can do something like that like
Installer and py2exe but they actualy pack the code in a huge arhive!
This solves the problem of giving python programs to users who don't
have python but doesn't solve the problem of the source "secrecy"
(copyright).
And the programs also run much slower and become extremely big compared
to a normal C++ program for example. I made a test and a 2 programs
doing the same thing where 400 KB with C Builder (static linked) and
2.80 MB with python+installe r in an arhive packed with upx and 6.9 MB
with py2exe(unpacked ). And the speed difference was huge.
So can a python program become a "real" executable(I am refering both to
windows and unix platforms)?
If this is imposible with python is it possible with jpython?

Bruno wrote: Here you expose 3 different problems :

1/ source "secrecy" (copyright) :
It's the wrong problem. *Any* binary code can be subject to
reverse-engineering. There are even tools to do this quite easily for
Java. The right way to protect your property is via copyright and licence.
IMHO, Catalin has a good point here. I'm no legal expert, but I believe that
copyrights and licences are not quite enough to protect your code. They just
mean that if someone uses your code without your authorisation, you *could*
theoretically sue them, but :
1- Would it be worth it to go and hire a lawyer and everything?
2- How would you prove it (or even know about it) if they just stole pieces
of your code? Or even algorithms?
3- Moreover, you may never know who hacked your code. Look at all the games
and excellent software cracked everyday: do you know who dunnit? Who would
you sue?

So why not simply compile your code and make it *harder* (although not
impossible) to decypher: it'll stop most of the potential hackers. It's
like the lock on your door: however weak it is, it'll stop most burglars
because they won't bother fighting it at all: they'll just go and look for
an unlocked house! Well... unless everyone knows there's a treasure inside
it, that is. In which case there's not much you can do against determined
hackers except to make the task difficult for them.

I agree with Bruno about Java decompilers, though : I used them many times
and I am still amazed at the quality of the decompilation process. In one
instance it even helped me recover my own code when all I had left was the
compiled result! The recovered code was neatly indented and perhaps clearer
than the original code! But there are also free "obfuscator s" that make your
compiled bytecode (a lot) harder to decompile.

Python bytecode has some pretty good decompilers too.

But I don't know about any decent C decompiler. If anyone does, though, I'd
be greatly interested.

2/ Size of "packed" programs :
Realize that the pack must include the whole Python interpreter and
librairies. BTW, I personnaly never used such tools, but I think I
remember that some of them allow you to specify which parts you really need.

Yes, some do.
3/ 'Slowness' :
I don't believe that 'packing' the program makes it slower.

Are you sure your Python code is really Pythonic ? There are tips and
tricks in how to 'optimize' Python code, and it can be very different
from low-level (C/C++ etc) languages techniques. You may want to have a
look at :
http://manatee.mojam.com/~skip/python/fastpython.html

Now if you really need smallest possible footprint and blazing-fast
execution speed (which are antagonist needs anyway), and your program is
about low-level stuff, you may not have choosen the right tool !-)
Bruno


I don't see small footprint and fast execution speed as antagonist at all,
quite the contrary. In fact, assembly code produces the fastest and
smallest programs.

But Bruno is right, IMHO, about choosing the right tool: if you need a 50k
program calculating Pi to the 5000th decimal in 0.1 seconds... python is
definitely *not* the way to go.

Aurélien
Jul 18 '05 #3
On Thu, 26 Jun 2003 18:26:58 -0700, ac*****@easystr eet.com wrote:
This is a funny thing. IBM has done some studies
Cite, please.
that showed that users do prefer faster programs, but only 25% faster.
If a program runs more than 25% faster than what they are used to,
users don't like it.


I suspect the data would show they were studying a particular class of
program, and a particular class of user; the answer would only be
relevant to that scope.

We surely couldn't conclude that, if a web server became 60% faster in
completing its tasks, or if an interactive video game's refresh speed or
startup time became 60% faster, that "users [wouldn't] like it".

So, it's necessary to see the study to know what kind of software, and
what kind of users, were being studied; only then can we make
intelligent generalisations .

--
\ "I went to a fancy french restaurant called 'Deja Vu.' The |
`\ headwaiter said, 'Don't I know you?'" -- Steven Wright |
_o__) |
http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B
Jul 18 '05 #4
Aurélien Géron wrote:
Catalin wrote:
How can I make executables with python?
I found some utilities that claim they can do something like that like
Installer and py2exe but they actualy pack the code in a huge arhive!
This solves the problem of giving python programs to users who don't
have python but doesn't solve the problem of the source "secrecy"
(copyright ).


(snip)

Bruno wrote: (snip)
1/ source "secrecy" (copyright) :
It's the wrong problem. *Any* binary code can be subject to
reverse-engineering. There are even tools to do this quite easily for
Java. The right way to protect your property is via copyright and licence.

IMHO, Catalin has a good point here. I'm no legal expert, but I believe that
copyrights and licences are not quite enough to protect your code. They just
mean that if someone uses your code without your authorisation, you *could*
theoretically sue them, but :
1- Would it be worth it to go and hire a lawyer and everything?
2- How would you prove it (or even know about it) if they just stole pieces
of your code? Or even algorithms?
3- Moreover, you may never know who hacked your code. Look at all the games
and excellent software cracked everyday: do you know who dunnit? Who would
you sue?


This point out that binarie compilation does not enforce licence and
copyright...

<troll>A simple solution is to make the code open-source !-)</troll>
So why not simply compile your code and make it *harder* (although not
impossible) to decypher:
Compiling also means loosing quite a great part of interpreted languages
power.
it'll stop most of the potential hackers. It's
like the lock on your door: however weak it is, it'll stop most burglars
because they won't bother fighting it at all: they'll just go and look for
an unlocked house! Well... unless everyone knows there's a treasure inside
it, that is. In which case there's not much you can do against determined
hackers except to make the task difficult for them.
You can choose to only deliver bytecode (.pyc) files. But you have to be
sure the user has the right interpreter version... And like Java, there
is a simple way to decompyle...
I agree with Bruno about Java decompilers, though : I used them many times
and I am still amazed at the quality of the decompilation process. In one
instance it even helped me recover my own code when all I had left was the
compiled result! The recovered code was neatly indented and perhaps clearer
than the original code! But there are also free "obfuscator s" that make your
compiled bytecode (a lot) harder to decompile.
Doesn't this affect bytecode quality ?
Python bytecode has some pretty good decompilers too.

But I don't know about any decent C decompiler. If anyone does, though, I'd
be greatly interested.
I guess there is none. All you can do is hack the binary code. But some
people are pretty good at this.

(snip)
3/ 'Slowness' :
I don't believe that 'packing' the program makes it slower.

Are you sure your Python code is really Pythonic ? There are tips and
tricks in how to 'optimize' Python code, and it can be very different
from low-level (C/C++ etc) languages techniques. You may want to have a
look at :
http://manatee.mojam.com/~skip/python/fastpython.html

Now if you really need smallest possible footprint and blazing-fast
execution speed (which are antagonist needs anyway), and your program is
about low-level stuff, you may not have choosen the right tool !-)


I don't see small footprint and fast execution speed as antagonist at all,
quite the contrary.


This seems to be a quite common observation that programs can be
optimized for speed or for size, but not both (the program being
correctly written, of course...).
In fact, assembly code produces the fastest and
smallest programs.


I was talking about the same program written with the same language...

BTW, I'm not sure a human programmer can beat a good compiler, unless
the code is to be 'optimized' for one specific processor, which I don't
call optimization !-)

Bruno
Jul 18 '05 #5
Catalin <ad****@ploiest i.astral.ro> wrote in
news:ma******** *************** ***********@pyt hon.org:
And the programs also run much slower and become extremely big compared
to a normal C++ program for example.


What are you doing that the speed decrease matters?
What are you doing that is so secret?

If it really is too slow (i.e. 100 times slower than C++ is one thing, but
if it still only takes 0.1s is that really a problem?), consider writing
the slow part in C or C++ as a compiled extension. That could get you the
speed and mildly-increased-code-security you desire for the delicate parts
of your program, plus the advantages of Python for all the rest.

sfb.
Jul 18 '05 #6
On 27 Jun 2003 09:24:22 +0950, Ben Finney
<bi************ ****@and-zip-does-too.com.au> wrote:
This solves the problem of giving python programs to users who don't
have python but doesn't solve the problem of the source "secrecy"
(copyright).


Wrong problem. If you want to hide your source code from your users,
don't expect help from free software programmers.


I thought about this for a few days before responding (and Im sure I
did a few other things too ;) ), but I wanted to comment on this.

I think everyone that uses Python wants it to gain acceptance for the
great language that it is. I believe that stating an attitude in this
way is pretty counter productive in gaining any kind of wide-spread
acceptance.

Most of the replies to this request didn't mention the concept of NOT
protecting the software, but 2 did to different degrees. As someone
who uses and like open source software, and is slowly starting to
release some things as open source, and ALSO someone who sells
software and will continue in the future to sell software, I can say
that nothing turns me off more to a community than being told what my
goals should be.

I can understand wanting everything to be open, but thats not reality
and it never will be. Some people will always want things
proprietary, and they will only work within systems that allow that.
I think to be truly successful, systems will have to allow for this
and make it easy to do.

Currently Python does not make this REALLY easy to do, and in the
privacy portion, I believe its not even possible. This was a big
concern for me when I released my last for-sale software, but I just
decided I didn't care that much, and I love working in Python.

Some people will care enough, and will avoid Python because the
ability to protect their end results aren't there.

So far, the only semi-workable way to do this would be something like:

- Build a C program that embeds Python.
- Encrypt all the Python script/bytecode files.
- On runtime, decrypt the files and then execute.

Optional:

- Change the bytecode values in the Python source, and include your
new Python with different bytecode values.

I tried this last thing just to see if it would work, and I got some
problems compiling initially, so just gave up, but I think in theory
it should work.

Ignoring the Optional portion, this semi-solution is not actually very
secure. It does however move the problem into having to decompile a C
program, and then get it to decrypt the Python files. Then the normal
Python bytecode -> source. It means any cracker will have to know
something about both C and Python to do it, so a bit more barrier to
entry. It also means that in the US, the (vile and despicable, but
present) DMCA laws will make it a much more severe crime because
"cryptograp hy reverse engineering" needed to be applied, and may at
least reduce corporations from doing this for fear of
lawsuits/criminal charges if they are exposed.

Anyway, this is a good bit of work and not a great solution, but is
there anything else? If Python is to have avenues of support in all
walks of the software industry, will something like this be required?

From what I understand, there are also very good Java decompilers, but
no one seems to complain about Java's lack of security. Perhaps it is
because it is seen as something that is really "compiled" while
Python's loose compilation seems more whimsicle.

I think Python faces a lot of different public relations problems, and
just thought I'd pipe up about one that I have looked at myself, and
that I think most people coming into the Python world are faced with
and have to decide whether to ignore or not.
-Geoff Howland
http://ludumdare.com/
Jul 18 '05 #7
On 27 Jun 2003 09:24:22 +0950, Ben Finney
<bi************ ****@and-zip-does-too.com.au> wrote:
This solves the problem of giving python programs to users who don't
have python but doesn't solve the problem of the source "secrecy"
(copyright).


Wrong problem. If you want to hide your source code from your users,
don't expect help from free software programmers.


I thought about this for a few days before responding (and Im sure I
did a few other things too ;) ), but I wanted to comment on this.

I think everyone that uses Python wants it to gain acceptance for the
great language that it is. I believe that stating an attitude in this
way is pretty counter productive in gaining any kind of wide-spread
acceptance.

Most of the replies to this request didn't mention the concept of NOT
protecting the software, but 2 did to different degrees. As someone
who uses and like open source software, and is slowly starting to
release some things as open source, and ALSO someone who sells
software and will continue in the future to sell software, I can say
that nothing turns me off more to a community than being told what my
goals should be.

I can understand wanting everything to be open, but thats not reality
and it never will be. Some people will always want things
proprietary, and they will only work within systems that allow that.
I think to be truly successful, systems will have to allow for this
and make it easy to do.

Currently Python does not make this REALLY easy to do, and in the
privacy portion, I believe its not even possible. This was a big
concern for me when I released my last for-sale software, but I just
decided I didn't care that much, and I love working in Python.

Some people will care enough, and will avoid Python because the
ability to protect their end results aren't there.

So far, the only semi-workable way to do this would be something like:

- Build a C program that embeds Python.
- Encrypt all the Python script/bytecode files.
- On runtime, decrypt the files and then execute.

Optional:

- Change the bytecode values in the Python source, and include your
new Python with different bytecode values.

I tried this last thing just to see if it would work, and I got some
problems compiling initially, so just gave up, but I think in theory
it should work.

Ignoring the Optional portion, this semi-solution is not actually very
secure. It does however move the problem into having to decompile a C
program, and then get it to decrypt the Python files. Then the normal
Python bytecode -> source. It means any cracker will have to know
something about both C and Python to do it, so a bit more barrier to
entry. It also means that in the US, the (vile and despicable, but
present) DMCA laws will make it a much more severe crime because
"cryptograp hy reverse engineering" needed to be applied, and may at
least reduce corporations from doing this for fear of
lawsuits/criminal charges if they are exposed.

Anyway, this is a good bit of work and not a great solution, but is
there anything else? If Python is to have avenues of support in all
walks of the software industry, will something like this be required?

From what I understand, there are also very good Java decompilers, but
no one seems to complain about Java's lack of security. Perhaps it is
because it is seen as something that is really "compiled" while
Python's loose compilation seems more whimsicle.

I think Python faces a lot of different public relations problems, and
just thought I'd pipe up about one that I have looked at myself, and
that I think most people coming into the Python world are faced with
and have to decide whether to ignore or not.
-Geoff Howland
http://ludumdare.com/
Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2149
by: Irmen de Jong | last post by:
QOTW: "Confronting the Martellibot is like flirting with an encyclopedia, I'd rather not do it myself, but I respect those who do, because it produces knowledge." -- Anton Vredegoor "Python and Java are not diametrically opposed religions that must fight to the death in jihad, despite the existence of loonies favoring exactly that. They solve different problems; sometimes in similar ways, sometimes not." ...
3
3147
by: John Draper | last post by:
I am having a lot of problems trying to get a Python CGI to run. I have included 3 parts... 1) A simple stripped down python module. 2) An output of what I get when I do: python index.py (which not suprisingly should generate HTML output, and it does) 3) And the "error_log" output from the "server error" I get when I run it by typing in: http://localhost/cgi-bin/index.py
1
1138
by: mailpitches | last post by:
Using OSX 10.4.5 This is more of a unix/tcsh question than a python question. Somehow I got to the point where I have two files 'a.py' and 'b.py' which have identical contents and permissions, but one refuses to execute: me% a.py tcsh: a.py: Command not found. me% b.py
66
5467
by: Srijit Kumar Bhadra | last post by:
Is there any specific reason for not using MinGW to build the official distribution of Python for Win32? A quick Google search did not reveal the answer to my question. If a link is available, please post it. Best Regards, Srijit
3
1792
by: Cameron Laird | last post by:
QOTW: "Check out BeautifulSoup -- you will never write HTMLParser-based screen scrapers again. :)" - Jonathan Ellis "You clearly need something instead of XML." - Paul McGuire http://groups.google.com/group/comp.lang.python/msg/09e943c8dbf1e8c5? Johann C. Rocholl donates a PNG manager in pure Python: http://groups.google.com/group/comp.lang.python/browse_thread/thread/97c035f8b3646fd/
31
2781
by: Mark Dufour | last post by:
Hi all, I have recently released version 0.0.20 and 0.0.21 of Shed Skin, an optimizing Python-to-C++ compiler. Shed Skin allows for translation of pure (unmodified), implicitly statically typed Python programs into optimized C++, and hence, highly optimized machine language. Besides many bug fixes and optimizations, these releases add the following changes: -support for 'bisect', 'collections.deque' and 'string.maketrans'
13
4002
by: c3950ig | last post by:
Hi, I am python newbie and the command prompt is having an issue with python. I installed python 2.4.4 onto my windows machine, opened a command prompt window, and typed python to start the interactive mode. Got the following error. D:\>python 'python' is not recognized as an internal or external command, operable program or batch file.
145
4258
by: Dave Parker | last post by:
I've read that one of the design goals of Python was to create an easy- to-use English-like language. That's also one of the design goals of Flaming Thunder at http://www.flamingthunder.com/ , which has proven easy enough for even elementary school students, even though it is designed for scientists, mathematicians and engineers.
1
1773
by: Tim Rowe | last post by:
I have Python 2.5 working just fine on my system. I've tried downloading and installing the MS Windows Python extensions, but can't get pythonw.exe (that's the windows executable, right?) to do anything. I double-click it, nothing happens. I run it from a command prompt, it just returns me to the command prompt. The only possible clue I have is that the installation process produced the error message:
0
8619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9112
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8817
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4336
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4571
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.