Skip to content

Commit 7000604

Browse files
authored
Merge pull request #422 from python-cmd2/invoke
Move from fab to invoke
2 parents a72219b + 6e027d1 commit 7000604

File tree

4 files changed

+261
-154
lines changed

4 files changed

+261
-154
lines changed

CONTRIBUTING.md

Lines changed: 82 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ The tables below list all prerequisites along with the minimum required version
6767

6868
If Python is already installed in your machine, run the following commands to validate the versions:
6969

70-
```shell
71-
python -V
72-
pip freeze | grep pyperclip
70+
```sh
71+
$ python -V
72+
$ pip freeze | grep pyperclip
7373
```
7474

7575
If your versions are lower than the prerequisite versions, you should update.
@@ -95,7 +95,7 @@ If you do not already have Python installed on your machine, we recommend using
9595
1. Open a Terminal / Command Line / Bash Shell in your projects directory (_i.e.: `/yourprojectdirectory/`_)
9696
2. Clone your fork of cmd2
9797

98-
```shell
98+
```sh
9999
$ git clone https://github.com/yourUsername/cmd2.git
100100
```
101101

@@ -108,7 +108,7 @@ This will download the entire cmd2 repo to your projects directory.
108108
1. Change directory to the new cmd2 directory (`cd cmd2`)
109109
2. Add a remote to the official cmd2 repo:
110110

111-
```shell
111+
```sh
112112
$ git remote add upstream https://github.com/python-cmd2/cmd2.git
113113
```
114114

@@ -124,29 +124,29 @@ Do this prior to every time you create a branch for a PR:
124124

125125
1. Make sure you are on the `master` branch
126126

127-
> ```shell
127+
> ```sh
128128
> $ git status
129129
> On branch master
130130
> Your branch is up-to-date with 'origin/master'.
131131
> ```
132132
133133
> If your aren't on `master`, resolve outstanding files / commits and checkout the `master` branch
134134
135-
> ```shell
135+
> ```sh
136136
> $ git checkout master
137137
> ```
138138
139139
2. Do A Pull with Rebase Against `upstream`
140140
141-
> ```shell
141+
> ```sh
142142
> $ git pull --rebase upstream master
143143
> ```
144144
145145
> This will pull down all of the changes to the official master branch, without making an additional commit in your local repo.
146146
147147
3. (_Optional_) Force push your updated master branch to your GitHub fork
148148
149-
> ```shell
149+
> ```sh
150150
> $ git push origin master --force
151151
> ```
152152
@@ -164,13 +164,13 @@ Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short
164164
165165
To create a branch on your local machine (and switch to this branch):
166166
167-
```shell
167+
```sh
168168
$ git checkout -b [name_of_your_new_branch]
169169
```
170170
171171
and to push to GitHub:
172172

173-
```shell
173+
```sh
174174
$ git push origin [name_of_your_new_branch]
175175
```
176176

@@ -180,12 +180,12 @@ $ git push origin [name_of_your_new_branch]
180180
### Setup for cmd2 development
181181
For doing cmd2 development, you actually do NOT want to have cmd2 installed as a Python package.
182182
So if you have previously installed cmd2, make sure to uninstall it:
183-
```bash
184-
pip uninstall cmd2
183+
```sh
184+
$ pip uninstall cmd2
185185
```
186186

187187
Assuming you cloned the repository to `~/src/cmd2`:
188-
```bash
188+
```sh
189189
$ cd ~/src/cmd2
190190
$ pip install -e .
191191
```
@@ -195,18 +195,39 @@ imports `cmd2`, there is no need to re-install the module after every change. Th
195195
command will also install all of the runtime dependencies for `cmd2`.
196196

197197
Next you should install all the modules used for development of `cmd2`:
198-
```bash
198+
```sh
199199
$ cd ~/src/cmd2
200200
$ pip install -e .[dev]
201201
```
202202

203-
This will install `pytest` and `tox` for running unit tests, `pylint` for
204-
static code analysis, and `sphinx` for building the documentation.
203+
This project uses many python modules for various development tasks, including
204+
testing, rendering documentation, and building and distributing releases. These
205+
modules can be configured many different ways, which can make it difficult to
206+
learn the specific incantations required for each project you are familiar with.
207+
208+
This project uses `invoke <http://www.pyinvoke.org>`_ to provide a clean, high
209+
level interface for these development tasks. To see the full list of functions
210+
available::
211+
```sh
212+
$ invoke -l
213+
```
214+
215+
You can run multiple tasks in a single invocation, for example::
216+
```sh
217+
$ invoke docs sdist wheel
218+
```
219+
220+
That one command will remove all superflous cache, testing, and build
221+
files, render the documentation, and build a source distribution and a
222+
wheel distribution.
223+
224+
If you want to see the details about what `invoke` is doing under the hood,
225+
have a look at `tasks.py`.
205226

