Skip to content

Commit

Permalink
Fix incompatibility with recent versions of setuptools
Browse files Browse the repository at this point in the history
Fixes #412
  • Loading branch information
ronaldoussoren committed Apr 3, 2022
1 parent 421f865 commit 458b8fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
5 changes: 5 additions & 0 deletions doc/changelog.rst
Expand Up @@ -7,6 +7,11 @@ py2app 0.28
* Fix hard crash in "rtree" recipe when the package contents doesn't
match the recipe expectations.

* #412: Fix incompatibility with setuptools 60.8.1

The setuptools recipe did not recoginize all vendored dependencies
in ``pkg_resources`` and that breaks app bundles that use ``pkg_resoures``.

* PR #388: Add builtin definitions for 'quit' and 'exit' in site.py

PR by mcclary
Expand Down
34 changes: 20 additions & 14 deletions py2app/recipes/setuptools.py
Expand Up @@ -17,23 +17,29 @@ def check(cmd, mf):
}

if os.path.exists(vendor_dir):
for nm in os.listdir(vendor_dir):
if nm in ("__pycache__", "__init__.py"): continue
if nm.endswith(".py"):
mf.import_hook("pkg_resources._vendor." + (nm[:-3]), m, ["*"])
expected_missing_imports.add("pkg_resources.extern." + (nm[:3]))
elif os.path.isdir(os.path.join(vendor_dir)):
mf.import_hook("pkg_resources._vendor." + nm, m, ["*"])
expected_missing_imports.add("pkg_resources.extern." + nm)
for topdir, dirs, files in os.walk(vendor_dir):
for fn in files:
if fn in ("__pycache__", "__init__.py"): continue

relnm = os.path.relpath(os.path.join(topdir, fn), vendor_dir)
if relnm.endswith(".py"):
relnm = relnm[:-3]
relnm = relnm.replace("/", ".")

if fn.endswith(".py"):
mf.import_hook("pkg_resources._vendor." + relnm, m, ["*"])
expected_missing_imports.add("pkg_resources.extern." + relnm)
for dn in dirs:
if not os.path.exists(os.path.join(topdir, dn, "__init__.py")):
continue
relnm = os.path.relpath(os.path.join(topdir, dn), vendor_dir)
relnm = relnm.replace("/", ".")

mf.import_hook("pkg_resources._vendor." + relnm, m, ["*"])
expected_missing_imports.add("pkg_resources.extern." + relnm)

mf.import_hook("pkg_resources._vendor", m)

#for node in mf.nodes():
# if node.name and node.name.startswith("pkg_resources.extern"):
# suffix = node.name[len("pkg_resources.extern."):]
# mf.import_hook("pkg_resources._vendor." + suffix, node, ["*"])


if sys.version[0] != 2:
expected_missing_imports.add("__builtin__")

Expand Down

0 comments on commit 458b8fa

Please sign in to comment.