New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
py2app should byte-compile the script file #47
Comments
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). This is almost certainly related to the current working directory of your script: py2app by default changes the current working directory to the 'Resources' directory inside of the application bundle. The reason for this is that when you double-click the application icon (the usual way to start the application) the Finder will start your application with an arbitrary working directory (although IIRC this was the root directory from OSX 10.0 until now). You have to use an absolute path to read the configuration file. |
Original comment by RajeshVaidheeswarran (Bitbucket: RajeshVaidheeswarran, ). Thank you! You were right. It works with an absolute path. However, I see that py2app uses the pyc files inside a zip file and also copies the actual script to Resources. Is there any way to make it can actually embed the zip inside the binary? |
Original comment by RajeshVaidheeswarran (Bitbucket: RajeshVaidheeswarran, ). not sure how I accidentally changed the state.. reverting it to new |
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). The easiest workaround to include the script in the zipfile: add a wrapper script that just imports the real script. That said, I will add the script to the zipfile in a future release but haven't gotten around to that yet. |
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). BTW. The primary reason why the script is not in the zipfile is that py2app ensures that the script is loaded as the 'main' module. |
Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren). Changed the title to document why this issue is still open |
Original report by RajeshVaidheeswarran (Bitbucket: RajeshVaidheeswarran, ).
Hello,
I am looking at creating an app that parses a config file and does stuff..
When I run the app directly, it works well, but when I create a binary using py2app, the configparser doesn't parse anymore. The solution to this problem eludes me.
I have a very distilled down version of this problem with just a single script.
The python script - foo.py
The script:
The config file: foo.cfg
The file:
The execution from source:
Output:
The app was created as follows:
I tried not including the ConfigParser first, and then tried including it. Both produce the same result.
The execution from the binary app:
[]
<ConfigParser.ConfigParser instance at 0x102c5a3f8>
[]
As you can see above, the sections and file list are both empty
The setup.py file to create the app
Source:
The text was updated successfully, but these errors were encountered: