@@ -7,12 +7,10 @@ Python Package (pypi) Cookiecutter, with emphasis on CI/CD and automation.
77
88| |build| |release_version| |wheel| |supported_versions| |commits_since_specific_tag_on_master| |commits_since_latest_github_release|
99
10-
1110|
1211| **Source Code:** https://github.com/boromir674/cookiecutter-python-package
1312| **Pypi Package:** https://pypi.org/project/cookiecutter-python/
14- |
15-
13+ | **CI Pipeline:** https://github.com/boromir674/cookiecutter-python-package/actions/
1614
1715.. Test Workflow Status on Github Actions for specific branch <branch>
1816
@@ -34,9 +32,9 @@ Python Package (pypi) Cookiecutter, with emphasis on CI/CD and automation.
3432 :alt: Supported Python versions
3533 :target: https://pypi.org/project/cookiecutter_python
3634
37- .. |commits_since_specific_tag_on_master | image :: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v0.6.1 /master?color=blue&logo=github
35+ .. |commits_since_specific_tag_on_master | image :: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v0.7.2 /master?color=blue&logo=github
3836 :alt: GitHub commits since tagged version (branch)
39- :target: https://github.com/boromir674/cookiecutter-python-package/compare/v0.6.1 ..master
37+ :target: https://github.com/boromir674/cookiecutter-python-package/compare/v0.7.2 ..master
4038
4139.. |commits_since_latest_github_release | image :: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/latest?color=blue&logo=semver&sort=semver
4240 :alt: GitHub commits since latest release (by SemVer)
@@ -55,63 +53,131 @@ Python Package (pypi) Cookiecutter, with emphasis on CI/CD and automation.
5553 :target: https://scrutinizer-ci.com/g/boromir674/cookiecutter-python-package/?branch=master
5654
5755
58-
59-
6056Features
6157========
6258
63- - Python Package Project generation
64- - CI pipeline to test against multiple Python versions and Platforms
65- - One-line commands for DevOps activities such as 'package', 'build', 'deploy'
66- - Test Suite, using Pytest
59+ 1. Fresh **Python Package Project Generation **, "packaged" with a **Test Suite ** and a **CI ** Pipeline (see `Quickstart `_)
60+ 2. **Python Package Template ** (source code at `src/cookiecutter_python/ `_) implemented as a `Cookiecutter `
61+ 3. **Tested ** on python versions **3.6, 2.7, 3.8, 3.9 and 3.10 **, for both **"Linux" ** and **"MacOS" ** platforms (see `Test Workflow ` on `CI `_)
62+
63+ See the **Biskotaki ** *Python Package Project *, which was entirely generated using this **Python Package Template: **
64+
65+ * **Source Code ** hosted on *Github * at https://github.com/boromir674/biskotaki
66+ * **Python Package ** hosted on *pypi.org * at https://pypi.org/project/biskotaki/
67+ * **CI Pipeline ** hosted on *Github Actions * at https://github.com/boromir674/biskotaki/actions
68+
69+ Generated Python Package Features
70+ ---------------------------------
71+
72+ 1. **Test Suite ** using `pytest `_
73+ 2. **Parallel Execution ** of Unit Tests, on multiple cpu's
74+ 3. **Automation **, using `tox `_
75+
76+ a. **Code Coverage ** measuring
77+ b. **Build Command **, using the `build `_ python package
78+ c. **Pypi Deploy Command **, supporting upload to both `pypi.org `_ and `test.pypi.org `_ servers
79+ d. **Type Check Command **, using `mypy `_
80+ 4. **CI Pipeline **, running on `Github Actions `_
81+
82+ a. **Job Matrix **, spanning different `platform `'s and `python version `'s
83+
84+ 1. Platfroms: `ubuntu-latest `, `macos-latest `
85+ 2. Python Interpreters: `3.6 `, `3.7 `, `3.8 `, `3.9 `, `3.10 `
86+ b. **Parallel Job ** execution, generated from the `matrix `, that runs the `Test Suite `
87+
6788
89+ Quickstart
90+ ==========
6891
6992Prerequisites
70- =============
93+ -------------
7194
7295You need to have Cookiecutter installed.
7396Check the `Cookiecutter documentation `_ pages for more on Cookiecutter.
7497
7598
7699Usage
77- =====
78-
79- Simply, get (clone) the code and generate a Project based on the (downloaded) template.
100+ -----
80101
81102Open a console/terminal and run:
82103
83- .. code-block :: sh
104+ .. code-block :: sh
84105
85- git clone git@github.com:boromir674/cookiecutter-python-package.git
106+ git clone git@github.com:boromir674/cookiecutter-python-package.git
107+ cookiecutter cookiecutter-python-package/src/cookiecutter_python
86108
87- cookiecutter cookiecutter-python-package/src/cookiecutter_python
109+ Now, you should have generated a new Project for a Python Package, based on the ` Template `_!
88110
111+ Just 'enter' (`cd ` into) the newly created directory, ie `cd <my-great-python-package> `.
89112
90- This will generate a new `Python Package Project ` (in the currect dir), using the template from github.
91- It shall prompt you to enter the necessary initial information to generate the project in a typical cookiecutter fashion.
113+ Develop your package's **Source Code ** (`business logic `) inside `src/my_great_python_package ` dir :)
92114
115+ Develop your package's **Test Suite ** (ie `unit-tests `, `integration tests `) inside `tests ` dir :)
93116
94- Modifying the Template
95- ======================
96117
97- You can always adjust the template to your needs, before generating a new Project.
118+ Try yourself!
119+ ^^^^^^^^^^^^^
98120
99- Open a console/terminal and run:
121+ You are ready to enjoy some of the package's **features ** available out-of-the-box!
122+
123+ For instance:
124+
125+ 1. Leverage the supplied `tox environments ` to automate various **Testing ** and **DevOps ** related activities.
126+
127+ Assuming you have `tox ` installed (example installation command: `python3 -m pip install --user tox `)
128+ and you have done a `cd ` into the newly generated Project directory, you can do for example:
129+
130+ a. Run the **Test Suite ** against different combinations of `Python versions ` (ie 3.7, 3.8) and different ways of installing (ie 'dev', 'sdist', 'wheel') the `<my_great_python_package> ` package:
131+
132+ .. code-block :: sh
133+
134+ tox -e " py{3.7, 3.8}-{dev, sdist, wheel}"
135+
136+ b. Check the code for **compliance ** with **best practises ** of the `Python packaging ecosystem ` (ie PyPI, pip),
137+ build `sdist ` and `wheel ` distributions and store them in the `dist ` directory:
138+
139+ .. code-block :: sh
140+
141+ tox -e check && tox -e build
142+
143+ c. **Deploy ** the package's distributions in a `pypi ` (index) server:
100144
101- .. code-block :: bash
145+ 1. Deploy to ** staging **, using the ` test ` pypi (index) server at ` test.pypi.org `_:
102146
103- git clone git@github.com:boromir674/cookiecutter-python-package.git
104- cd cookiecutter-python-package
147+ .. code-block :: sh
105148
149+ TWINE_USERNAME=username TWINE_PASSWORD=password PACKAGE_DIST_VERSION=1.0.0 tox -e deploy
106150
107- Now, you should be inside the `cookiecutter-python-package ` repository (directory)
108- and the actual Template, that you can modify, is inside the `src/cookiecutter_python ` sub directory.
151+ 2. Deploy to **production **, using the `production ` pypi (index) server at `pypi.org `_:
109152
110- After, finishing the modifications you can run something like:
153+ .. code-block :: sh
111154
112- .. code-block :: bash
155+ TWINE_USERNAME=username TWINE_PASSWORD=password PACKAGE_DIST_VERSION=1.0.0 PYPI_SERVER=pypi tox -e deploy
113156
114- cookiecutter src/cookiecutter_python --output-dir < your-new-project-dir>
157+ .. note ::
158+ Setting PYPI_SERVER=pypi indicates to deploy to `pypi.org ` (instead of `test.pypi.org `).
159+
160+ .. note ::
161+ Please modify the TWINE_USERNAME, TWINE_PASSWORD and PACKAGE_DIST_VERSION envronment variables, accordingly.
162+
163+ TWINE_USERNAME & TWINE_PASSWORD are used to authenticate (user credentials) with the targeted pypi server.
164+
165+ PACKAGE_DIST_VERSION is used to avoid accidentally uploading distributions of different versions than intented.
166+
167+
168+ 2. Leverage the **CI Pipeline ** and its **build matrix ** to run the **Test Suite ** against a combination of
169+ different Platforms, different Python interpreter versions and different ways of installing the subject Python Package:
170+
171+ `Trigger ` the **Test Workflow ** on the **CI server **, by `pushing ` a git commit to a remote branch (ie `master ` on github).
172+
173+ `Navigate ` to the `CI Pipeline web interface ` (hosted on `Github Actions `) and inspect the **build ** results!
174+
175+
176+ .. note ::
177+ You might have already `pushed `, in case you answered `yes `, in the `initialize_git_repo ` prompt, while generating the Python Package,
178+ and in that case, the **Test Workflow ** should have already started running!
179+
180+ Out-of-the-box, `triggering ` the **Test Workflow ** happens only when pushing to the `master ` or `dev ` branch.
115181
116182
117183License
@@ -120,7 +186,39 @@ License
120186* Free software: Affero GNU General Public License v3.0
121187
122188
189+ Notes
190+ =====
191+
192+ Currently, since the actual `cookiecutter ` template does not reside on the `root ` directory
193+ of the repository (but rather in `src/cookiecutter_python `), 'cloning' the repository
194+ locally is required at first.
195+
196+ This was demonstrated in the `quickstart ` section, as well.
197+
198+ For more complex use cases, you can modify the Template and also leverage all of
199+ `cookiecutter `'s features, according to your needs.
200+
123201
124202.. URL LINKS
125203
126204 .. _Cookiecutter documentation : https://cookiecutter.readthedocs.io/en/stable/
205+
206+ .. _CI : https://github.com/boromir674/cookiecutter-python-package/actions
207+
208+ .. _tox : https://tox.wiki/en/latest/
209+
210+ .. _pytest : https://docs.pytest.org/en/7.1.x/
211+
212+ .. _build : https://github.com/pypa/build
213+
214+ .. _pypi.org : https://pypi.org/
215+
216+ .. _test.pypi.org : https://test.pypi.org/
217+
218+ .. _mypy : https://mypy.readthedocs.io/en/stable/
219+
220+ .. _Github Actions : https://github.com/boromir674/cookiecutter-python-package/actions
221+
222+ .. _src/cookiecutter_python/ : https://github.com/boromir674/cookiecutter-python-package/tree/master/src/cookiecutter_python
223+
224+ .. _Template : https://github.com/boromir674/cookiecutter-python-package/tree/master/src/cookiecutter_python
0 commit comments