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..866bf23 --- /dev/null +++ b/hooks/pyiboot01_bootstrap.py.diff @@ -0,0 +1,33 @@ +--- 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,12 @@ + if sys.warnoptions: + import warnings + +-try: ++def _setup_ctypes(): + import ctypes + import os ++ import sys + 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)