Skip to content

Commit d5cebae

Browse files
authored
Merge pull request #1046 from KyleKing/patch-1
Update conditional pyreadline3 dependency for Win
2 parents 44eb9d4 + a96c0f5 commit d5cebae

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

Pipfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ipython = "*"
2222
isort = "*"
2323
mock = {version = "*",markers = "python_version < '3.6'"}
2424
plumbum = "*"
25-
pyreadline = {version = "*",sys_platform = "== 'win32'"}
25+
pyreadline = {version = "*",sys_platform = "== 'win32'",markers = "python_version < '3.8'"}
26+
pyreadline3 = {version = "*",sys_platform = "== 'win32'",markers = "python_version >= '3.8'"}
2627
pytest = "*"
2728
pytest-cov = "*"
2829
pytest-mock = "*"

cmd2/rl_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class RlType(Enum):
3737
# Explanation for why readline wasn't loaded
3838
_rl_warn_reason = ''
3939

40-
# The order of this check matters since importing pyreadline will also show readline in the modules list
41-
if 'pyreadline' in sys.modules:
40+
# The order of this check matters since importing pyreadline/pyreadline3 will also show readline in the modules list
41+
if 'pyreadline' in sys.modules or 'pyreadline3' in sys.modules:
4242
rl_type = RlType.PYREADLINE
4343

4444
from ctypes import byref

docs/overview/integrating.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ Windows Considerations
2626

2727
If you would like to use :ref:`features/completion:Completion`, and you want
2828
your application to run on Windows, you will need to ensure you install the
29-
``pyreadline`` package. Make sure to include the following in your
30-
``setup.py``::
29+
``pyreadline3`` or ``pyreadline`` package. Make sure to include the following
30+
in your ``setup.py``::
3131

3232
install_requires=[
3333
'cmd2>=1,<2',
34-
":sys_platform=='win32'": ['pyreadline'],
34+
":sys_platform=='win32'": [
35+
"pyreadline ; python_version<'3.8'",
36+
"pyreadline3 ; python_version>='3.8'", # pyreadline3 is a drop-in replacement for Python 3.8 and above
37+
],
3538
]

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
]
4545

4646
EXTRAS_REQUIRE = {
47-
# Windows also requires pyreadline to ensure tab completion works
48-
":sys_platform=='win32'": ['pyreadline'],
47+
# Windows also requires pyreadline or the replacement, pyreadline3, to ensure tab completion works
48+
":sys_platform=='win32' and python_version<'3.8'": ["pyreadline"],
49+
":sys_platform=='win32' and python_version>='3.8'": ["pyreadline3"],
4950
# Extra dependencies for running unit tests
5051
'test': [
5152
"gnureadline; sys_platform=='darwin'", # include gnureadline on macOS to ensure it is available in nox env

0 commit comments

Comments
 (0)