| 1 |
# Contributing |
| 2 |
|
| 3 |
Welcome! |
| 4 |
|
| 5 |
For contributing tips, follow the [Jupyter Contributing Guide](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html). |
| 6 |
Please make sure to follow the [Jupyter Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md). |
| 7 |
|
| 8 |
## Installing ipykernel for development |
| 9 |
|
| 10 |
ipykernel is a pure Python package, so setting up for development is the same as most other Python projects: |
| 11 |
|
| 12 |
```bash |
| 13 |
# clone the repo |
| 14 |
git clone https://github.com/ipython/ipykernel |
| 15 |
cd ipykernel |
| 16 |
# do a 'development' or 'editable' install with pip: |
| 17 |
pip install -e . |
| 18 |
``` |
| 19 |
|
| 20 |
## Code Styling |
| 21 |
|
| 22 |
`ipykernel` has adopted automatic code formatting so you shouldn't |
| 23 |
need to worry too much about your code style. |
| 24 |
As long as your code is valid, |
| 25 |
the pre-commit hook should take care of how it should look. |
| 26 |
To install `pre-commit`, run the following:: |
| 27 |
|
| 28 |
``` |
| 29 |
pip install pre-commit |
| 30 |
pre-commit install |
| 31 |
``` |
| 32 |
|
| 33 |
You can invoke the pre-commit hook by hand at any time with:: |
| 34 |
|
| 35 |
``` |
| 36 |
pre-commit run |
| 37 |
``` |
| 38 |
|
| 39 |
which should run any autoformatting on your code |
| 40 |
and tell you about any errors it couldn't fix automatically. |
| 41 |
You may also install [black integration](https://github.com/psf/black#editor-integration) |
| 42 |
into your text editor to format code automatically. |
| 43 |
|
| 44 |
If you have already committed files before setting up the pre-commit |
| 45 |
hook with `pre-commit install`, you can fix everything up using |
| 46 |
`pre-commit run --all-files`. You need to make the fixing commit |
| 47 |
yourself after that. |
| 48 |
|
| 49 |
Some of the hooks only run on CI by default, but you can invoke them by |
| 50 |
running with the `--hook-stage manual` argument. |
| 51 |
|
| 52 |
## Releasing ipykernel |
| 53 |
|
| 54 |
Releasing ipykernel is _almost_ standard for a Python package: |
| 55 |
|
| 56 |
- set version for release |
| 57 |
- make and publish tag |
| 58 |
- publish release to PyPI |
| 59 |
- set version back to development |
| 60 |
|
| 61 |
The one extra step for ipykernel is that we need to make separate wheels for Python 2 and 3 |
| 62 |
because the bundled kernelspec has different contents for Python 2 and 3. This |
| 63 |
affects only the 4.x branch of ipykernel as the 5+ version is only compatible |
| 64 |
Python 3. |
| 65 |
|
| 66 |
The full release process is available below: |
| 67 |
|
| 68 |
```bash |
| 69 |
# make sure version is set in ipykernel/_version.py |
| 70 |
VERSION="4.9.0" |
| 71 |
# commit the version and make a release tag |
| 72 |
git add ipykernel/_version.py |
| 73 |
git commit -m "release $VERSION" |
| 74 |
git tag -am "release $VERSION" $VERSION |
| 75 |
|
| 76 |
# push the changes to the repo |
| 77 |
git push |
| 78 |
git push --tags |
| 79 |
|
| 80 |
# publish the release to PyPI |
| 81 |
# note the extra `python2 setup.py bdist_wheel` for creating |
| 82 |
# the wheel for Python 2 |
| 83 |
pip install --upgrade twine |
| 84 |
git clean -xfd |
| 85 |
python3 setup.py sdist bdist_wheel |
| 86 |
python2 setup.py bdist_wheel # the extra step for the 4.x branch. |
| 87 |
twine upload dist/* |
| 88 |
|
| 89 |
# set the version back to '.dev' in ipykernel/_version.py |
| 90 |
# e.g. 4.10.0.dev if we just released 4.9.0 |
| 91 |
git add ipykernel/_version.py |
| 92 |
git commit -m "back to dev" |
| 93 |
git push |
| 94 |
``` |