@@ -11,10 +11,10 @@ We welcome pull requests from cmd2 users and seasoned Python developers alike! F
11
11
12
12
Remember to feel free to ask for help by leaving a comment within the Issue.
13
13
14
- Working on your first pull request? You can learn how from this * free * series
15
- [ How to Contribute to an Open Source Project on GitHub] ( https://egghead.io/series/how-to-contribute- to-an-open-source-project-on-github ) .
14
+ Working on your first pull request? You can learn how from the
15
+ [ GitHub Docs ] ( https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes- to-your-work-with-pull-requests/creating-a-pull-request ) .
16
16
17
- ###### If you've found a bug that is not on the board, [ follow these steps] ( README.md#found-a-bug ) .
17
+ ###### If you've found a bug that is not on the board, [ follow these steps] ( ../ README.md#found-a-bug) .
18
18
19
19
--------------------------------------------------------------------------------
20
20
@@ -42,37 +42,43 @@ Working on your first pull request? You can learn how from this *free* series
42
42
43
43
The tables below list all prerequisites along with the minimum required version for each.
44
44
45
- > _ Updating to the latest releases for all prerequisites via pip or conda is recommended_ .
45
+ > _ Updating to the latest releases for all prerequisites via ` uv ` is recommended_ .
46
46
47
47
#### Prerequisites to run cmd2 applications
48
48
49
- | Prerequisite | Minimum Version |
50
- | -----------------------------------------------------| -----------------|
51
- | [ python] ( https://www.python.org/downloads/ ) | ` 3.8 ` |
52
- | [ pyperclip] ( https://github.com/asweigart/pyperclip ) | ` 1.6 ` |
53
- | [ setuptools] ( https://pypi.org/project/setuptools/ ) | ` 34.4 ` |
54
- | [ wcwidth] ( https://pypi.python.org/pypi/wcwidth ) | ` 0.1.7 ` |
55
-
56
- #### Additional prerequisites to run cmd2 unit tests
57
-
58
49
| Prerequisite | Minimum Version |
59
50
| ------------------------------------------------------| -----------------|
60
- | [ pytest] ( http://doc.pytest.org/en/latest/ ) | ` 3.0.6 ` |
61
- | [ pytest-mock] ( https://pypi.org/project/pytest-mock/ ) | ` 1.3 ` |
62
-
63
- #### Additional prerequisites to build cmd2 documentation
51
+ | [ python] ( https://www.python.org/downloads/ ) | ` 3.8 ` |
52
+ | [ pyperclip] ( https://github.com/asweigart/pyperclip ) | ` 1.8.2 ` |
53
+ | [ wcwidth] ( https://pypi.python.org/pypi/wcwidth ) | ` 0.2.12 ` |
54
+
55
+ #### Additional prerequisites to build and publish cmd2
56
+
57
+ | Prerequisite | Minimum Version |
58
+ | ----------------------------------------------------------| -----------------|
59
+ | [ build] ( https://pypi.org/project/build/ ) | ` 1.2.2 ` |
60
+ | [ setuptools] ( https://pypi.org/project/setuptools/ ) | ` 72.1.0 ` |
61
+ | [ setuptools-scm] ( https://github.com/pypa/setuptools-scm ) | ` 8.0.4 ` |
62
+ | [ twine] ( https://github.com/pypa/twine ) | ` 5.1.1 ` |
63
+
64
+ #### Additional prerequisites for developing cmd2
65
+
66
+ | Prerequisite | Minimum Version | Purpose |
67
+ | ----------------------------------------------------------------------| -----------------| ----------------------------|
68
+ | [ codecov] ( http://doc.pytest.org/en/latest/ ) | ` 2.1.13 ` | Cover coverage reporting |
69
+ | [ doc8] ( https://github.com/PyCQA/doc8 ) | ` 1.1.2 ` | Sphinx style checker |
70
+ | [ invoke] ( https://www.pyinvoke.org/ ) | ` 2.2.0 ` | Command automation |
71
+ | [ mypy] ( https://mypy-lang.org/ ) | ` 1.13.0 ` | Static type checker |
72
+ | [ pytest] ( https://docs.pytest.org/en/stable/ ) | ` 3.0.6 ` | Unit and integration tests |
73
+ | [ pytest-cov] ( http://doc.pytest.org/en/latest/ ) | ` 6.0.0 ` | Pytest code coverage |
74
+ | [ pytest-mock] ( https://pypi.org/project/pytest-mock/ ) | ` 3.14.0 ` | Pytest mocker fixture |
75
+ | [ sphinx] ( https://www.sphinx-doc.org/en/master/ ) | ` 8.1.3 ` | Documentation |
76
+ | [ sphinx-autobuild] ( hhttps://pypi.org/project/sphinx-autobuild/ ) | ` 2024.10.3 ` | Rebuild docs on changes |
77
+ | [ sphinx-rtd-theme] ( https://github.com/readthedocs/sphinx_rtd_theme ) | ` 3.0.1 ` | Sphinx theme for RTD |
78
+ | [ ruff] ( https://github.com/astral-sh/ruff ) | ` 0.7.3 ` | Fast linter and formatter |
79
+ | [ uv] ( https://github.com/astral-sh/uv ) | ` 0.5.1 ` | Python package management |
64
80
65
- | Prerequisite | Minimum Version |
66
- | ---------------------------------------------------------------| -----------------|
67
- | [ sphinx] ( http://www.sphinx-doc.org ) | ` 2.0.0 ` |
68
- | [ sphinx-rtd-theme] ( https://github.com/snide/sphinx_rtd_theme ) | ` 0.1.9 ` |
69
81
70
- #### Optional prerequisites for enhanced unit test features
71
-
72
- | Prerequisite | Minimum Version |
73
- | -------------------------------------------------------| -----------------|
74
- | [ pytest-cov] ( https://pypi.python.org/pypi/pytest-cov ) | ` 2.4 ` |
75
- | [ ruff] ( https://github.com/astral-sh/ruff ) | ` 0.7.0 ` |
76
82
77
83
If Python is already installed in your machine, run the following commands to validate the versions:
78
84
@@ -83,10 +89,14 @@ $ pip freeze | grep pyperclip
83
89
84
90
If your versions are lower than the prerequisite versions, you should update.
85
91
86
- If you do not already have Python installed on your machine, we recommend using the
87
- [ Anaconda] ( https://www.continuum.io/downloads ) distribution because it provides an excellent out-of-the-box install on
88
- all platforms (Windows, Mac, and Linux) and because it supports having multiple Python environments (versions of Python)
89
- installed simultaneously.
92
+ If you do not already have Python installed on your machine, we recommend using [ uv] ( https://github.com/astral-sh/uv )
93
+ for all of your Python needs because it is extremely fast, meets all Python installation and packaging needs, and works
94
+ on all platforms (Windows, Mac, and Linux). You can install ` uv ` using instructions at the link above.
95
+
96
+ You can then install multiple versions of Python using ` uv ` like so:
97
+ ``` sh
98
+ uv python install 3.10 3.11 3.12 3.13
99
+ ```
90
100
91
101
### Forking the project
92
102
@@ -199,70 +209,48 @@ _[this](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git
199
209
For doing cmd2 development, it is recommended you create a virtual environment using Conda or Virtualenv and install the
200
210
package from the source.
201
211
202
- #### Create a new environment for cmd2 using Pipenv
212
+ #### Create a new environment for cmd2 using uv
203
213
204
- ` cmd2 ` has support for using [ Pipenv ] ( https://docs.pipenv.org/en/latest/ ) for development.
214
+ ` cmd2 ` has support for using [ uv ] ( https://github.com/astral-sh/uv ) for development.
205
215
206
- ` Pipenv ` essentially combines the features of ` pip ` and ` virtualenv ` into a single tool. ` cmd2 ` contains a Pipfile
207
- which
208
- makes it extremely easy to setup a ` cmd2 ` development environment using ` pipenv ` .
216
+ ` uv ` is single tool to replace ` pip ` , ` pip-tools ` , ` pipx ` , ` poetry ` , ` pyenv ` , ` twine ` , ` virtualenv ` , and more. ` cmd2 `
217
+ contains configuration for using ` uv ` in it's ` pyproject.toml ` file which makes it extremely easy to setup a ` cmd2 `
218
+ development environment using ` uv ` .
209
219
210
- To create a virtual environment and install everything needed for ` cmd2 ` development using ` pipenv ` , do the following
220
+ To create a virtual environment and install everything needed for ` cmd2 ` development using ` uv ` , do the following
211
221
from a GitHub checkout:
212
222
213
223
``` sh
214
- pipenv install --dev
224
+ uv venv
215
225
```
216
226
217
- To create a new virtualenv, using a specific version of Python you have installed (and on your PATH) , use the
227
+ To create a new virtualenv, using a specific version of Python you have installed, use the
218
228
--python VERSION flag, like so:
219
229
220
230
``` sh
221
- pipenv install --dev --python 3.8
222
- ```
223
-
224
- Then you can enter that virtual environment with:
225
-
226
- ``` sh
227
- pipenv shell
231
+ uv venv --python 3.12
228
232
```
229
233
230
- #### Create a new environment for cmd2 using Conda
234
+ Then you can run commands in this isolated virtual environment using ` uv ` like so:
231
235
232
236
``` sh
233
- $ conda create -n cmd2_py38 python=3.8
234
- $ conda activate cmd2_py38
237
+ uv run examples/basic.py
235
238
```
236
239
237
- #### Create a new environment for cmd using Virtualenv
238
-
239
- We recommend that you use [ pyenv] ( https://github.com/pyenv/pyenv ) to manage your installed python versions.
240
-
240
+ Alternatively you can activate the virtual environment using the OS-specific command such as this on Linux or macOS:
241
241
``` sh
242
- # Check pyenv versions installed
243
- pyenv versions
244
-
245
- # Install python version defined
246
- pyenv install 3.8.2
242
+ source .venv/bin/activate
247
243
```
248
244
249
- With the Python version installed, you can set the virtualenv properly.
250
-
251
- ``` sh
252
- $ cd ~ /src/cmd2
253
- $ virtualenv -p $( pyenv root) /versions/3.8.2/ cmd_py38
254
- $ source ~ /src/cmd2/bin/activate
255
- ```
256
-
257
- Assuming you cloned the repository to ` ~/src/cmd2 ` you can install cmd2 in
245
+ Assuming you cloned the repository to ` ~/src/cmd2 ` and setup a virtual environment using ` uv ` , ` cmd2 ` in this venv in
258
246
[ editable mode] ( https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs ) .
259
247
Changes to the source code are immediately available when the python interpreter
260
248
imports ` cmd2 ` , there is no need to re-install the module after every change. This
261
249
command will also install all of the runtime dependencies for ` cmd2 ` and modules used for development of ` cmd2 ` :
262
250
263
251
``` sh
264
252
$ cd ~ /src/cmd2
265
- $ pip install -e .[dev]
253
+ $ uv venv
266
254
```
267
255
268
256
This project uses many python modules for various development tasks, including
@@ -275,13 +263,13 @@ high-level interface for these development tasks. To see the full list of functi
275
263
available:
276
264
277
265
``` sh
278
- $ invoke -l
266
+ $ uv run inv -l
279
267
```
280
268
281
269
You can run multiple tasks in a single invocation, for example::
282
270
283
271
``` sh
284
- $ invoke docs sdist wheel
272
+ $ uv run inv docs sdist wheel
285
273
```
286
274
287
275
That one command will remove all superfluous cache, testing, and build
@@ -295,15 +283,15 @@ Now you can check if everything is installed and working:
295
283
296
284
``` sh
297
285
$ cd ~ src/cmd2
298
- $ invoke pytest
286
+ $ uv run inv pytest
299
287
```
300
288
301
289
If the tests are executed it means that dependencies and project are installed successfully.
302
290
303
291
You can also run the example app and see a prompt that says "(Cmd)" running the command:
304
292
305
293
``` sh
306
- $ python examples/example.py
294
+ $ uv run examples/example.py
307
295
```
308
296
309
297
You can type ` help ` to get help or ` quit ` to quit. If you see that, then congratulations
@@ -331,7 +319,7 @@ If you made changes to any file in the `/docs` directory, you need to build the
331
319
Sphinx documentation and make sure your changes look good:
332
320
333
321
``` sh
334
- $ invoke docs
322
+ $ uv inv docs
335
323
```
336
324
337
325
In order to see the changes, use your web browser of choice to open ` ~/cmd2/docs/_build/html/index.html ` .
@@ -340,13 +328,13 @@ If you would rather use a webserver to view the documentation, including
340
328
automatic page refreshes as you edit the files, use:
341
329
342
330
``` sh
343
- $ invoke livehtml
331
+ $ uv inv livehtml
344
332
```
345
333
346
334
You will be shown the IP address and port number where the documents are now
347
335
served (usually [ http://localhost:8000 ] ( http://localhost:8000 ) ).
348
336
349
- ### Static code analysis
337
+ ### Code Quality Checks
350
338
351
339
You should have some sort of [ PEP 8] ( https://www.python.org/dev/peps/pep-0008/ ) -based linting running in your editor or
352
340
IDE or at the command line before you commit code. ` cmd2 ` uses [ ruff] ( https://github.com/astral-sh/ruff ) as part of
@@ -356,13 +344,41 @@ its continuous integration (CI) process for both linting and auto-formatting.
356
344
> clean and simple code base. Don't worry about linting errors in code you don't touch though - cleaning up the legacy
357
345
> code is a work in progress.
358
346
347
+ #### Formatting
348
+
349
+ To check if formatting is correct:
350
+
351
+ ``` sh
352
+ uv run inv format
353
+ ```
354
+
355
+ To automatically fix formatting:
356
+
357
+ ``` sh
358
+ uv run ruff format
359
+ ```
360
+
361
+ #### Linting
362
+
363
+ To run the linter:
364
+
365
+ ``` shell
366
+ uv run inv lint
367
+ ```
368
+
369
+ #### Static Type Checking
370
+
371
+ ``` shell
372
+ uv run inv mypy
373
+ ```
374
+
359
375
### Running the test suite
360
376
361
377
When you're ready to share your code, run the test suite:
362
378
363
379
``` sh
364
380
$ cd ~ /cmd2
365
- $ invoke pytest
381
+ $ uv run pytest
366
382
```
367
383
368
384
and ensure all tests pass.
0 commit comments