473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do (not) I distribute my Python progz?

Let's suppose that I have written a Python program and, of course, want
to show it to the world ;-)

So, do I have to distrubute my source code? Or is there a way to hide
my code?

Dec 14 '05 #1
12 1776
"Tolga" <to*********@gmail.com> writes:
Let's suppose that I have written a Python program and, of course, want
to show it to the world ;-)

So, do I have to distrubute my source code? Or is there a way to hide
my code?


You're not really showing it to the world, if you hide the source.
Dec 14 '05 #2

Hmm... Can't find any word to say...

Dec 14 '05 #3
Hi,

You can make exe code. The process is much more elaborate than C/C++
compilation.

Get the full information at http://www.py2exe.org/. also read the
Programing FAQ at python.org

Dec 14 '05 #4
Tolga wrote:
Let's suppose that I have written a Python program and, of course, want
to show it to the world ;-)

So, do I have to distrubute my source code? Or is there a way to hide
my code?


Why? Is there a problem with your source code? Are you
ashamed of it? Or trying to hide secret back-doors? Or
do you think that your "Hello World" program is worth
millions of dollars? *wink*

For many purposes, you can just distribute the .pyc
compiled byte-code. That will discourage the casual
user from reading the source code, but of course a
serious programmer will be able to disassemble the .pyc
code very easily.

--
Steven.

Dec 14 '05 #5
Tolga wrote:
Let's suppose that I have written a Python program and, of course, want
to show it to the world ;-)

So, do I have to distrubute my source code? Or is there a way to hide
my code?


Suggested solutions to this in the past have including using Py2exe (or
something like it) to create single-file distributables (viewable with
a zip program, however), writing custom import hooks to decode
encrypted modules, and storing valuable data online. It might even be
possible to do some sort of RMI and store useful parts of your code
online, although this requires a network connection and a
latency-insensitive application, which are by no means universal.

You could also consider moving your sensitive code to a compiled C
module, perhaps using something like Pyrex to make it fairly easy.

Obviously you will want to decide whether it's worth the effort to do
all this, because most of the time it won't be.

--
Ben Sizer

Dec 14 '05 #6
Hi Steven,
For many purposes, you can just distribute the .pyc compiled byte-code.
That will discourage the casual user from reading the source code, but
of course a serious programmer will be able to disassemble the .pyc code
very easily.


very easily ?

I tried it with my own code a year or two ago, and had some problems
(sorry don't remember all steps, but I think there was a tool called
disassemble ?). As I don't use a repository at the moment, I would need
it sometimes to disassemble older versions of my exe'd code. Could you
please give some hints, how I can get on ?

Thanks in advance
Jürgen
Dec 14 '05 #7
On Wed, 14 Dec 2005 11:41:25 +0100, Juergen Kareta wrote:
Hi Steven,
For many purposes, you can just distribute the .pyc compiled byte-code.
That will discourage the casual user from reading the source code, but
of course a serious programmer will be able to disassemble the .pyc code
very easily.


very easily ?

I tried it with my own code a year or two ago, and had some problems
(sorry don't remember all steps, but I think there was a tool called
disassemble ?). As I don't use a repository at the moment, I would need
it sometimes to disassemble older versions of my exe'd code. Could you
please give some hints, how I can get on ?


What makes you think I'm a serious programmer? *wink*

Try this:
py> import dis # the Python disassembler
py>
py> def f(x):
.... print x
.... return x+1
....
py> dis.dis(f)
2 0 LOAD_FAST 0 (x)
3 PRINT_ITEM
4 PRINT_NEWLINE

3 5 LOAD_FAST 0 (x)
8 LOAD_CONST 1 (1)
11 BINARY_ADD
12 RETURN_VALUE
13 LOAD_CONST 0 (None)
16 RETURN_VALUE
Python's byte-code is not exactly as easy to understand as native Python,
but it is still understandable. And I wonder, is there a program which
will try to generate Python code from the output of the disassembler?
--
Steven

