By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,172 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,172 IT Pros & Developers. It's quick & easy.

How do (not) I distribute my Python progz?

P: n/a
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
Share this Question
Share on Google+
12 Replies


P: n/a
"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

P: n/a

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

Dec 14 '05 #3

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.