|
| 1 | +# Contributing to readchar |
| 2 | + |
| 3 | +:+1::tada: First off, thanks for taking the time to contribute! :tada::+1: |
| 4 | + |
| 5 | +The following is a set of guidelines for contributing to this GitHub project. These are mostly guidelines, not rules. Use your best judgment, and feel |
| 6 | +free to propose changes to this document in a pull request. |
| 7 | + |
| 8 | +## Opening an issue |
| 9 | + |
| 10 | +If you want to open an issue about a problem or bug you encountered, simply go to the GitHub page and click _New issue_ in the _issues_ section. You |
| 11 | +will be presented with templates to use, choose a relevant one. (If no template fits, you can open a blank issue. But make sure you input all the |
| 12 | +appropriate information!) |
| 13 | + |
| 14 | +Fill out the template. You should at least provide the following information: |
| 15 | + |
| 16 | +- a short but exact description of your problem (screenshots often help) |
| 17 | +- steps on how to reproduce the problem |
| 18 | +- Information about your system: |
| 19 | + - your OS |
| 20 | + - your Python version and implementation |
| 21 | + - the version of readchar you use |
| 22 | + |
| 23 | +## Opening a pull request |
| 24 | + |
| 25 | +Follow these steps if you want to contribute code to the project: |
| 26 | + |
| 27 | +1. Fork this Git repository and create your branch from `master`. |
| 28 | + |
| 29 | +2. Check out the code to your local machine by following the steps in [Getting the code](#getting-the-code) and make your changes. |
| 30 | + |
| 31 | +3. **Make sure the tests pass!!** |
| 32 | + |
| 33 | +4. If you added to the source code, add tests for your new code. |
| 34 | + |
| 35 | +5. Update the documentation, if necessary. |
| 36 | + |
| 37 | +6. Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), if you have multiple changes, make sure your |
| 38 | + commits are atomic (single irreducible change that makes sense on its own) |
| 39 | + |
| 40 | +7. Done, you can open a pull request. |
| 41 | + |
| 42 | +## Getting the code |
| 43 | + |
| 44 | +If you want to experiment with the code yourself, you can get started by following these steps. |
| 45 | + |
| 46 | +1. Clone the repository. |
| 47 | + |
| 48 | + ```bash |
| 49 | + git clone https://github.com/magmax/python-readchar.git |
| 50 | + ``` |
| 51 | + |
| 52 | +2. Create a virtual environment: |
| 53 | + |
| 54 | + ```bash |
| 55 | + python -m venv .venv |
| 56 | + ``` |
| 57 | + |
| 58 | +3. Enter the virtual environment |
| 59 | + |
| 60 | + on Linux systems: |
| 61 | + |
| 62 | + ```bash |
| 63 | + source .venv/bin/activate |
| 64 | + ``` |
| 65 | + |
| 66 | + or for Windows systems: |
| 67 | + |
| 68 | + ```bash |
| 69 | + .venv\Scripts\activate |
| 70 | + ``` |
| 71 | + |
| 72 | +4. Install dependencies |
| 73 | + |
| 74 | + ```bash |
| 75 | + pip install -r requirements.txt |
| 76 | + ``` |
| 77 | + |
| 78 | +5. Install the local version of readchar (in edit mode, so it automatically reflects changes) |
| 79 | + |
| 80 | + ```bash |
| 81 | + pip install -e . |
| 82 | + ``` |
| 83 | + |
| 84 | +### Run the tests! |
| 85 | + |
| 86 | +Always make sure all tests pass before suggesting any changes! This will avoid invalid PR's. |
| 87 | +
|
| 88 | +The simplest way is to just run `make`. The provided makefile calls all tests for you. |
| 89 | +
|
| 90 | +```bash |
| 91 | +make |
| 92 | +``` |
| 93 | +
|
| 94 | +If you don't have `make`, you could run all tests manually like this: |
| 95 | + |
| 96 | +- run `pytest` (source-code testing) |
| 97 | + |
| 98 | + ```bash |
| 99 | + pytest |
| 100 | + ``` |
| 101 | + |
| 102 | +- run `pre-commit` (linting and styling) |
| 103 | + |
| 104 | + ```bash |
| 105 | + pre-commit run -a |
| 106 | + ``` |
| 107 | + |
| 108 | +- run `setup.py` (to test build process) |
| 109 | + |
| 110 | + ```bash |
| 111 | + python setup.py sdist bdist_wheel |
| 112 | + ``` |
0 commit comments