Skip to content

Commit

Permalink
Merge pull request #418 from mrclary/black-recipe
Browse files Browse the repository at this point in the history
Add recipe for black
  • Loading branch information
ronaldoussoren committed Apr 7, 2022
2 parents c8ba07c + b980ccd commit 509ca7c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions py2app/recipes/__init__.py
@@ -1,6 +1,7 @@
from . import PIL # noqa: F401
from . import automissing # noqa: F401
from . import autopackages # noqa: F401
from . import black # noqa: F401
from . import ctypes # noqa: F401
from . import detect_dunder_file # noqa: F401
from . import ftplib # noqa: F401
Expand Down
26 changes: 26 additions & 0 deletions py2app/recipes/black.py
@@ -0,0 +1,26 @@
import os
from pkg_resources import get_distribution


def check(cmd, mf):
m = mf.findNode("black")
if m is None or m.filename is None:
return None

egg = get_distribution('black').egg_info
top = os.path.join(egg, 'top_level.txt')

# These cannot be in zip
packages = ["black", "blib2to3"]

# black may include optimized platform specific C extension which has
# unusual name, e.g. 610faff656c4cfcbb4a3__mypyc; best to determine it from
# the egg-info/top_level.txt
with open(top, 'r') as f:
includes = set(f.read().strip().split('\n'))
includes = list(includes.difference(packages))

# Missed dependency
includes.append('pathspec')

return {"includes": includes, "packages": packages}

0 comments on commit 509ca7c

Please sign in to comment.