whey-mixin
A plugin for Whey build system to add simple build steps
Usage
First, reassign your Whey builders to be handled by mixin. The following are supported, use as many or as few as you like.
[tool.whey.builders]
sdist = "whey_mixin_sdist"
wheel = "whey_mixin_wheel"
binary = "whey_mixin_binary"
exe = "whey_mixin_exe"
dmg = "whey_mixin_dmg"
deb = "whey_mixin_deb"
rpm = "whey_mixin_rpm"
Next, make the code for your hooks. We will place ours in a build_hooks.py file in the root directory of our project.
from whey.mixin import BuilderMixin
def build_messages(self: BuilderMixin):
# This makes Babel a build dep
from babel.messages.mofile import write_mo
from babel.messages.pofile import read_po
# pkgdir is the base folder for your module, constructed from
# the root folder, tool.whey.source-dir, and tool.whey.package
locales = self.pkgdir / "locales"
if self.verbose:
print(" Building messages")
# Find all .po files for all languages
for po in locales.glob("*/LC_MESSAGES/*.po"):
with po.open("rt", encoding="UTF-8") as f:
# po.parts[-3] extracts the language part of the path
# po.stem is the domain
catalog = read_po(f, po.parts[-3], po.stem)
# Here we construct the path relative to the build directory
# (/build by default). Be sure to create the subdirs!
mo = self.build_dir / po.relative_to(self.project_dir).with_suffix(".mo")
mo.parent.maybe_make(parents=True)
with mo.open("wb") as f:
write_mo(f, catalog)
# This reports to Whey they we've written a file, so that
# it will include it in the final package
self.report_written(mo)
if self.verbose:
print(" Wrote language file:", mo)
Next, configure whey-mixin itself. You can supply global or builder-specific hooks. You may also specify the base class to use per builder. By default, it uses Whey's default SDistBuilder for sdist, and its WheelBuilder for wheel and binary; there is no default for anything else, so those must be specified.
Make sure to add any dependencies into you build deps
[build-system]
requires = ["whey", "whey-mixin", "Babel"]
build-backend = "whey"
[tool.whey.mixin]
hooks = [
"build_hooks:build_messages"
]
[tool.whey.mixin.exe]
class = "my_builders:ExeBuilder"
hooks = []
Both hooks and class are entry points which specify the function or class to load, respectively. For use with this system, they will generally be relative to the root directory of your project. However, that's not required, and they can be from other modules as well.
Hooks specified in tool.whey.mixin run before build-specific hooks. They will run for every mixin builder, so if you don't want that, you will have to put the hook in individual build configs.
If a module defines its own named entry point that you wish to add hooks to, you may use the key entry-point instead of class to specify the entry point name.
Metadata
Release files for whey-mixin 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| whey_mixin-0.1.3.tar.gz | 4.3 kB | Without provenance | Details for whey_mixin-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| whey_mixin-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for whey_mixin-0.1.3-py3-none-any.whl |
Total release size: 14.9 kB
Release files / whey_mixin-0.1.3.tar.gz
| Download URL | whey_mixin-0.1.3.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff74e7c56f5bee2047cdb90de84c38ccf3e70b170d267b8277a8c625e12e07a7
|
|
BLAKE2b-256 checksum How to use checksums |
f1443fd9cabad6786aeb8970b1e26cc1c9b3112cf2ffbd8af982bac52d90a56f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.10
|
Release files / whey_mixin-0.1.3-py3-none-any.whl
| Download URL | whey_mixin-0.1.3-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d626b915841a53af7a9256129dd4d285bfcdbf8d4576a78418523c739fbd94e5
|
|
BLAKE2b-256 checksum How to use checksums |
2403a29398c30854265eb282b67c266038cce654a83ec618bf196ae5c1d23a4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.10
|
Security for whey-mixin 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.