Various boilerplates used in almost all of my Python packages.
Project description
Various boilerplates used in almost all of my Python packages.
This package includes boilerplates for various common tasks in Python packages, such as building the package, testing the packaging process and storing the package config.
Requirements
Python version 3.8 or later.
Python libraries as specified in requirements.txt.
Building and running tests additionally requires packages listed in requirements_test.txt.
Tested on Linux, OS X and Windows.
Available boilerplates
Setup boilerplate
Module boilerplates.setup provides a class Package that abstracts out many of the common tasks needed to set up the package. The class has a setup() class method that can be called from the if __name__ == '__main__' block in your setup.py file.
To avoid setup script boilerplate, create setup.py file with the minimal contents as given below and modify it according to the specifics of your package.
See the implementation of boilerplates.setup.Package for all other available options. Some fields don’t need to be entered and will be automatically initialised using various detectors. Also, some fields have default values. See DEFAULT_* constants in the boilerplates.setup for those values.
Example setup.py:
"""Setup script."""
import boilerplates.setup
class Package(boilerplates.setup.Package):
"""Package metadata."""
name = ''
description = ''
url = 'https://github.com/mbdevpl/...'
author = '...'
author_email = '...'
classifiers = [
'Development Status :: 1 - Planning',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3 :: Only']
keywords = []
if __name__ == '__main__':
Package.setup()
You will also need the following in your pyproject.toml file:
[build-system]
requires = ['boilerplates[setup] ~= 0.1']
Packaging tests
As an extension of setup boilerplate, there’s an extra boilerplate for testing the packaging process, in a way that enables 100% code coverage, including the setup.py script.
In order to use it, all you need to do is create a file as follows in your tests directory.
Example test/test_packaging.py:
"""Tests for packaging."""
import boilerplates.packaging_tests
class Tests(boilerplates.packaging_tests.PackagingTests):
pass
And, you will need to add the following to your requirements_test.txt file (or equivalent):
boilerplates[packaging_tests] ~= 0.1
Config boilerplate
Module boilerplates.config provides few utility functions useful to handle local configuration.
Example usage:
import boilerplates.config
...
boilerplates.config.initialize_config_directory('app_name')
And, you will need to add the following to your requirements.txt file (or equivalent):
boilerplates[config] ~= 0.2
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 boilerplates-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | faa0eb164c688dd616184d9760a3f2a94ea16750431eb6c66a5bf4f30598de80 |
|
MD5 | 8c5ce736da81accb61dd82e140a6fac3 |
|
BLAKE2b-256 | bfd8db93a31f5e1786df871104bb2c65ea88089017b4c138b71354fdb3ae0b2b |