From 8dd296f03c06137af95d277543266fe95322a5d5 Mon Sep 17 00:00:00 2001 From: Shahar Zini Date: Tue, 13 Aug 2019 18:48:11 +1000 Subject: [PATCH 1/3] Add scope around ctypes patching in pyiboot01_bootstrap.py --- appveyor.yml | 2 ++ hooks/pyiboot01_bootstrap.py.diff | 32 +++++++++++++++++++++++++++++++ pyexe.py | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 hooks/pyiboot01_bootstrap.py.diff diff --git a/appveyor.yml b/appveyor.yml index 84832b7..0cd3671 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -78,6 +78,8 @@ build_script: # Patch the PyInstaller building\utils.py to avoid storing project path # names. - "pushd %PYTHON%\\Lib\\site-packages\\PyInstaller\\building && python -m patch %PROJDIR%\\hooks\\utils.py.diff && popd" + # Patch the PyInstall loader\pyiboot01_bootstrap.py to keep ctypes' patches a scope other than global + - "pushd %PYTHON%\\Lib\\site-packages\\PyInstaller\\loader && python -m patch %PROJDIR%\\hooks\\pyiboot01_bootstrap.py.diff && popd" - del /S /Q %PYTHON%\*.pyc >NUL - del /S /Q %PYTHON%\*.pyo >NUL # Save the artifact immediately diff --git a/hooks/pyiboot01_bootstrap.py.diff b/hooks/pyiboot01_bootstrap.py.diff new file mode 100644 index 0000000..600c724 --- /dev/null +++ b/hooks/pyiboot01_bootstrap.py.diff @@ -0,0 +1,32 @@ +--- pyiboot01_bootstrap.py 2019-08-12 17:37:25.460219000 +1000 ++++ pyiboot01_bootstrap.py 2019-08-13 18:10:32.084968800 +1000 +@@ -123,11 +123,11 @@ + if sys.warnoptions: + import warnings + +-try: ++def _setup_ctypes(): + import ctypes + import os + from ctypes import LibraryLoader, DEFAULT_MODE +- ++ + def _frozen_name(name): + if name: + frozen_name = os.path.join(sys._MEIPASS, os.path.basename(name)) +@@ -186,6 +186,8 @@ + + ctypes.OleDLL = PyInstallerOleDLL + ctypes.oledll = LibraryLoader(PyInstallerOleDLL) ++try: ++ _setup_ctypes() + except ImportError: + pass + +@@ -213,4 +215,4 @@ + # use-case, see issue #653. + if os.path.isdir(d): + for fn in os.listdir(d): +- sys.path.append(os.path.join(d, fn)) ++ sys.path.append(os.path.join(d, fn)) +\ No newline at end of file diff --git a/pyexe.py b/pyexe.py index a9204f6..811a373 100644 --- a/pyexe.py +++ b/pyexe.py @@ -408,7 +408,7 @@ def skip(*args, **kwargs): # Generate the globals/locals environment globenv = {} for key in list(globals().keys()): - if key.startswith('_') and key != '_frozen_name': + if key.startswith('_') and not key in ['_frozen_name','_setup_ctypes']: globenv[key] = globals()[key] if RunFile: run_file(RunFile, RunFileArgv, SkipFirstLine, globenv) From e8e4ed3adffab989552cf5e5499baadcb0ef1cec Mon Sep 17 00:00:00 2001 From: Shahar Zini Date: Mon, 9 Sep 2019 18:01:01 +1000 Subject: [PATCH 2/3] Fix --- hooks/pyiboot01_bootstrap.py.diff | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/pyiboot01_bootstrap.py.diff b/hooks/pyiboot01_bootstrap.py.diff index 600c724..2f0d32a 100644 --- a/hooks/pyiboot01_bootstrap.py.diff +++ b/hooks/pyiboot01_bootstrap.py.diff @@ -1,6 +1,6 @@ --- pyiboot01_bootstrap.py 2019-08-12 17:37:25.460219000 +1000 +++ pyiboot01_bootstrap.py 2019-08-13 18:10:32.084968800 +1000 -@@ -123,11 +123,11 @@ +@@ -123,11 +123,12 @@ if sys.warnoptions: import warnings @@ -8,6 +8,7 @@ +def _setup_ctypes(): import ctypes import os ++ import sys from ctypes import LibraryLoader, DEFAULT_MODE - + From 1f8faa3b20357686410b032dbdf41552472f1202 Mon Sep 17 00:00:00 2001 From: Shahar Zini Date: Mon, 9 Sep 2019 18:11:21 +1000 Subject: [PATCH 3/3] Fix --- hooks/pyiboot01_bootstrap.py.diff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/pyiboot01_bootstrap.py.diff b/hooks/pyiboot01_bootstrap.py.diff index 2f0d32a..866bf23 100644 --- a/hooks/pyiboot01_bootstrap.py.diff +++ b/hooks/pyiboot01_bootstrap.py.diff @@ -8,7 +8,7 @@ +def _setup_ctypes(): import ctypes import os -+ import sys ++ import sys from ctypes import LibraryLoader, DEFAULT_MODE - +