From e0ef4bc2f3d6738aec240d33d469094a3813228f Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Wed, 2 Sep 2020 09:35:55 -0700 Subject: [PATCH] skip pyreadline dependency on Windows with Python 3.9+ --- humanfriendly/prompts.py | 6 +++++- setup.py | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/humanfriendly/prompts.py b/humanfriendly/prompts.py index 4a9d023..07166b6 100644 --- a/humanfriendly/prompts.py +++ b/humanfriendly/prompts.py @@ -341,7 +341,11 @@ def prepare_friendly_prompts(): This function is called by the other functions in this module to enable user friendly prompts. """ - import readline # NOQA + try: + import readline # NOQA + except ImportError: + # might not be available on Windows if pyreadline isn't installed + pass def retry_limit(limit=MAX_ATTEMPTS): diff --git a/setup.py b/setup.py index 0b9436d..fe8aefc 100755 --- a/setup.py +++ b/setup.py @@ -49,7 +49,9 @@ def get_install_requires(): if sys.version_info.major == 2: install_requires.append('monotonic') if sys.platform == 'win32': - install_requires.append('pyreadline') + # pyreadline isn't compatible with Python 3.9+ + # https://github.com/pyreadline/pyreadline/issues/65 + install_requires.append('pyreadline ; python_version<"3.9"') return sorted(install_requires) @@ -63,7 +65,9 @@ def get_extras_require(): ]) extras_require[expression] = ['monotonic'] # Conditional `pyreadline' dependency. - expression = ':sys_platform == "win32"' + # pyreadline isn't compatible with Python 3.9+ + # https://github.com/pyreadline/pyreadline/issues/65 + expression = ':sys_platform == "win32" and python_version<"3.9"' extras_require[expression] = 'pyreadline' return extras_require