Py2app using a .pyc

Page 1 of 1

6 Replies - 778 Views - Last Post: 24 May 2013 - 09:09 PM Rate Topic: -----

#1 npanagakis  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 01-December 12

Py2app using a .pyc

Posted 19 May 2013 - 12:22 AM

I wrote a basic game with pygame, and python 2.7. I decided to use py2app to compile it, and I would like to hide my source. I named my source file shootkill.py, then I compiled it to shootkill.pyc, but py2app only works when I compile the source file (.py) and dosen't work when I compile the bytecode one (.pyc). In the terminal I typed: python setup.py py2app

My setup.py:
"""
Script for building the example.

Usage:
    python setup.py py2app
"""
from setuptools import setup

NAME = 'ZOMBIE-D'
VERSION = '0.9'
setup(
    data_files=['data'],
     app=["shootkill.pyc"],
    setup_requires=["py2app"],
)


When I try to use shootkill.pyc I get an error saying:
    co = compile(contents, pathname, 'exec', 0, True)
TypeError: compile() expected string without null bytes


However, the game works when you run the .pyc with Python Launcher. Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: Py2app using a .pyc

#2 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Py2app using a .pyc

Posted 20 May 2013 - 09:02 PM

Have you considered obfuscation?
Was This Post Helpful? 1
  • +
  • -

#3 npanagakis  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 01-December 12

Re: Py2app using a .pyc

Posted 20 May 2013 - 09:50 PM

I guess that will have to do for now. Perhaps I could report the issue to PSF to fix sometime.
Was This Post Helpful? 0
  • +
  • -

#4 Mekire  Icon User is offline

  • D.I.C Head

Reputation: 116
  • View blog
  • Posts: 212
  • Joined: 11-January 13

Re: Py2app using a .pyc

Posted 20 May 2013 - 10:03 PM

If it is indeed a basic game, why bother? Even pyc can be decompiled by anyone determined enough. Unless you are doing something ground-breaking your gameplay will probably be easily approximated even without your code. I just don't see the point, and honestly nothing annoys me more than people that feel the need to hide their code for trivial projects, because they have commercial aspirations.

Anyway, just ignore me,
-Mek
Was This Post Helpful? 0
  • +
  • -

#5 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Py2app using a .pyc

Posted 23 May 2013 - 09:16 PM

View PostMekire, on 21 May 2013 - 01:03 AM, said:

If it is indeed a basic game, why bother? Even pyc can be decompiled by anyone determined enough. Unless you are doing something ground-breaking your gameplay will probably be easily approximated even without your code. I just don't see the point, and honestly nothing annoys me more than people that feel the need to hide their code for trivial projects, because they have commercial aspirations.

Anyway, just ignore me,
-Mek


We will :)

If the guy wants to hide his code, let him hide his code. Doesn't bother me and it really shouldn't bother you, who cares? As he grows as a programmer, it'll give him something to look back on and chuckle about.

This post has been edited by atraub: 24 May 2013 - 09:10 PM
Reason for edit:: bolding for emphasis

Was This Post Helpful? 0
  • +
  • -

#6 Mekire  Icon User is offline

  • D.I.C Head

Reputation: 116
  • View blog
  • Posts: 212
  • Joined: 11-January 13

Re: Py2app using a .pyc

Posted 24 May 2013 - 03:58 AM

Quote

As he grows as a programmer, it'll give him something to look back on and chuckle about.
That is just it though. Hiding one's code is completely counterproductive to the goal of improving as a programmer.

Take this for example: python py2app pygame errors, very confusing
Half of his code for this game is written and executed in the global namespace and is rampant with global variables; his images are reloaded every time he uses them; he has basic errors like always using ifs when elifs are indicated and overall redundant logic. But instead of fixing all of these things he is more worried about turning his program into an app and hiding his code. All of these problems will never be corrected with this attitude.

-Mek
Was This Post Helpful? -1
  • +
  • -

#7 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: Py2app using a .pyc

Posted 24 May 2013 - 09:09 PM

View PostMekire, on 24 May 2013 - 06:58 AM, said:

Quote

As he grows as a programmer, it'll give him something to look back on and chuckle about.
That is just it though. Hiding one's code is completely counterproductive to the goal of improving as a programmer.

Take this for example: python py2app pygame errors, very confusing
Half of his code for this game is written and executed in the global namespace and is rampant with global variables; his images are reloaded every time he uses them; he has basic errors like always using ifs when elifs are indicated and overall redundant logic. But instead of fixing all of these things he is more worried about turning his program into an app and hiding his code. All of these problems will never be corrected with this attitude.

-Mek

Finding another thread with code that you consider poorly written and then parading it out here does not make you look clever, only childish. For better or worse. this is a thread about hiding source code. This is not a soap box for you to throw out general criticisms against this guy. I can't help but notice that for someone so concerned about the OP's growth, you failed to even comment on the thread you linked. That leads me to believe that you're more interested in being right than actually helping him succeed.

As this thread seems to be on a downward spiral, I'm going to go ahead and close it now.

This post has been edited by atraub: 24 May 2013 - 09:11 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1