Yet another modern Python Package (pypi) with emphasis in CI/CD and automation
Project description
Features
Fresh Python Package Project Generation, “packaged” with a Test Suite and a CI Pipeline (see Quickstart)
Python Package Template (source code at src/cookiecutter_python/) implemented as a Cookiecutter
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)
See the Biskotaki Python Package Project, which was entirely generated using this Python Package Template:
Source Code hosted on Github at https://github.com/boromir674/biskotaki
Python Package hosted on pypi.org at https://pypi.org/project/biskotaki/
CI Pipeline hosted on Github Actions at https://github.com/boromir674/biskotaki/actions
Generated Python Package Features
Test Suite using pytest
Parallel Execution of Unit Tests, on multiple cpu’s
Automation, using tox
Code Coverage measuring
Build Command, using the build python package
Pypi Deploy Command, supporting upload to both pypi.org and test.pypi.org servers
Type Check Command, using mypy
CI Pipeline, running on Github Actions
Job Matrix, spanning different platform’s and python version’s
Platfroms: ubuntu-latest, macos-latest
Python Interpreters: 3.6, 3.7, 3.8, 3.9, 3.10
Parallel Job execution, generated from the matrix, that runs the Test Suite
Quickstart
Prerequisites
You need to have Cookiecutter installed. Check the Cookiecutter documentation pages for more on Cookiecutter.
Usage
Open a console/terminal and run:
git clone git@github.com:boromir674/cookiecutter-python-package.git cookiecutter cookiecutter-python-package/src/cookiecutter_python
Now, you should have generated a new Project for a Python Package, based on the Template!
Just ‘enter’ (cd into) the newly created directory, ie cd <my-great-python-package>.
Develop your package’s Source Code (business logic) inside src/my_great_python_package dir :)
Develop your package’s Test Suite (ie unit-tests, integration tests) inside tests dir :)
Try yourself!
You are ready to enjoy some of the package’s features available out-of-the-box!
For instance:
Leverage the supplied tox environments to automate various Testing and DevOps related activities.
Assuming you have tox installed (example installation command: python3 -m pip install –user tox) and you have done a cd into the newly generated Project directory, you can do for example:
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:
tox -e "py{3.7, 3.8}-{dev, sdist, wheel}"
Check the code for compliance with best practises of the Python packaging ecosystem (ie PyPI, pip), build sdist and wheel distributions and store them in the dist directory:
tox -e check && tox -e build
Deploy the package’s distributions in a pypi (index) server:
Deploy to staging, using the test pypi (index) server at test.pypi.org:
TWINE_USERNAME=username TWINE_PASSWORD=password PACKAGE_DIST_VERSION=1.0.0 tox -e deploy
Deploy to production, using the production pypi (index) server at pypi.org:
TWINE_USERNAME=username TWINE_PASSWORD=password PACKAGE_DIST_VERSION=1.0.0 PYPI_SERVER=pypi tox -e deploy
Leverage the CI Pipeline and its build matrix to run the Test Suite against a combination of different Platforms, different Python interpreter versions and different ways of installing the subject Python Package:
Trigger the Test Workflow on the CI server, by pushing a git commit to a remote branch (ie master on github).
Navigate to the CI Pipeline web interface (hosted on Github Actions) and inspect the build results!
License
Free software: Affero GNU General Public License v3.0
Notes
Currently, since the actual cookiecutter template does not reside on the root directory of the repository (but rather in src/cookiecutter_python), ‘cloning’ the repository locally is required at first.
This was demonstrated in the quickstart section, as well.
For more complex use cases, you can modify the Template and also leverage all of cookiecutter’s features, according to your needs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cookiecutter_python-0.7.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80278838b2bfbdbba3955af9befc4d24b3647593d5dd4e0781015e8195433eb3 |
|
MD5 | 682d3df595cb5eb953810c824c7a9dea |
|
BLAKE2b-256 | 5f106b8610f4c01efe0b5cb503facac656a77303a6f1f8bb9d2a9523e932ccf8 |
Hashes for cookiecutter_python-0.7.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3213c0ac6d0e47f092b565086237463151902831fb17a05f5169ccf68baa7b8 |
|
MD5 | 3c36b02daa5d435bcb8475d7e1f4df6b |
|
BLAKE2b-256 | d2b8067c00ff66b12fa1cb6edca36f5b3dcf121738272dba93159520851125bc |