Skip to content

Commit 89b644d

Browse files
committed
Merge PR ceph#53710 into main
* refs/pull/53710/head: doc/cephfs-shell: drop installing packaging module cephfs-shell: use pkg_resources rather than packaging module Reviewed-by: Jos Collin <[email protected]>
2 parents 983db41 + 5be9213 commit 89b644d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

doc/man/8/cephfs-shell.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Options
5656

5757
.. code:: bash
5858
59-
[build]$ python3 -m venv venv && source venv/bin/activate && pip3 install cmd2 colorama packaging
59+
[build]$ python3 -m venv venv && source venv/bin/activate && pip3 install cmd2 colorama
6060
[build]$ source vstart_environment.sh && source venv/bin/activate && python3 ../src/tools/cephfs/shell/cephfs-shell
6161
6262
Commands

src/tools/cephfs/shell/cephfs-shell

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ import shlex
1616
import stat
1717
import errno
1818

19-
from packaging import version
19+
from pkg_resources import packaging # type: ignore
2020

2121
from cmd2 import Cmd
2222
from cmd2 import __version__ as cmd2_version
2323
# XXX: In cmd2 versions < 1.0.1, we'll get SystemExit(2) instead of
2424
# Cmd2ArgparseError
25-
if version.parse(cmd2_version) >= version.parse("1.0.1"):
25+
Version = packaging.version.Version
26+
if Version(cmd2_version) >= Version("1.0.1"):
2627
from cmd2.exceptions import Cmd2ArgparseError
2728
else:
2829
# HACK: so that we don't have check for version everywhere
@@ -1700,11 +1701,11 @@ def read_shell_conf(shell, shell_conf_file):
17001701

17011702
sec = 'cephfs-shell'
17021703
opts = []
1703-
if version.parse(cmd2_version) >= version.parse("0.10.0"):
1704+
if Version(cmd2_version) >= Version("0.10.0"):
17041705
for attr in shell.settables.keys():
17051706
opts.append(attr)
17061707
else:
1707-
if version.parse(cmd2_version) <= version.parse("0.9.13"):
1708+
if Version(cmd2_version) <= Version("0.9.13"):
17081709
# hardcoding options for 0.7.9 because -
17091710
# 1. we use cmd2 v0.7.9 with teuthology and
17101711
# 2. there's no way distinguish between a shell setting and shell
@@ -1713,7 +1714,7 @@ def read_shell_conf(shell, shell_conf_file):
17131714
'continuation_prompt', 'debug', 'echo', 'editor',
17141715
'feedback_to_output', 'locals_in_py', 'prompt', 'quiet',
17151716
'timing']
1716-
elif version.parse(cmd2_version) >= version.parse("0.9.23"):
1717+
elif Version(cmd2_version) >= Version("0.9.23"):
17171718
opts.append('allow_style')
17181719
# no equivalent option was defined by cmd2.
17191720
else:
@@ -1768,7 +1769,7 @@ def manage_args():
17681769
args.exe_and_quit = False # Execute and quit, don't launch the shell.
17691770

17701771
if args.batch:
1771-
if version.parse(cmd2_version) <= version.parse("0.9.13"):
1772+
if Version(cmd2_version) <= Version("0.9.13"):
17721773
args.commands = ['load ' + args.batch, ',quit']
17731774
else:
17741775
args.commands = ['run_script ' + args.batch, ',quit']
@@ -1813,7 +1814,7 @@ def execute_cmds_and_quit(args):
18131814
# value to indicate whether the execution of the commands should stop, but
18141815
# since 0.9.7 it returns the return value of do_* methods only if it's
18151816
# not None. When it is None it returns False instead of None.
1816-
if version.parse(cmd2_version) <= version.parse("0.9.6"):
1817+
if Version(cmd2_version) <= Version("0.9.6"):
18171818
stop_exec_val = None
18181819
else:
18191820
stop_exec_val = False

0 commit comments

Comments
 (0)