|
2 | 2 | python-dev-tips, `Slides <https://docs.google.com/presentation/d/1BnezhwUy22DiF72wss8GU_YIMfhjortz-uILdIFGuoM/edit?usp=sharing>`__ |
3 | 3 | ****************************************************************************************************************************************** |
4 | 4 |
|
5 | | -Creating virtual environment and install |
6 | | -======================================== |
| 5 | +Tutorial first given at ENS Ulm (January 2023) on how to develop a Python package. There is a slight focus on scientific computing, but the general principles apply to any Python project. |
| 6 | + |
| 7 | +.. contents:: **Table of Contents** |
| 8 | + |
| 9 | +Creating virtual environment and local install |
| 10 | +============================================== |
7 | 11 |
|
8 | 12 | With `Anaconda <https://www.anaconda.com/>`__ (recommended). |
9 | 13 | After installing Anaconda or `Miniconda <https://docs.conda.io/en/latest/miniconda.html>`__ (light version), create a new environment: |
@@ -86,32 +90,51 @@ To run a specific test: |
86 | 90 | (project_env) pytest tests/test_fftconvolve.py::test_fft |
87 | 91 |
|
88 | 92 |
|
89 | | -Releasing package to PyPi |
90 | | -========================= |
| 93 | +Releasing new version and deploying to PyPi |
| 94 | +=========================================== |
| 95 | + |
| 96 | +Uploading to PyPi is done via `twine <https://pypi.org/project/twine/>`__. |
| 97 | + |
| 98 | +In the steps below and **after merging to** ``main``, replace "X.X.X" with the appropriate version number. |
91 | 99 |
|
92 | | -This is done through `twine <https://pypi.org/project/twine/>`__: |
| 100 | +See `Semantic Versioning <https://semver.org/>`__ for recommendations on picking version numbers. |
93 | 101 |
|
94 | 102 | .. code:: bash |
95 | 103 |
|
96 | 104 | # inside virtual environment |
97 | 105 | (project_env) pip install twine |
98 | 106 |
|
| 107 | + # edit version in setup |
99 | 108 | # build package |
100 | 109 | (project_env) python setup.py sdist bdist_wheel |
101 | | - # -- create in dist folder |
| 110 | + # -- creates zip in dist folder |
102 | 111 |
|
103 | | - # upload to test pypi |
| 112 | + # upload to pypi |
104 | 113 | (project_env) python -m twine upload dist/pydevtips-X.X.X.tar.gz |
105 | 114 | # -- X.X.X is the version number in setup.py |
106 | 115 | # -- enter username and password |
107 | 116 | # -- check https://pypi.org/project/pydevtips/X.X.X/ |
108 | 117 |
|
| 118 | + # new tag on GitHub |
| 119 | + git tag -a X.X.X -m "version X.X.X" |
| 120 | + git push origin X.X.X |
| 121 | +
|
| 122 | +On `GitHub <https://github.com/ebezzam/python-dev-tips/tags>`__ create a new release by: |
| 123 | + |
| 124 | +#. Clicking (the rightmost) "..." dropdown menu. |
| 125 | +#. Selecting "Create release". |
| 126 | +#. At the bottom pressing "Publish release". |
| 127 | + |
109 | 128 |
|
110 | 129 | TODO |
111 | 130 | ==== |
112 | 131 |
|
113 | | -- matplotlib in dev install |
| 132 | +- joblib example in profile |
| 133 | +- github page |
| 134 | +- point out features in scripts: object-oriented, asserts, tqdm, type hints |
| 135 | +- matplotlib, pytest, black in dev install |
114 | 136 | - example file with hydra |
115 | 137 | - manifest file to not include file in package |
116 | | -- GitHub actions |
117 | | -- documentation if time |
| 138 | +- GitHub actions for releasing to PyPi when changes to version |
| 139 | +- documentation (autodoc) |
| 140 | +- adding badges to README |
0 commit comments