ym-handcalcs
Render handcalcs calculations in YMPrint documents.
ym-handcalcs is a handcalcs renderer that produces ReportLab flowables, plus the _hc
block that puts them in a YMPrint document: write Python, get typeset calculations
with symbolic, substituted and computed values.
Installation
Install it with YMPrint's hc extra:
pip install "ymprint[hc]"
ym-handcalcs needs handcalcs 2.0, which is currently a pre-release. pip installs it
automatically; uv only installs a pre-release you name, so add it with --with:
uv tool install "ymprint[hc]" --with "handcalcs>=2.0.0rc1"
YMPrint registers the _hc block automatically when ym-handcalcs is installed.
The _hc block
_vars:
w_DL: 2.5
w_LL: 4.0
Beam design:
- _hc: |
## Factored load
L = 6.0 # span, m
w_f = 1.25 * w_DL + 1.5 * w_LL
M_f = w_f * L**2 / 8
- The factored moment is {{ M_f }} kN·m.
The source runs in the document's _vars, like a _py block: it can use values from
_vars and earlier blocks, and later blocks (and {{ }} interpolation) can use its
results. As in handcalcs, ## ... comments are headings, # ... comments are prose,
inline comments annotate their line, and # hc: commands work as usual.
The value is either the source as a string, or a mapping:
| Option | Default | Meaning |
|---|---|---|
source |
(required) | The Python source to run and render. |
theme_color |
"#0B5F66" |
A dark #RRGGBB colour; the whole palette is derived from it. |
base_size |
the document's body text size | Font size, in points, that every calc style scales from. |
Give a block an id to use it more than once in a mapping: _hc_loads, _hc_moment.
Using the renderer directly
The renderer works without YMPrint. It returns a ReportLab stylesheet and a story:
from handcalcs import HandCalcs
from ym_handcalcs import ReportLabRenderer, build_pdf
from ym_handcalcs.fonts import ensure_dejavu_registered
ensure_dejavu_registered() # YMPrint registers the DejaVu fonts itself
result = HandCalcs(renderer=ReportLabRenderer(theme_color="#7A1F1F"))("a = 2\nb = a * 3\n")
result["story"] # list of flowables
build_pdf(result, "calcs.pdf", title="Calcs")
# or straight to a PDF
HandCalcs(renderer=ReportLabRenderer())("a = 2\nb = a * 3\n", destination="calcs.pdf")
Development
uv sync
uv run pytest
Regenerate the golden files with HANDCALCS_UPDATE_GOLDEN=1 uv run pytest and review the diff.
License
Apache-2.0. See LICENSE.
Metadata
Release files for ym-handcalcs 0.1.0
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 | |
|---|---|---|---|---|
| ym_handcalcs-0.1.0.tar.gz | 34.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ym_handcalcs-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 72.1 kB
Release files / ym_handcalcs-0.1.0.tar.gz
| Download URL | ym_handcalcs-0.1.0.tar.gz |
|---|---|
| Size | 34.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16fc712e254a2aac45db5c582852ba14f8b8af9ecdf8ad38c1f71f239be63141
|
|
BLAKE2b-256 checksum How to use checksums |
4695eb73604b3cb8516f3050b9b9412839e56e8a928bfe0943f69e5de08b72cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logRelease files / ym_handcalcs-0.1.0-py3-none-any.whl
| Download URL | ym_handcalcs-0.1.0-py3-none-any.whl |
|---|---|
| Size | 37.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b79f85d6608107db133eabb63514efbb25620dddd4e30acba7f94f265e6d4d8
|
|
BLAKE2b-256 checksum How to use checksums |
ce285553c4477d6889d959fe50c6b4b818efd9b8b9ff22953fa678204442015c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logSecurity for ym-handcalcs 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ym_handcalcs-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logA 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.