Skip to content

Commit 4d0684e

Browse files
authored
Add [project] configuration to pyproject.toml (#1364)
* Add [project] configuration to pyproject.toml The only thing that is preventing us from deleting setup.py at this point is the fact that there are multiple packages in the source tree due to the ones under the plugins directory. Also: - Ruggedized a couple unit tests * Make sure pytest-mock is installed for testing * Fix gnureadline install on macOS
1 parent 378208c commit 4d0684e

File tree

6 files changed

+91
-15
lines changed

6 files changed

+91
-15
lines changed

plugins/ext_test/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def clean_all(context):
157157
def sdist(context):
158158
"""Create a source distribution"""
159159
with context.cd(TASK_ROOT_STR):
160-
context.run('python setup.py sdist')
160+
context.run('python -m build --sdist')
161161

162162

163163
namespace.add_task(sdist)
@@ -167,7 +167,7 @@ def sdist(context):
167167
def wheel(context):
168168
"""Build a wheel distribution"""
169169
with context.cd(TASK_ROOT_STR):
170-
context.run('python setup.py bdist_wheel')
170+
context.run('python -m build --wheel')
171171

172172

173173
namespace.add_task(wheel)

plugins/template/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def clean_all(context):
170170
@invoke.task(pre=[clean_all])
171171
def sdist(context):
172172
"""Create a source distribution"""
173-
context.run('python setup.py sdist')
173+
context.run('python -m build --sdist')
174174

175175

176176
namespace.add_task(sdist)
@@ -179,7 +179,7 @@ def sdist(context):
179179
@invoke.task(pre=[clean_all])
180180
def wheel(context):
181181
"""Build a wheel distribution"""
182-
context.run('python setup.py bdist_wheel')
182+
context.run('python -m build --wheel')
183183

184184

185185
namespace.add_task(wheel)

pyproject.toml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,86 @@
22
requires = ["build", "setuptools>=64", "setuptools-scm>=8"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "cmd2"
7+
dynamic = ["version"]
8+
description = "cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python"
9+
authors = [{ name = "cmd2 Contributors" }]
10+
readme = "README.md"
11+
requires-python = ">=3.8"
12+
keywords = [
13+
"CLI",
14+
"cmd",
15+
"command",
16+
"interactive",
17+
"prompt",
18+
"Python",
19+
]
20+
license = { file = "LICENSE" }
21+
classifiers = [
22+
"Development Status :: 5 - Production/Stable",
23+
"Environment :: Console",
24+
"Operating System :: OS Independent",
25+
"Intended Audience :: Developers",
26+
"Intended Audience :: System Administrators",
27+
"License :: OSI Approved :: MIT License",
28+
"Programming Language :: Python :: 3 :: Only",
29+
"Programming Language :: Python :: 3.8",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Programming Language :: Python :: 3.12",
34+
"Programming Language :: Python :: 3.13",
35+
"Topic :: Software Development :: Libraries :: Python Modules",
36+
]
37+
dependencies = [
38+
"gnureadline; platform_system == 'Darwin'",
39+
"pyperclip",
40+
"pyreadline3; platform_system == 'Windows'",
41+
"wcwidth",
42+
]
43+
44+
[project.optional-dependencies]
45+
build = [
46+
"build",
47+
"setuptools",
48+
"setuptools-scm",
49+
]
50+
dev = [
51+
"codecov",
52+
"doc8",
53+
"invoke",
54+
"mypy",
55+
"nox",
56+
"pytest",
57+
"pytest-cov",
58+
"pytest-mock",
59+
"sphinx",
60+
"sphinx-rtd-theme",
61+
"sphinx-autobuild",
62+
"ruff",
63+
"twine",
64+
]
65+
docs = [
66+
"setuptools",
67+
"setuptools_scm",
68+
"sphinx",
69+
"sphinx-rtd-theme",
70+
"sphinx-autobuild",
71+
]
72+
test = [
73+
"codecov",
74+
"coverage",
75+
"pytest",
76+
"pytest-cov",
77+
"pytest-mock",
78+
]
79+
validate = [
80+
"mypy",
81+
"ruff",
82+
"types-setuptools",
83+
]
84+
585
[tool.doc8]
686
ignore-path = [
787
"__pycache__",
@@ -232,3 +312,5 @@ docstring-code-format = false
232312
# This only has an effect when the `docstring-code-format` setting is
233313
# enabled.
234314
docstring-code-line-length = "dynamic"
315+
316+
[tool.setuptools_scm]

tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def validatetag(context):
309309
def sdist(context):
310310
"""Create a source distribution"""
311311
with context.cd(TASK_ROOT_STR):
312-
context.run('python setup.py sdist')
312+
context.run('python -m build --sdist')
313313

314314

315315
namespace.add_task(sdist)
@@ -319,7 +319,7 @@ def sdist(context):
319319
def wheel(context):
320320
"""Build a wheel distribution"""
321321
with context.cd(TASK_ROOT_STR):
322-
context.run('python setup.py bdist_wheel')
322+
context.run('python -m build --wheel')
323323

324324

325325
namespace.add_task(wheel)

tests/test_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,14 @@ def test_path_completion_no_text(cmd2_app):
484484

485485
def test_path_completion_no_path(cmd2_app):
486486
# Run path complete with search text that isn't preceded by a path. This should use CWD as the path.
487-
text = 's'
487+
text = 'p'
488488
line = 'shell ls {}'.format(text)
489489
endidx = len(line)
490490
begidx = endidx - len(text)
491491
completions_no_text = cmd2_app.path_complete(text, line, begidx, endidx)
492492

493493
# Run path complete with path set to the CWD
494-
text = os.getcwd() + os.path.sep + 's'
494+
text = os.getcwd() + os.path.sep + text
495495
line = 'shell ls {}'.format(text)
496496
endidx = len(line)
497497
begidx = endidx - len(text)

tests/test_utils.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,9 @@ def pr_none():
289289
def test_proc_reader_send_sigint(pr_none):
290290
assert pr_none._proc.poll() is None
291291
pr_none.send_sigint()
292-
293-
wait_start = time.monotonic()
294292
pr_none.wait()
295-
wait_finish = time.monotonic()
296-
297-
# Make sure the process exited before sleep of 5 seconds finished
298-
# 3 seconds accounts for some delay but is long enough for the process to exit
299-
assert wait_finish - wait_start < 3
300293

294+
# Mac sure a SIGINT killed the process
301295
ret_code = pr_none._proc.poll()
302296
if sys.platform.startswith('win'):
303297
assert ret_code is not None

0 commit comments

Comments
 (0)