Skip to content

Commit

Permalink
Fix some incompatibilies with python 2.7
Browse files Browse the repository at this point in the history
Issue #406
  • Loading branch information
ronaldoussoren committed Apr 3, 2022
1 parent 032de04 commit 7cd6518
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
9 changes: 9 additions & 0 deletions doc/changelog.rst
Expand Up @@ -4,6 +4,15 @@ Release history
py2app 0.28
-----------

* #406: Fix incompatibility with python 2.7

py2app 0.24 accidently broke compatibility with Python 2.7, and
this release fixes this.

This is the last release with Python 2.7 support, the next
release will contain package metadata that ensures it can
only be installed on Python 3.

* #413: Find dist-info in included pythonXX.zip

By default the ``working_set`` of pkg_resources does not contain
Expand Down
19 changes: 7 additions & 12 deletions py2app/apptemplate/lib/site.py
Expand Up @@ -23,13 +23,7 @@
USER_SITE = None
USER_BASE = None


def _import_os():
global os
import os # noqa: E402


_import_os()
import os

try:
basestring
Expand Down Expand Up @@ -197,12 +191,13 @@ def getusersitepackages():
if hasattr(sys, "setdefaultencoding"):
del sys.setdefaultencoding

import builtins # noqa: E402
import _sitebuiltins # noqa: E402
if sys.version_info[0] == 3:
import builtins # noqa: E402
import _sitebuiltins # noqa: E402

builtins.help = _sitebuiltins._Helper()
builtins.quit = _sitebuiltins.Quitter('quit', 'Ctrl-D (i.e. EOF)')
builtins.exit = _sitebuiltins.Quitter('exit', 'Ctrl-D (i.e. EOF)')
builtins.help = _sitebuiltins._Helper()
builtins.quit = _sitebuiltins.Quitter('quit', 'Ctrl-D (i.e. EOF)')
builtins.exit = _sitebuiltins.Quitter('exit', 'Ctrl-D (i.e. EOF)')

# Prefixes for site-packages; add additional prefixes like /usr/local here
PREFIXES = [sys.prefix, sys.exec_prefix]
9 changes: 6 additions & 3 deletions py2app/recipes/qt5.py
Expand Up @@ -53,12 +53,15 @@ def check(cmd, mf):
extra = {}

if sys.version[0] != 2:
return {
result = {
"packages": ["PyQt5"],
"expected_missing_imports": {"copy_reg", "cStringIO", "StringIO"},
**extra,
}
result.update(extra)
return result
else:
return {"packages": ["PyQt5"], **extra}
result = {"packages": ["PyQt5"]}
result.update(extra)
return result

return None
4 changes: 3 additions & 1 deletion py2app/recipes/qt6.py
Expand Up @@ -51,6 +51,8 @@ def check(cmd, mf):
except ImportError:
mf.import_hook("sip", m, level=1)

return {"packages": ["PyQt6"], **extra}
reslt = {"packages": ["PyQt6"] }
result.update(extra)
return result

return None

0 comments on commit 7cd6518

Please sign in to comment.