Dec 14 '05 #8

Hi Steven,

What makes you think I'm a serious programmer? *wink*
Ok, it's not a 'serious' investigation, but maybe it could be, that you
(sometimes) quote something usefull ;-)

Python's byte-code is not exactly as easy to understand as native Python,
but it is still understandable. And I wonder, is there a program which
will try to generate Python code from the output of the disassembler?


look at:
http://www.crazy-compilers.com/decompyle/

it's only a online service. But if it works, it would be nice to have
such a tool as standalone programm.

Thanks a lot.

regards,
Jürgen
Dec 14 '05 #9
Juergen Kareta wrote:
look at:
http://www.crazy-compilers.com/decompyle/

it's only a online service. But if it works, it would be nice to have
such a tool as standalone programm.


And the next search result for decompyle on Google is...

http://packages.debian.org/unstable/python/decompyle

Get the source package from there, or check out your favourite
distribution's package repository. Very useful for investigating and
revealing the embarrassing secrets of closed source software, I think.

Paul

Dec 14 '05 #10
Hi Paul,

I had looked to the same link and downloaded the package. Maybe I'll
give it a try at the christmas holidays - hope so ;-)

Thanks
Jürgen
Dec 14 '05 #11

Paul Boddie wrote:
Juergen Kareta wrote:
look at:
http://www.crazy-compilers.com/decompyle/

it's only a online service. But if it works, it would be nice to have
such a tool as standalone programm.


And the next search result for decompyle on Google is...

http://packages.debian.org/unstable/python/decompyle

Get the source package from there, or check out your favourite
distribution's package repository. Very useful for investigating and
revealing the embarrassing secrets of closed source software, I think.

Paul


http://users.cs.cf.ac.uk/J.P.Giddy/p...ecompiler.html
http://www.logilab.org/projects/pyreverse/
http://docs.python.org/lib/module-dis.html
http://docs.python.org/lib/bytecodes.html

Dec 14 '05 #12
gene tani schrieb:
http://users.cs.cf.ac.uk/J.P.Giddy/p...ecompiler.html

Thanks for the links.
Regards,
Jürgen
Dec 19 '05 #13

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

Similar topics

3
by: Matt Shomphe | last post by:
Are there any guidelines for packaging a pure python module? Specifically, say I have a set of 10 functions, all of varying behaviors (no unifying theme to bind them together into clear subsets),...
34
by: nobody | last post by:
This article is posted at the request of C.W. Yang who asked me to detail my opinion of Lisp, and for the benefit of people like him, who may find themselves intrigued by this language. The...
5
by: codecraig | last post by:
i want to distribute my python script as an executable. I have tried py2exe but it caused a problem in my script when I ran it. I know about Gordon McMillans Installer (which is no longer...
17
by: Lonnie Princehouse | last post by:
In short: Is there any way to run Python WITHOUT trying to create .pyc files (or ..pyo) or to have Python not attempt to import the .pyc files it finds? Reason: We have a site-specific...
9
by: vj | last post by:
When I run the setup.py script , it throws an error Traceback (most recent call last): File "C:\vijay\db2\utils\PyDB2-1.1.0-2.tar\PyDB2-1.1.0\setup.py", line 57, in -toplevel- libraries=, File...
13
by: Chris Lasher | last post by:
Should a Python module not intended to be executed have shebang/ hashbang (e.g., "#!/usr/bin/env python") or not? I'm used to having a shebang in every .py file but I recently heard someone argue...
2
by: Steven W. Orr | last post by:
We have an app and I'm trying to decide where the app should be installed. The question is whether it should be site-specific or not, as in /usr/lib/python2.3/site-packages or...
68
by: Santiago Romero | last post by:
( Surely if this question has been asked for a zillion of times... ) ( and sorry for my english! ) I'm impressed with python. I'm very happy with the language and I find Python+Pygame a very...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.