|
| 1 | +# Quickstart Guide |
| 2 | + |
| 3 | +## Requirements |
| 4 | + |
| 5 | +Install [Cookiecutter]: |
| 6 | + |
| 7 | +```console |
| 8 | +$ pipx install cookiecutter |
| 9 | +``` |
| 10 | + |
| 11 | +Install [Poetry] by downloading and running [install-poetry.py]: |
| 12 | + |
| 13 | +```console |
| 14 | +$ python install-poetry.py |
| 15 | +``` |
| 16 | + |
| 17 | +Install [Nox] and [nox-poetry]: |
| 18 | + |
| 19 | +```console |
| 20 | +$ pipx install nox |
| 21 | +$ pipx inject nox nox-poetry |
| 22 | +``` |
| 23 | + |
| 24 | +[pipx] is preferred, but you can also install with `pip install --user`. |
| 25 | + |
| 26 | +It is recommended to set up Python 3.7, 3.8, 3.9, 3.10 using [pyenv]. |
| 27 | + |
| 28 | +## Creating a project |
| 29 | + |
| 30 | +Generate a Python project: |
| 31 | + |
| 32 | +```console |
| 33 | +$ cookiecutter gh:cjolowicz/cookiecutter-hypermodern-python \ |
| 34 | + --checkout="2021.11.26" |
| 35 | +``` |
| 36 | + |
| 37 | +Change to the root directory of your new project, |
| 38 | +and create a Git repository: |
| 39 | + |
| 40 | +```console |
| 41 | +$ git init |
| 42 | +$ git add . |
| 43 | +$ git commit |
| 44 | +``` |
| 45 | + |
| 46 | +## Running |
| 47 | + |
| 48 | +Run the command-line interface from the source tree: |
| 49 | + |
| 50 | +```console |
| 51 | +$ poetry install |
| 52 | +$ poetry run <project> |
| 53 | +``` |
| 54 | + |
| 55 | +Run an interactive Python session: |
| 56 | + |
| 57 | +```console |
| 58 | +$ poetry install |
| 59 | +$ poetry run python |
| 60 | +``` |
| 61 | + |
| 62 | +## Testing |
| 63 | + |
| 64 | +Run the full test suite: |
| 65 | + |
| 66 | +```console |
| 67 | +$ nox |
| 68 | +``` |
| 69 | + |
| 70 | +List the available Nox sessions: |
| 71 | + |
| 72 | +```console |
| 73 | +$ nox --list-sessions |
| 74 | +``` |
| 75 | + |
| 76 | +Install the pre-commit hooks: |
| 77 | + |
| 78 | +```console |
| 79 | +$ nox -s pre-commit -- install |
| 80 | +``` |
| 81 | + |
| 82 | +## Continuous Integration |
| 83 | + |
| 84 | +### GitHub |
| 85 | + |
| 86 | +1. Sign up at [GitHub]. |
| 87 | +2. Create an empty repository for your project. |
| 88 | +3. Follow the instructions to push an existing repository from the command line. |
| 89 | + |
| 90 | +### PyPI |
| 91 | + |
| 92 | +1. Sign up at [PyPI]. |
| 93 | +2. Go to the Account Settings on PyPI, |
| 94 | + generate an API token, and copy it. |
| 95 | +3. Go to the repository settings on GitHub, and |
| 96 | + add a secret named `PYPI_TOKEN` with the token you just copied. |
| 97 | + |
| 98 | +### TestPyPI |
| 99 | + |
| 100 | +1. Sign up at [TestPyPI]. |
| 101 | +2. Go to the Account Settings on TestPyPI, |
| 102 | + generate an API token, and copy it. |
| 103 | +3. Go to the repository settings on GitHub, and |
| 104 | + add a secret named `TEST_PYPI_TOKEN` with the token you just copied. |
| 105 | + |
| 106 | +### Codecov |
| 107 | + |
| 108 | +1. Sign up at [Codecov]. |
| 109 | +2. Install their GitHub app. |
| 110 | + |
| 111 | +### Read the Docs |
| 112 | + |
| 113 | +1. Sign up at [Read the Docs]. |
| 114 | +2. Import your GitHub repository, using the button _Import a Project_. |
| 115 | +3. Install the GitHub webhook, |
| 116 | + using the button _Add integration_ |
| 117 | + on the _Integrations_ tab |
| 118 | + in the _Admin_ section of your project |
| 119 | + on Read the Docs. |
| 120 | + |
| 121 | +## Releasing |
| 122 | + |
| 123 | +Releases are triggered by a version bump on the default branch. |
| 124 | +It is recommended to do this in a separate pull request: |
| 125 | + |
| 126 | +1. Switch to a branch. |
| 127 | +2. Bump the version using [poetry version]. |
| 128 | +3. Commit and push to GitHub. |
| 129 | +4. Open a pull request. |
| 130 | +5. Merge the pull request. |
| 131 | + |
| 132 | +The Release workflow performs the following automated steps: |
| 133 | + |
| 134 | +- Build and upload the package to PyPI. |
| 135 | +- Apply a version tag to the repository. |
| 136 | +- Publish a GitHub Release. |
| 137 | + |
| 138 | +Release notes are populated with the titles and authors of merged pull requests. |
| 139 | +You can group the pull requests into separate sections |
| 140 | +by applying labels to them, like this: |
| 141 | + |
| 142 | +<!-- table-release-drafter-sections-begin --> |
| 143 | + |
| 144 | +| Pull Request Label | Section in Release Notes | |
| 145 | +| ------------------ | ---------------------------- | |
| 146 | +| `breaking` | 💥 Breaking Changes | |
| 147 | +| `enhancement` | 🚀 Features | |
| 148 | +| `removal` | 🔥 Removals and Deprecations | |
| 149 | +| `bug` | 🐞 Fixes | |
| 150 | +| `performance` | 🐎 Performance | |
| 151 | +| `testing` | 🚨 Testing | |
| 152 | +| `ci` | 👷 Continuous Integration | |
| 153 | +| `documentation` | 📚 Documentation | |
| 154 | +| `refactoring` | 🔨 Refactoring | |
| 155 | +| `style` | 💄 Style | |
| 156 | +| `dependencies` | 📦 Dependencies | |
| 157 | + |
| 158 | +<!-- table-release-drafter-sections-end --> |
| 159 | + |
| 160 | +[codecov]: https://codecov.io/ |
| 161 | +[cookiecutter]: https://github.com/audreyr/cookiecutter |
| 162 | +[github]: https://github.com/ |
| 163 | +[install-poetry.py]: https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py |
| 164 | +[nox]: https://nox.thea.codes/ |
| 165 | +[nox-poetry]: https://nox-poetry.readthedocs.io/ |
| 166 | +[pipx]: https://pipxproject.github.io/pipx/ |
| 167 | +[poetry]: https://python-poetry.org/ |
| 168 | +[poetry version]: https://python-poetry.org/docs/cli/#version |
| 169 | +[pyenv]: https://github.com/pyenv/pyenv |
| 170 | +[pypi]: https://pypi.org/ |
| 171 | +[read the docs]: https://readthedocs.org/ |
| 172 | +[testpypi]: https://test.pypi.org/ |
0 commit comments