App built with non-system Python using py2app in pyenv not runnable on other machines
Asked Answered
A

1

3

My understanding was that as long as a non-Apple-default Python is employed to build, that the end-user need not install Python him/herself to execute a py2app-built app. In developing and testing the app in my own environment, I obviously have Python installed. Specifically, I built in a pyenv with with a python.org install, not Apple's own. Yet when I give the app to an end-user who doesn't have Python installed, she gets:

A Python runtime could not be located. You may need to install a framework build of Python, or edit the PyRuntimeLocations array in this application's Info.plist file.

The second line is concerning; if what it states is true, then a separate app instance would need to be built for every possible location of an end-user's install e.g /usr/bin, /Library/Frameworks etc.

UPDATE: Info.plist defines:

    <key>PythonExecutable</key>
<string>/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python</string

Yet the end-user in question only has a system install in /usr/bin.

Does this mean that every end-user needs to have an externally-installed Python, and it must live in /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

What if they don't have a non-Apple Python? What if they have a non-Apple Python but it's not 2.6? How can this somewhat hardcoded dependency be avoided?

Arboretum answered 17/1, 2016 at 23:33 Comment(1)
find MyAppliation.app -name Python.framework returns nothingArboretum
V
2

py2app automatically defaults to --semi-standalone mode if it thinks you are using the system interpreter. Your interpreter from Python.org shouldn't count as a "system" interpreter, but you could see what py2app thinks using this command:

$ python -c "import py2app.build_app; print py2app.build_app.is_system()"
False

One issue to watch out for: After I installed a Python.org interpreter today, bash didn't update it's hash cache, causing strange incompatibilities when I launched python. I had to type hash -r python to reset the cache and make sure the correct version of python was getting used. (Another way to fix this is to log out and log in again.) I suppose it's possible that the same issue could have caused py2app to be confused about whether or not you were using the system python.

If that doesn't do the trick, then try installing your python interpreter to a weird location, like ~/mypython or something like that, just to make sure there's no way it can be confused for a system python.

As a last resort, I suppose you could just hack the py2app source code so that is_system() always returns False. Not sure if that would have any adverse consequences, though.

PS -- Here's a little tutorial on using py2app with a conda-packaged application: https://github.com/stuarteberg/helloworld Not exactly relevant to your problem here, but you could compare it with your own setup and look for any conspicuous differences.

Vitek answered 18/1, 2016 at 19:14 Comment(1)
github.com/stuarteberg/helloworld is quite useful to make py2app work with condaIsoagglutination

© 2022 - 2024 — McMap. All rights reserved.