@@ -11,10 +11,10 @@ We welcome pull requests from cmd2 users and seasoned Python developers alike! F
1111
1212Remember to feel free to ask for help by leaving a comment within the Issue.
1313
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 ) .
1616
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) .
1818
1919--------------------------------------------------------------------------------
2020
@@ -42,37 +42,43 @@ Working on your first pull request? You can learn how from this *free* series
4242
4343The tables below list all prerequisites along with the minimum required version for each.
4444
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_ .
4646
4747#### Prerequisites to run cmd2 applications
4848
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-
5849| Prerequisite | Minimum Version |
5950| ------------------------------------------------------| -----------------|
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 |
6480
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 ` |
6981
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 ` |
7682
7783If Python is already installed in your machine, run the following commands to validate the versions:
7884
@@ -83,10 +89,14 @@ $ pip freeze | grep pyperclip
8389
8490If your versions are lower than the prerequisite versions, you should update.
8591
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+ ```
90100
91101### Forking the project
92102
@@ -199,70 +209,48 @@ _[this](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git
199209For doing cmd2 development, it is recommended you create a virtual environment using Conda or Virtualenv and install the
200210package from the source.
201211
202- #### Create a new environment for cmd2 using Pipenv
212+ #### Create a new environment for cmd2 using uv
203213
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.
205215
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 ` .
209219
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
211221from a GitHub checkout:
212222
213223``` sh
214- pipenv install --dev
224+ uv venv
215225```
216226
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
218228--python VERSION flag, like so:
219229
220230``` 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
228232```
229233
230- #### Create a new environment for cmd2 using Conda
234+ Then you can run commands in this isolated virtual environment using ` uv ` like so:
231235
232236``` sh
233- $ conda create -n cmd2_py38 python=3.8
234- $ conda activate cmd2_py38
237+ uv run examples/basic.py
235238```
236239
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:
241241``` 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
247243```
248244
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
258246[ editable mode] ( https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs ) .
259247Changes to the source code are immediately available when the python interpreter
260248imports ` cmd2 ` , there is no need to re-install the module after every change. This
261249command will also install all of the runtime dependencies for ` cmd2 ` and modules used for development of ` cmd2 ` :
262250
263251``` sh
264252$ cd ~ /src/cmd2
265- $ pip install -e .[dev]
253+ $ uv venv
266254```
267255
268256This 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
275263available:
276264
277265``` sh
278- $ invoke -l
266+ $ uv run inv -l
279267```
280268
281269You can run multiple tasks in a single invocation, for example::
282270
283271``` sh
284- $ invoke docs sdist wheel
272+ $ uv run inv docs sdist wheel
285273```
286274
287275That one command will remove all superfluous cache, testing, and build
@@ -295,15 +283,15 @@ Now you can check if everything is installed and working:
295283
296284``` sh
297285$ cd ~ src/cmd2
298- $ invoke pytest
286+ $ uv run inv pytest
299287```
300288
301289If the tests are executed it means that dependencies and project are installed successfully.
302290
303291You can also run the example app and see a prompt that says "(Cmd)" running the command:
304292
305293``` sh
306- $ python examples/example.py
294+ $ uv run examples/example.py
307295```
308296
309297You 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
331319Sphinx documentation and make sure your changes look good:
332320
333321``` sh
334- $ invoke docs
322+ $ uv inv docs
335323```
336324
337325In 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
340328automatic page refreshes as you edit the files, use:
341329
342330``` sh
343- $ invoke livehtml
331+ $ uv inv livehtml
344332```
345333
346334You will be shown the IP address and port number where the documents are now
347335served (usually [ http://localhost:8000 ] ( http://localhost:8000 ) ).
348336
349- ### Static code analysis
337+ ### Code Quality Checks
350338
351339You should have some sort of [ PEP 8] ( https://www.python.org/dev/peps/pep-0008/ ) -based linting running in your editor or
352340IDE 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.
356344> clean and simple code base. Don't worry about linting errors in code you don't touch though - cleaning up the legacy
357345> code is a work in progress.
358346
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+
359375### Running the test suite
360376
361377When you're ready to share your code, run the test suite:
362378
363379``` sh
364380$ cd ~ /cmd2
365- $ invoke pytest
381+ $ uv run pytest
366382```
367383
368384and ensure all tests pass.
0 commit comments