ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
558 stars 46 forks source link

Unable to replicate working pyobjc environment without cloning #379

Closed hx2A closed 3 years ago

hx2A commented 3 years ago

I am the maintainer of the python project py5 and recently found py5objc, which is a great project that is solving a lot of my OSX problems. I'm using AppHelper.runEventLoop() on my computer with great success.

The problem is I can't replicate the working environment in a way that will get this working on other computers.

I can clone the working Anaconda environment with

conda create --name py5clone --clone py5

The cloned environment will work correctly.

I can export the environment and create a new one from the yml file:

conda env export > /tmp/py5_env.yml
conda env create -n py5clone2 -f /tmp/py5_env.yml

But this environment does not work. I get this error:

% run_sketch test_code.py                   
2021-08-18 13:46:21.458 python3.8[31334:275093] No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting

There has to be some necessary file in the Anaconda environment file that gets cloned that is not included in what gets exported.

I can look for differences in plist files:

% diff -rq py5clone py5clone2 | grep plist 
diff: py5clone/DISCLAIMER: No such file or directory
diff: py5clone2/DISCLAIMER: No such file or directory
Files py5clone/lib/python3.8/__pycache__/plistlib.cpython-38.pyc and py5clone2/lib/python3.8/__pycache__/plistlib.cpython-38.pyc differ
Files py5clone/org.freedesktop.dbus-session.plist and py5clone2/org.freedesktop.dbus-session.plist differ

But that last one is not a relevant difference:

% diff py5clone/org.freedesktop.dbus-session.plist py5clone2/org.freedesktop.dbus-session.plist
19c19
<       <string>/Users/jim/INSTALL/anaconda3/envs/py5clone/bin/dbus-daemon</string>
---
>       <string>/Users/jim/INSTALL/anaconda3/envs/py5clone2/bin/dbus-daemon</string>

I've been searching for differences between the working and not working environments that are not also different between the two working environments. I'm not finding anything that helps me figure out this problem.

if it helps, my setup.py file is here:

https://github.com/hx2A/py5generator/blob/run_sketch_osx/py5_resources/py5_module/setup.py

Any thoughts or advice would be super appreciated!

hx2A commented 3 years ago

I did some more experimenting and I see the hello world example works the same in all 3 environments:

https://pyobjc.readthedocs.io/en/latest/examples/core/Scripts/HelloWorld/index.html

hx2A commented 3 years ago

So, I read more of the example code and did more experimenting with my project and it seems I now have consistently working code that is not limited to one Python environment. Not sure how I arrive here. I spent much of the day flailing about. But in the end I made some small changes to my code, and now it works as it should.

I'm still curious about what was causing that environment issue, but if you don't have any ideas, don't spend time thinking about it.

I'm going to close this as I don't seem to have a problem to solve anymore. Thanks for your work on this project. I am glad I found it.

ronaldoussoren commented 3 years ago

I don't use conda myself, so don't know what might cause this issue. I do know that the binary wheels I provide on PyPI work on multiple systems, which makes it likely that the issue was either in conda or in something you did.

hx2A commented 3 years ago

My initial attempts as using pyobjc were a bit erratic, and perhaps I did something that put the environment into a weird state that worked but was not reproducible. In any case, reading through your example code was the right path forward as it helped me get a better understanding of what I needed to do. Thanks!