206227
Now you can check if everything is installed and working:
207-
```bash
208-
cd ~src/cmd2
209-
python examples/example.py
228+
```sh
229+
$ cd ~src/cmd2
230+
$ python examples/example.py
210231
```
211232

212233
If the example app loads, you should see a prompt that says "(Cmd)". You can
@@ -220,20 +241,32 @@ This bit is up to you!
220241

221242
#### How to find the code in the cmd2 codebase to fix/edit?
222243

223-
The cmd2 project directory structure is pretty simple and straightforward. All actual code for cmd2
224-
is located underneath the `cmd2` directory. The code to generate the documentation is in the `docs` directory. Unit tests are in the `tests` directory. The `examples` directory contains examples of how
225-
to use cmd2. There are various other files in the root directory, but these are primarily related to
226-
continuous integration and to release deployment.
244+
The cmd2 project directory structure is pretty simple and straightforward. All
245+
actual code for cmd2 is located underneath the `cmd2` directory. The code to
246+
generate the documentation is in the `docs` directory. Unit tests are in the
247+
`tests` directory. The `examples` directory contains examples of how to use
248+
cmd2. There are various other files in the root directory, but these are
249+
primarily related to continuous integration and to release deployment.
227250

228251
#### Changes to the documentation files
229-
If you made changes to any file in the `/docs` directory, you need to build the Sphinx documentation
230-
and make sure your changes look good:
231-
```shell
232-
cd docs
233-
make clean html
252+
253+
If you made changes to any file in the `/docs` directory, you need to build the
254+
Sphinx documentation and make sure your changes look good:
255+
```sh
256+
$ invoke docs
234257
```
235258
In order to see the changes, use your web browser of choice to open `<cmd2>/docs/_build/html/index.html`.
236259

260+
If you would rather use a webserver to view the documentation, including
261+
automatic page refreshes as you edit the files, use:
262+
263+
```sh
264+
$ invoke livehtml
265+
```
266+
267+
You will be shown the IP address and port number where the documents are now
268+
served (usually [http://localhost:8000](http://localhost:8000).
269+
237270
### Static Code Analysis
238271

239272
You should have some sort of [PEP8](https://www.python.org/dev/peps/pep-0008/)-based linting running in your editor or IDE or at the command-line before you commit code. [pylint](https://www.pylint.org) is a good Python linter which can be run at the command-line but also can integrate with many IDEs and editors.
@@ -242,21 +275,14 @@ You should have some sort of [PEP8](https://www.python.org/dev/peps/pep-0008/)-b
242275
243276
### Run The Test Suite
244277
When you're ready to share your code, run the test suite:
245-
```shell
246-
cd <cmd2>
247-
py.test
278+
```sh
279+
$ cd <cmd2>
280+
$ invoke pytest
248281
```
249282
and ensure all tests pass.
250283

251-
#### Measuring code coverage
252-
253-
Code coverage can be measured as follows:
254-
255-
```shell
256-
py.test --cov=cmd2 --cov-report=term-missing --cov-report=html
257-
```
258-
259-
Then use your web browser of choice to look at the results which are in `<cmd2>/htmlcov/index.html`.
284+
Running the test suite also calculates test code coverage. A summary of coverage
285+
is shown on the screen. A full report is available in `<cmd2>/htmlcov/index.html`.
260286

261287
### Squash Your Commits
262288
When you make a pull request, it is preferable for all of your changes to be in one commit.
@@ -301,7 +327,7 @@ Instance of cmd2](#maintaining-your-fork).
301327
1. Perform the maintenance step of rebasing `master`.
302328
2. Ensure you are on the `master` branch using `git status`:
303329

304-
```bash
330+
```sh
305331
$ git status
306332
On branch master
307333
Your branch is up-to-date with 'origin/master'.
@@ -458,6 +484,19 @@ excellent support for debugging console applications.
458484

459485
[PyCharm](https://www.jetbrains.com/pycharm/) is also quite good and has very nice [Code Inspection](https://www.jetbrains.com/help/pycharm/code-inspection.html) capabilities.
460486

461-
### Acknowledgement
487+
## Publishing a new release
488+
489+
Since 0.9.2, the process of publishing a new release of `cmd2` to [PyPi](https://pypi.org/) has been
490+
mostly automated. The manual steps are all git operations. Here's the checklist:
491+
492+
1. Make sure you are on the proper branch
493+
2. Make sure the version strings in `cmd2.py`, `conf.py`, `setup.py`, and `test_cmd2.py` are correct.
494+
3. Make sure all the unit tests pass.
495+
4. Make sure `CHANGELOG.md` describes the version and has the correct release date.
496+
5. Create and push a git tag that matches the version strings above.
497+
6. (Optional) Run `invoke pypi_test` to clean, build, and upload a new release to [Test PyPi](https://test.pypi.org)
498+
7. Run `invoke pypi` to clean, build, and upload a new release to [PyPi](https://pypi.org/)
499+
500+
## Acknowledgement
462501
Thanks to the good folks at [freeCodeCamp](https://github.com/freeCodeCamp/freeCodeCamp) for creating
463502
an excellent `CONTRIBUTING` file which we have borrowed heavily from.

fabfile.py

Lines changed: 0 additions & 111 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
# install with 'pip install -e .[dev]'
7474
'dev': [
7575
'pytest', 'pytest-cov', 'tox', 'pylint', 'sphinx', 'sphinx-rtd-theme',
76+
'sphinx-autobuild','invoke', 'twine',
7677
]
7778
}
7879

0 commit comments

Comments
 (0)