Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from BabbageCom/patches
Browse files Browse the repository at this point in the history
Update py2exe with upstream, add patch for
  • Loading branch information
feerrenrut authored Jul 2, 2019
2 parents 1b5d26a + 60a0449 commit c496ae6
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 13 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# py2exe-bin
NVDA's py2exe dependency

This repository fulfils NVDA's build dependency on py2exe 0.9.3.1 from https://github.com/albertosottile/py2exe.
It was created with the following command: `pip3 install -t ./ https://dl.bintray.com/alby128/py2exe/py2exe-0.9.3.1-cp37-none-win32.whl`
This repository fulfils NVDA's build dependency on py2exe from https://github.com/albertosottile/py2exe.
Currently, py2exe 0.9.3.2 (in development, commit b372a8e from https://github.com/albertosottile/py2exe/pull/13) is used.
It was created with the following command: `pip3 install -t ./ <path_to_local_git_clone_of_py2exe>`

Py2exe relies on pywin32, which is also included in this repository.
The pywin32 distribution was created using the following steps:
Expand Down
2 changes: 1 addition & 1 deletion py2exe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
"""py2exe package
"""
__version__ = '0.9.3.1'
__version__ = '0.9.3.2'

from .patch_distutils import patch_distutils

Expand Down
13 changes: 13 additions & 0 deletions py2exe/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,16 @@ def hook_scipy_optimize(finder, module):
finder.recursion_depth_optimize = depth + 1
finder.import_hook("scipy.optimize.minpack2")
finder.recursion_depth_optimize = depth

def hook__ssl(finder, module):
"""
On python 3.7 and above, _ssl.pyd requires additional dll's to load.
Based on code by Sebastian Krause: https://github.com/anthony-tuininga/cx_Freeze/pull/470
"""
if sys.version_info < (3, 7, 0):
return
import glob
for dll_search in ["libcrypto-*.dll", "libssl-*.dll"]:
for dll_path in glob.glob(os.path.join(sys.base_prefix, "DLLs", dll_search)):
dll_name = os.path.basename(dll_path)
finder.add_dll(dll_path)
24 changes: 20 additions & 4 deletions py2exe/mf3.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sys
import textwrap
import warnings
from importlib.machinery import DEBUG_BYTECODE_SUFFIXES, OPTIMIZED_BYTECODE_SUFFIXES

# XXX Clean up once str8's cstor matches bytes.
LOAD_CONST = dis.opname.index('LOAD_CONST')
Expand Down Expand Up @@ -670,21 +671,31 @@ def __init__(self, loader, name, optimize):
except AttributeError:
pass

@property
def __dest_file__(self):
"""Gets the destination path for the module that will be used at compilation time."""
if self.__optimize__:
bytecode_suffix = OPTIMIZED_BYTECODE_SUFFIXES[0]
else:
bytecode_suffix = DEBUG_BYTECODE_SUFFIXES[0]
if hasattr(self, "__path__"):
return self.__name__.replace(".", "\\") + "\\__init__" + bytecode_suffix
else:
return self.__name__.replace(".", "\\") + bytecode_suffix


@property
def __code__(self):
if self.__code_object__ is None:
if self.__optimize__ == sys.flags.optimize:
self.__code_object__ = self.__loader__.get_code(self.__name__)
else:
try:
try:
source = self.__source__
except Exception:
import traceback; traceback.print_exc()
raise RuntimeError("loading %r" % self) from None
if source is not None:
# XXX??? for py3exe:
__file__ = self.__file__ \
__file__ = self.__dest_file__ \
if hasattr(self, "__file__") else "<string>"
try:
self.__code_object__ = compile(source, __file__, "exec",
Expand All @@ -695,6 +706,11 @@ def __code__(self):
elif hasattr(self, "__file__") and not self.__file__.endswith(".pyd"):
# XXX Remove the following line if the Bug is never triggered!
raise RuntimeError("should read __file__ to get the source???")
except RuntimeError:
if self.__optimize__ != sys.flags.optimize:
raise
print("Falling back to loader to get code for module %s" % self.__name__)
self.__code_object__ = self.__loader__.get_code(self.__name__)
return self.__code_object__


Expand Down
Binary file modified py2exe/resources.dll
Binary file not shown.
Binary file modified py2exe/run-py3.7-win32.exe
Binary file not shown.
Binary file modified py2exe/run_ctypes_dll-py3.7-win32.dll
Binary file not shown.
Binary file modified py2exe/run_w-py3.7-win32.exe
Binary file not shown.
9 changes: 3 additions & 6 deletions py2exe/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,7 @@ def build_archive(self, libpath, delete_existing_resources=False):
# keys; we only need one of them in the archive.
for mod in set(self.mf.modules.values()):
if mod.__code__:
if hasattr(mod, "__path__"):
path = mod.__name__.replace(".", "\\") + "\\__init__" + bytecode_suffix
else:
path = mod.__name__.replace(".", "\\") + bytecode_suffix
path =mod.__dest_file__
stream = io.BytesIO()
stream.write(imp.get_magic())
if sys.version_info >= (3,7,0):
Expand Down Expand Up @@ -495,8 +492,8 @@ def copy_files(self, destdir):
if self.options.verbose:
print("Copy %s to %s" % (pydll, destdir))
shutil.copy2(pydll, dst)
with UpdateResources(dst, delete_existing=False) as resource:
resource.add_string(1000, "py2exe")
# with UpdateResources(dst, delete_existing=False) as resource:
# resource.add_string(1000, "py2exe")

if self.options.bundle_files == 3:
# copy extension modules; they go to libdir
Expand Down

0 comments on commit c496ae6

Please sign in to comment.