|
| 1 | +# Contributing |
| 2 | + |
| 3 | +<details> |
| 4 | +<summary>Table of Contents</summary> |
| 5 | + |
| 6 | +- [Fork](#fork) |
| 7 | +- [Install](#install) |
| 8 | +- [Develop](#develop) |
| 9 | +- [Test](#test) |
| 10 | +- [Lint](#lint) |
| 11 | +- [Build](#build) |
| 12 | +- [Release](#release) |
| 13 | + |
| 14 | +</details> |
| 15 | + |
| 16 | +Pull requests are welcome! By participating in this project, you agree to abide by our [code of conduct](https://github.com/remarkablemark/.github/blob/master/CODE_OF_CONDUCT.md). |
| 17 | + |
| 18 | +## Fork |
| 19 | + |
| 20 | +[Fork](https://github.com/remarkablemark/python_package_template/fork) and then clone the repository: |
| 21 | + |
| 22 | +```sh |
| 23 | +# replace <USER> with your username |
| 24 | +git clone [email protected]: <USER >/python_package_template.git |
| 25 | +``` |
| 26 | + |
| 27 | +```sh |
| 28 | +cd python_package_template |
| 29 | +``` |
| 30 | + |
| 31 | +## Install |
| 32 | + |
| 33 | +Install [Python](https://www.python.org/): |
| 34 | + |
| 35 | +```sh |
| 36 | +brew install python |
| 37 | +``` |
| 38 | + |
| 39 | +Create the virtual environment: |
| 40 | + |
| 41 | +```sh |
| 42 | +python3 -m venv .venv |
| 43 | +``` |
| 44 | + |
| 45 | +Activate the virtual environment: |
| 46 | + |
| 47 | +```sh |
| 48 | +source .venv/bin/activate |
| 49 | +``` |
| 50 | + |
| 51 | +Install the dependencies: |
| 52 | + |
| 53 | +```sh |
| 54 | +pip install -e '.[build]' |
| 55 | +pip install -e '.[test]' |
| 56 | +``` |
| 57 | + |
| 58 | +Install pre-commit into your git hooks: |
| 59 | + |
| 60 | +```sh |
| 61 | +pre-commit install |
| 62 | +``` |
| 63 | + |
| 64 | +## Develop |
| 65 | + |
| 66 | +Make your changes, add tests/documentation, and ensure tests pass: |
| 67 | + |
| 68 | +```sh |
| 69 | +pytest |
| 70 | +``` |
| 71 | + |
| 72 | +Write a commit message that follows the [Conventional Commits](https://www.conventionalcommits.org/) specification: |
| 73 | + |
| 74 | +- **feat**: A new feature |
| 75 | +- **fix**: A bug fix |
| 76 | +- **perf**: A code change that improves performance |
| 77 | +- **refactor**: A code change that neither fixes a bug nor adds a feature |
| 78 | +- **test**: Add missing tests or correct existing tests |
| 79 | +- **build**: Changes that affect the build system or external dependencies |
| 80 | +- **ci**: Updates configuration files and scripts for continuous integration |
| 81 | +- **docs**: Documentation only changes |
| 82 | + |
| 83 | +Push to your fork and create a [pull request](https://github.com/remarkablemark/python_package_template/compare/). |
| 84 | + |
| 85 | +At this point, wait for us to review your pull request. We'll try to review pull requests within 1-3 business days. We may suggest changes, improvements, and/or alternatives. |
| 86 | + |
| 87 | +Things that will improve the chance that your pull request will be accepted: |
| 88 | + |
| 89 | +- [ ] Write tests that pass [CI](https://github.com/remarkablemark/python_package_template/actions/workflows/test.yml). |
| 90 | +- [ ] Write solid documentation. |
| 91 | +- [ ] Write a good [commit message](https://github.com/angular/angular/blob/main/CONTRIBUTING.md#commit). |
| 92 | + |
| 93 | +## Test |
| 94 | + |
| 95 | +Run the tests: |
| 96 | + |
| 97 | +```sh |
| 98 | +pytest |
| 99 | +``` |
| 100 | + |
| 101 | +## Lint |
| 102 | + |
| 103 | +Update pre-commit hooks to the latest version: |
| 104 | + |
| 105 | +```sh |
| 106 | +pre-commit autoupdate |
| 107 | +``` |
| 108 | + |
| 109 | +Run all pre-commit hooks: |
| 110 | + |
| 111 | +```sh |
| 112 | +pre-commit run --all-files |
| 113 | +``` |
| 114 | + |
| 115 | +Lint all files in the current directory: |
| 116 | + |
| 117 | +```sh |
| 118 | +ruff check |
| 119 | +``` |
| 120 | + |
| 121 | +Format all files in the current directory: |
| 122 | + |
| 123 | +```sh |
| 124 | +ruff format |
| 125 | +``` |
| 126 | + |
| 127 | +## Build |
| 128 | + |
| 129 | +Generate distribution packages: |
| 130 | + |
| 131 | +```sh |
| 132 | +python3 -m build |
| 133 | +``` |
| 134 | + |
| 135 | +Upload all of the archives under `dist`: |
| 136 | + |
| 137 | +```sh |
| 138 | +twine upload --repository testpypi dist/* |
| 139 | +``` |
| 140 | + |
| 141 | +Install the package: |
| 142 | + |
| 143 | +```sh |
| 144 | +pip install --index-url https://test.pypi.org/simple/ --no-deps python_package_template |
| 145 | +``` |
| 146 | + |
| 147 | +## Release |
| 148 | + |
| 149 | +Release and publish are automated with [Release Please](https://github.com/googleapis/release-please). |
| 150 | + |
| 151 | +[Add a new pending publisher to PyPI.](https://pypi.org/manage/account/publishing/) |
0 commit comments