Closed justvanrossum closed 1 year ago
It seems that "top_level.txt" is not a required file, but is always added by setuptools. This is not the case with other packaging tools like Hatch (as used by Black).
Info found here: https://blog.schuetze.link/2018/07/21/a-dive-into-packaging-native-python-extensions.html
top_level.txt: Setuptools also add this file which contains only the name of your package. This is part of the (PEP-less) egg format, the predecessor of wheels, as described in The Internal Structure of Python Eggs. This file is not documented and not needed for wheels and therefore not added by other packagers such as poetry. (Interestingly enough, the wheel repository, which adds the bdist_whl command to setuptools, does not even contain the string top_level.txt.)
Maybe tangentially, running black==22.8.0
from a bundled app fails like this:
Traceback (most recent call last):
File "/Applications/DrawBot.app/Contents/Resources/DrawBot.py", line 66, in formatCode_
self.vanillaWindowController.formatCode()
File "/Applications/DrawBot.app/Contents/Resources/lib/python3.9/drawBot/ui/drawBotController.py", line 171, in formatCode
import black
File "src/black/__init__.py", line 32, in <module>
ModuleNotFoundError: No module named 'mypy_extensions'
Somehow black's dependencies aren't completely picked up by py2app.
Black uses mypyc and that makes it annoying hard to automatically bundle it up. Last time I worked on this just adding "black" to the packages option wasn't good enough, mypyc adds a helper extension outside of the package.
I'll see if I can update the recipe for this.
End of year vacation time for the win... Could you check if the head of the "v0.28-branch" branch fixes the issue for this?
Don't test the the master branch, that's fairly unstable at the moment and more importantly doesn't include the fix I pushed earlier.
Fantastic, works like a charm with black 22.12.0. Thank you so much!
Great, I'll push out a release later this week.
thanks Ronald!
a py2app with this fix was released yesterday.
FWIW, while I see the release on PyPI, it is not listed on the GH releases page: https://github.com/ronaldoussoren/py2app/releases
Running
python setup.py py2app
in the attached archived folder fails like this:This is happening since
black==22.10.0
Here is a minimal reproducer:
app_with_black.zip
~Now, this may of course be a bug in black: https://github.com/psf/black/pull/3233#issuecomment-1361191055, but thought it good to report here, too.~
Cc @typemytype