Python Build Simplified. A simple setuptools automation, designed mainly for publishing multiple packages from single repository
Project description
Python Build Simplified
Lighter alternative to PBR. Created to support easily multiple namespace packages built from single repository. Ultra simple, allows to have almost empty setup.py file, while keeping all information in setup.json
Optionally integrates with Pipfile.lock which means you can stop using requirements.txt and use fully reproducible builds on production without doing pip freeze manually
Features:
- External dependencies in
requirements-external.txt
- Internal dependencies (packages from same repository) in
requirements-subpackages.txt
- All arguments that goes to setup() are placed as dictionary in
setup.json
file, there is no magic there - README.md and README.rst (in order) are loaded automatically as long description
- Uses SCM plugin (setuptools_scm) by default
- Optional Pipfile.lock from Pipenv support
- Command
./setup.py --quiet freeze_dependencies
to print dependencies in requirements.txt format - Command
./setup.py install_dependencies
to install dependencies using pip
Getting started
project.toml
Needs to be configured, so the pip and pipenv would know the dependencies to run setup.py file
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0", "riotkit.pbs>=1.0"]
setup.py
The usage of PBS is really simple, import and unpack a dictionary. Optionally override values as you wish - there is no magic, everything is passed explicitly, so you can print it or pass to setup()
#!/usr/bin/env python3
from setuptools import setup
from riotkit.pbs import get_setup_attributes
# advanced usage: override any attribute
attributes = get_setup_attributes(git_root_dir='../../')
attributes['long_description'] += "\nBuilt using Riotkit Python Build Simplified"
setup(
**attributes
)
setup.json
Again, there is no any magic. Every key there is an attribute that should go to setup() from setuptools. Please look at setuptools documentation for list of available attributes, you can find it there: https://setuptools.readthedocs.io/en/latest/references/keywords.html
{
"name": "rkd.process",
"author": "RiotKit non-profit organization",
"author_email": "riotkit@riseup.net",
"description": "rkd.process provides easy process interaction and output capturing/redirecting, wraps subprocess from Python's standard library.",
"url": "https://github.com/riotkit-org",
"license": "Apache-2",
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX",
"Programming Language :: Python :: 3 :: Only"
],
"keywords": ["rkd", "riotkit", "anarchism", "output capturing", "output", "subprocess"]
}
requirements-external.txt
It's a regular requirements.txt
replacement, with all versions there.
some-package>=1.0
MANIFEST.in
Points out which files should be included in a distribution package.
recursive-exclude tests *
recursive-exclude example *
include requirements-external.txt
include requirements-subpackages.txt
include setup.json
Additional work to do in multiple-package repository
Multiple-package repositories are used to keep versioning in synchronization for multiple packages. Some of packages could be dependent on each other, but possible to install standalone.
See real use case: https://github.com/riotkit-org/riotkit-do/tree/master/src/core
requirements-subpackages.txt
A dynamic version of requirements.txt
, where a simple templating mechanism is available to allow
creating dependencies to packages that are released together with current package from same repository.
rkd.process >= {{ current_version }}, < {{ next_minor_version }}
Available variables:
- current_version: Example 1.3.1.2
- next_minor_version: Example 1.4
- next_major_version: Example 2.0
Pipenv support
Pipenv support could be optionally enabled. In this case all standard dependencies from Pipfile.lock
would be frozen
and added to install_requires
automatically.
setup.py
#!/usr/bin/env python3
from setuptools import setup
from riotkit.pbs import get_setup_attributes
setup(
**get_setup_attributes(pipenv=True)
)
Debugging
PBS is not performing any magic inside, so there is a possibility to just print the attributes that would be used in setup()
setup.py
#!/usr/bin/env python3
from setuptools import setup
from riotkit.pbs import get_setup_attributes
import pprint
attributes = get_setup_attributes(git_root_dir='../../')
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(attributes)
# setup(
# **attributes
# )
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
File details
Details for the file riotkit.pbs-1.0.tar.gz
.
File metadata
- Download URL: riotkit.pbs-1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0878cfc93dcdf01f3853c88185f7441c8a2e2a715532fa8b82688f8aef29b980 |
|
MD5 | b1f996cc07512473856747df281d2325 |
|
BLAKE2b-256 | b62e3e84f8f4109700e2de03d6e0318fc08879c652c0f6adca2ce41b6dc504d9 |