Can .py be complied?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • monkey

    Can .py be complied?

    Hi all, I am new to programming, already have a glace on introduction of
    c++, java and finally decided on python. But I found that the .py file is
    just like the source file, how can I make a program without revealing its
    source? (may be my question is a little bit stupid)


  • Harlin Seritt

    #2
    Re: Can .py be complied?

    Hi monkey,

    Not a stupid question especially if you're trying to create commercial
    software and don't want to reveal your source. At any rate, you can use
    py2exe to create a .exe file. It does have some cons to it since you
    are compiling an interpreted script but it works fine in this capacity.
    If you would like to obfuscate your code (disguise it) without an
    executable you can try pyobfuscate as well. Just Google for these two
    and you'll find easily.

    Harlin Seritt

    Comment

    • Maurice LING

      #3
      Re: Can .py be complied?

      monkey wrote:[color=blue]
      > Hi all, I am new to programming, already have a glace on introduction of
      > c++, java and finally decided on python. But I found that the .py file is
      > just like the source file, how can I make a program without revealing its
      > source? (may be my question is a little bit stupid)
      >
      >[/color]

      It is generally not very easy or straight-forward. The developers of
      CPython had generally intended that the source codes be the actual
      distribution, and is not likely to change. (see the thread on "bytecode
      non-backcompatibili ty")

      For now, you can use pyfreeze to snap the application, which is to
      bundle your application to a python interpreter (bootstrapping) as a
      package but this will not create a portable application. You can only
      run the application on the native system that it is frozen on. For
      example, if i freeze my application on Mac OSX, I won't be able to run
      that on MS Windows. Freezing bootstraps the system's python onto the
      application.

      If your application does not use any C modules, you can try to use
      Jython instead. Program in python but use jythonc to convert it into
      Java source files and package it into Java JAR files, then you will only
      need to release the JAR files without needing to release your codes.

      Cheers
      Maurice

      Comment

      • ryan@ryankaskel.com

        #4
        Re: Can .py be complied?

        I don't know the exact details, but try using the compiled Python
        scripts (bytecode). I believe they are semi-optimized and platform
        independent. They are the .pyc and .pyo files generated when the script
        is run.

        Comment

        • ryan@ryankaskel.com

          #5
          Re: Can .py be complied?


          ryan@ryankaskel .com wrote:[color=blue]
          > I don't know the exact details, but try using the compiled Python
          > scripts (bytecode). I believe they are semi-optimized and platform
          > independent. They are the .pyc and .pyo files generated when the[/color]
          script[color=blue]
          > is run.[/color]

          Okay, I found this documentation
          <http://fux0r.phathooku ps.com/programming-tutorials/Python/tut/node43.html>.
          It hides the source but you still need Python installed on the system
          running the bytecode.

          Comment

          • monkey

            #6
            Re: Can .py be complied?

            Thanks all of you guys, I found that python newsgroup is of wealthy
            knowledge:
            [color=blue]
            > If you would like to obfuscate your code (disguise it) without an
            > executable you can try pyobfuscate as well.
            >
            > Harlin Seritt
            >[/color]

            Yes, I want more options. Since the python doc mentioned py2exe only, and it
            is difficult to understand how it work.(may be you guys know C and make
            file, but I am still foolish here...)
            [color=blue]
            > It is generally not very easy or straight-forward.
            > For now, you can use pyfreeze to snap the application.... .
            > If your application does not use any C modules, you can try to use
            > Jython instead.
            >
            > Cheers
            > Maurice[/color]

            If using Jython to complie, is the end-user need JRE instead of Python
            installed, or need both of them?
            [color=blue]
            > I don't know the exact details, but try using the compiled Python
            > scripts (bytecode). I believe they are semi-optimized and platform
            > independent. They are the .pyc and .pyo files generated when the script
            > is run.
            >
            >ryan@ryankaske l[/color]

            Is that means a .py convert to .pyc or .pyo, without the need of "make file"
            as using py2exe?


            Comment

            • Filip Dreger

              #7
              Re: Can .py be complied?


              U¿ytkownik "monkey" <m@m.com> napisa³ w wiadomo¶ci
              news:426f562f$1 _3@rain.i-cable.com...
              [color=blue]
              > If using Jython to complie, is the end-user need JRE instead of
              > Python
              > installed, or need both of them?[/color]

              Only JRE. Just like Java.
              [color=blue][color=green]
              >> I don't know the exact details, but try using the compiled Python
              >> scripts (bytecode). I believe they are semi-optimized and platform
              >> independent. They are the .pyc and .pyo files generated when the
              >> script
              >> is run.[/color]
              > Is that means a .py convert to .pyc or .pyo, without the need of
              > "make file"
              > as using py2exe?[/color]

              ..pyc files are generated every time a module (any .py file can be a
              module) is imported. So if you have a program, say, example.py, you
              just start the python interpreter and write:[color=blue][color=green][color=darkred]
              >>> import example[/color][/color][/color]
              And then example.pyc will appear beside example.py. This new file does
              not require example.py (you can even delete it), and works on any
              computer with Python installed (on Windows you can just double-click
              it)
              If you start the Python interpreter using:
              python -OO (if you are using Windows, you shoud start the interpreter
              from the command line, probably something like:
              c:
              cd \
              python24\python -OO)
              and then import your example.py, you will get a file example.pyo,
              which is also stripped of any documentation strings (a bit harder to
              decode).

              regards,
              Filip Dreger


              Comment

              • Kent Johnson

                #8
                Re: Can .py be complied?

                monkey wrote:[color=blue][color=green]
                >>It is generally not very easy or straight-forward.
                >>For now, you can use pyfreeze to snap the application.... .
                >>If your application does not use any C modules, you can try to use
                >>Jython instead.
                >>
                >>Cheers
                >>Maurice[/color]
                >
                >
                > If using Jython to complie, is the end-user need JRE instead of Python
                > installed, or need both of them?[/color]

                The end-user needs the JRE, not Python.

                Kent

                Comment

                • Lucas Raab

                  #9
                  Re: Can .py be complied?

                  ryan@ryankaskel .com wrote:[color=blue]
                  > ryan@ryankaskel .com wrote:
                  >[color=green]
                  >>I don't know the exact details, but try using the compiled Python
                  >>scripts (bytecode). I believe they are semi-optimized and platform
                  >>independent . They are the .pyc and .pyo files generated when the[/color]
                  >
                  > script
                  >[color=green]
                  >>is run.[/color]
                  >
                  >
                  > Okay, I found this documentation
                  > <http://fux0r.phathooku ps.com/programming-tutorials/Python/tut/node43.html>.
                  > It hides the source but you still need Python installed on the system
                  > running the bytecode.
                  >[/color]

                  But those files can be decompyled.

                  --
                  --------------------------
                  Lucas Raab
                  lvraab"@"earthl ink.net
                  dotpyFE"@"gmail .com
                  AIM: Phoenix11890
                  MSN: dotpyfe"@"gmail .com
                  IRC: lvraab
                  ICQ: 324767918
                  Yahoo: Phoenix11890

                  Comment

                  • Maksim Kasimov

                    #10
                    Re: Can .py be complied?


                    "Maurice LING" <mauriceling@ac m.org> wrote:
                    news:d4mq31$gq3 $1@domitilla.ai oe.org...[color=blue]
                    > If your application does not use any C modules, you can try to use
                    > Jython instead. Program in python but use jythonc to convert it into
                    > Java source files and package it into Java JAR files, then you will only
                    > need to release the JAR files without needing to release your codes.[/color]

                    using Jython will not helps to hide your sources - jar-files are also easy
                    to decompile and to receive the source code (it will even looks like
                    original).
                    To avoid releasing your java-code (as far as it possible), the jar-files are
                    also necessary for processing by obfuscators


                    --
                    Best regards,
                    Maksim Kasimov
                    mailto: kasimov@i.com.u a


                    Comment

                    • monkey

                      #11
                      Re: Can .py be complied?

                      > And then example.pyc will appear beside example.py. This new file does[color=blue]
                      > not require example.py (you can even delete it), and works on any
                      > computer with Python installed[/color]

                      Filip, you can read through my mind (-: You just told me what I want to know
                      exactly, even I can't ask the question correctly. Thx..
                      [color=blue]
                      > python24\python -OO)
                      > and then import your example.py, you will get a file example.pyo,
                      > which is also stripped of any documentation strings (a bit harder to
                      > decode).[/color]

                      Is .pyo still not secure for serious purpose? The -OO function refer to
                      which area of python that I can read a doc in details?
                      [color=blue]
                      > The end-user needs the JRE, not Python.
                      >
                      > Kent[/color]

                      Actually I still not dare to touch Jython, because I am still digging python
                      now. But the JRE may not attract end-user, because it is still associate
                      with "slow" and "eating much system resource", although Java is sure a
                      respectfully programming language. What do you think?


                      Comment

                      • monkey

                        #12
                        Re: Can .py be complied?

                        >[color=blue]
                        > But those files can be decompyled.
                        >[/color]

                        Hi, so which way to go?


                        Comment

                        • Grant Edwards

                          #13
                          Re: Can .py be complied?

                          On 2005-04-27, monkey <m@m.com> wrote:
                          [color=blue]
                          > Yes, I want more options. Since the python doc mentioned
                          > py2exe only, and it is difficult to understand how it
                          > work.(may be you guys know C and make file, but I am still
                          > foolish here...)[/color]

                          py2exe has nothing to do with C or make files. You create a
                          setup.py file containing a couple lines of python. You run
                          that python program, and you end up with an .exe file and some
                          associated .dll files. I typically use inno-setup to create an
                          installer.exe that creates a desktop icon and start-menu entry,
                          but that's optional.
                          [color=blue]
                          > Is that means a .py convert to .pyc or .pyo, without the need
                          > of "make file" as using py2exe?[/color]

                          Huh? You don't need a make file for py2exe.

                          --
                          Grant Edwards grante Yow! I'd like TRAINED
                          at SEALS and a CONVERTIBLE on
                          visi.com my doorstep by NOON!!

                          Comment

                          • monkey

                            #14
                            Re: Can .py be complied?

                            > py2exe has nothing to do with C or make files. You create a[color=blue]
                            > setup.py file containing a couple lines of python. You run
                            > that python program, and you end up with an .exe file and some
                            > associated .dll files. I typically use inno-setup to create an
                            > installer.exe that creates a desktop icon and start-menu entry,
                            > but that's optional.[/color]

                            Is py2exe used to make a .exe file to install .py, or make the self-contain
                            ..exe file of the program itself?


                            Comment

                            • Grant Edwards

                              #15
                              Re: Can .py be complied?

                              On 2005-04-27, monkey <m@m.com> wrote:
                              [color=blue][color=green]
                              >> py2exe has nothing to do with C or make files. You create a
                              >> setup.py file containing a couple lines of python. You run
                              >> that python program, and you end up with an .exe file and some
                              >> associated .dll files. I typically use inno-setup to create
                              >> an installer.exe that creates a desktop icon and start-menu
                              >> entry, but that's optional.[/color]
                              >
                              > Is py2exe used to make a .exe file to install .py, or make the self-contain
                              > .exe file of the program itself?[/color]


                              The latter. It's not completely self contained, there is an
                              ...exe and some dll files that need to be distributed together.
                              It's explained very clearly by the py2exe web site:



                              Never used google before? Just go to www.google.com and type
                              in py2exe. Click "search". It's the first hit.

                              --
                              Grant Edwards grante Yow! Is something VIOLENT
                              at going to happen to a
                              visi.com GARBAGE CAN?

                              Comment

                              Working...