py2app icon indicating copy to clipboard operation
py2app copied to clipboard

py2app 0.26 error

Open hasii2011 opened this issue 4 years ago • 7 comments

On python 3.9.0 with mypy 0.910 installed I can successfully build my app gittodoist

However, when I upgrade to python 3.9.1 with all my dependencies the same including py2app and mypy I get the following error:

File "/Users/humberto.a.sanchez.ii/PycharmProjects/gittodoistclone/pyenv-venv-3.9.1/lib/python3.9/site-packages/py2app/util.py", line 497, in byte_compile raise RuntimeError("Don't know how to handle %r" % mod.filename) RuntimeError: Don't know how to handle '/Users/humberto.a.sanchez.ii/PycharmProjects/gittodoistclone/pyenv-venv-3.9.1/lib/python3.9/site-packages/mypy/__init__'

If I uninstall mypy on the 3.9.1 environment, I can successfully build again.

I use pyenv to switch python versions; And use venv to create virtual build environments for the above;

As a workaround, I uninstall mypy on 3.9.1

hasii2011 avatar Oct 09 '21 20:10 hasii2011

Hm. I encounter similar troubles. With mypy installed I cannot build my app with py2app. I have to uninstall it.

MAKOMO avatar Oct 10 '21 09:10 MAKOMO

I'm working on this, and expect that this has to do with having both python files and C extensions of the same base name. If that's the issue the workaround is to install the platform independent wheel for Mypy (although that will be slower).

ronaldoussoren avatar Oct 10 '21 11:10 ronaldoussoren

I need some more information to reproduce the issue...

  • Do you get the error when Mypy is just installed, or does your application actually use Mypy (and if so how)?
  • Can you share a way to reproduce the issue (and "just clone gittodoist clone and try to build it" is fine for that)?

I've tried to reproduce the issue with examples/simple and:

  • Having "Mypy" installed does not cause an issue
  • "Using" Mypy by importing it in the main script causes a different problem: py2app itself runs without problems, but I get an error when running the app:
Traceback (most recent call last):
  ...
  File ".../py2app/examples/simple/dist/hello.app/Contents/Resources/hello.py", line 3, in <module>
    import mypy
ModuleNotFoundError: No module named 'a64f60bb4641b67cb20c__mypyc'

This is likely due to an import in the C extensions included with Mypy. Running the app (with just the import statement) works just fine when I install the platform independent wheel. The issue I ran into above can be fixed with a recipe, but is not the issue you are reporting :-(

ronaldoussoren avatar Oct 10 '21 11:10 ronaldoussoren

Ronald,

the funny thing is that mypy is NOT used (imported) by the app. However, the apps code contains some Python3 static type annotations (which is the whole point of using mypy to check them).

I am not using a virtual environment. All packages are installed directly using sudo pip on my mac running Python 3.9.7.

With mypy installed I get

writing byte-compilation script '/tmp/tmpovsp5f9d.py'
/usr/bin/env PYTHONPATH=/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/py2app-0.26.1-py3.9.egg:/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9 /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -OO /tmp/tmpovsp5f9d.py
Traceback (most recent call last):
  File "/tmp/tmpovsp5f9d.py", line 1222, in <module>
    byte_compile(files, optimize=2, force=None,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/py2app-0.26.1-py3.9.egg/py2app/util.py", line 497, in byte_compile
    raise RuntimeError("Don't know how to handle %r" % mod.filename)
RuntimeError: Don't know how to handle '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mypy/__init__'
error: command '/usr/bin/env' failed with exit code 1

Sadly the project is large and one needs to install quite some packages (specified in requirements*.txt) and then run

# sudo ./build-mac3.sh

to start the build. The project is on GitHub: https://github.com/artisan-roaster-scope/artisan

If I can add some debug statements somewhere or help otherwise, let me know.

Marko

PS: Here is that file /tmp/tmpovsp5f9d.py

tmpovsp5f9d.py.txt

MAKOMO avatar Oct 10 '21 11:10 MAKOMO

When you say import from a platform independent wheel is that PyPi? To answer your questions

Yes, you can git clone the gittodoistclone project

pip3 install -r requirements.txt

then run

./scripts/packageme.sh deploy

That should show the problem

hasii2011 avatar Oct 11 '21 15:10 hasii2011

Ok, upgrade to 0.26.1 and problem goes away. Reverted back to 0.26 and problem does not exist anymore; Not sure what happened; But I am going to stay on 0.26.1

I am ok with closing this assuming @MAKOMO is ok also

hasii2011 avatar Oct 31 '21 19:10 hasii2011

Hm. I checked if the order of pip installs resolves this (pip install mypy before or after py2app). No change for me. However, my error message is slightly different from yours:

*** filtering dependencies ***
6221 total
47 filtered
183 orphaned
6174 remaining
*** create binaries ***
*** byte compile python files ***
writing byte-compilation script '/tmp/tmpwq8cwvba.py'
/usr/bin/env PYTHONPATH=/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages:/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9 /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -OO /tmp/tmpwq8cwvba.py
Traceback (most recent call last):
  File "/tmp/tmpwq8cwvba.py", line 1209, in <module>
    byte_compile(files, optimize=2, force=None,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/py2app/util.py", line 497, in byte_compile
    raise RuntimeError("Don't know how to handle %r" % mod.filename)
RuntimeError: Don't know how to handle '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mypy/__init__'
error: command '/usr/bin/env' failed with exit code 1

I wonder what mypy has to do with py2app at all. Very strange.

MAKOMO avatar Nov 01 '21 10:11 MAKOMO