From b95c9536b9c4069e4ee6cb3d78671c525fd901e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Rowlands=20=28=EB=B3=80=EA=B8=B0=ED=98=B8=29?= Date: Tue, 15 Nov 2022 20:18:08 +0900 Subject: [PATCH] pyinstaller: fix CI on py<3.10 (#244) --- pydrive2/__pyinstaller/test_hook-googleapiclient.py | 13 +++++++++++-- setup.py | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pydrive2/__pyinstaller/test_hook-googleapiclient.py b/pydrive2/__pyinstaller/test_hook-googleapiclient.py index c215a177..811661b2 100644 --- a/pydrive2/__pyinstaller/test_hook-googleapiclient.py +++ b/pydrive2/__pyinstaller/test_hook-googleapiclient.py @@ -3,12 +3,21 @@ from PyInstaller import __main__ as pyi_main -_APP_SOURCE = """import importlib.resources +# NOTE: importlib.resources.contents is available in py3.7+, but due to how +# pyinstaller handles importlib, we need to use the importlib_resources +# backport if there are any resources methods that are not available in a given +# python version, which ends up being py<3.10 +_APP_SOURCE = """ +import sys +if sys.version_info >= (3, 10): + from importlib.resources import contents +else: + from importlib_resources import contents import pydrive2.files -cache_files = importlib.resources.contents( +cache_files = contents( "googleapiclient.discovery_cache.documents" ) assert len(cache_files) > 0 diff --git a/setup.py b/setup.py index 04150480..c178fcdb 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ "flake8-docstrings", "pytest-mock", "pyinstaller", + "importlib_resources; python_version < '3.10'", ] tests_requirements.append("black==22.10.0")