pybosl2
Python ports of the BOSL2 OpenSCAD library,
for use with PythonSCAD. The package is imported as
pybosl2, with one module per wrapped/ported .scad file so each Python module can
be read side by side with its OpenSCAD source.
Most modules (constants, math, vectors, paths, shapes2d, …) are standalone pure-Python
ports that work in plain CPython. The modules that build native geometry
(shapes3d, masking, and the .polygon()/.polyhedron() boundaries) import the
pythonscad/openscad native modules at load time.
Reference
- Getting started — build one part end to end: solid, roundover, bore, boss, measurement, exported file
- Docs
- Specs of the various parts
- SPEC.md — what the system is and does, and the contracts it honours
(generated from spec/requirements.toml by
docs/_reqgen.py) - PLAN.md — how that is implemented in Python (typing, classes, docs, tests)
- TASKS.md — the ordered queue of conformance work
Installation
pip install pybosl2
This pulls in numpy. To build native geometry you also need PythonSCAD:
pip install pythonscad
Usage
Import by submodule (the square/circle/cube/text names intentionally shadow
the plain OpenSCAD builtins with BOSL2's anchor/spin/orient-aware versions, so the
package is deliberately not wildcard-re-exported):
from pybosl2 import Anchor, cuboid, cyl
part = cuboid([60, 40, 12], rounding=4, edges=Anchor.Z) - cyl(diameter=10, height=20)
print(part.bounds().size) # (60.0, 40.0, 12.0)
part.export("bracket.stl") # .stl / .obj / .off / .ply, no CAD runtime needed
part.show()
Booleans are operators (-, |, &), every operation returns a new shape so calls chain, and
bounds() measures without rendering. See Getting
started for the guided version.
Development & tests
Start with SPEC.md, then PLAN.md. Both are normative: the spec says what
the system does and which contracts it honours, the plan says how that is written in Python
(typing, class design, docstrings, errors, tests). Requirements are numbered and permanent — cite
them with their document (SPEC-P-1, PLAN-T-2) in reviews and commit bodies, since five prefixes
mean different things in the two. TASKS.md is the ordered queue of open
conformance work, CONFORMANCE.md is the history of what has closed, and
AGENTS.md is the one-page index.
SPEC.md and PLAN.md are generated: edit spec/requirements.toml for a requirement or the
frames in spec/ for prose, then run python docs/_reqgen.py.
Before a change is done, all of these must pass:
export TMPDIR=/path/with/room # test scratch; a full run can fill a small system disk
pytest # STL-render tests skip without the app
mypy --strict pybosl2
ruff check . --fix && ruff format .
The test-suite runs against a real, pip-installed pythonscad in a virtualenv:
python -m venv .venv # create from outside the repo dir, or the local
# pybosl2/math.py etc. can shadow stdlib modules
source .venv/bin/activate
pip install -e '.[test]' # pybosl2 + pytest + numpy + pythonscad + mypy
pytest
The [test] extra installs the pythonscad wheel, which provides the real
pythonscad/openscad native modules the geometry code imports.
A small number of tests exercise the full PythonSCAD app rather than the pip wheel:
- STL-render tests (
tests/test_stl_render.py) drive the real PythonSCAD binary in a subprocess to export and measure meshes. They skip unless a binary is found (setPYTHONSCAD_BIN, or install the app to/Applications). - App-only native ops (e.g.
roof()) skip when the pip wheel does not provide them.
Documentation
The API docs are built with Sphinx (autodoc + napoleon) straight from the module docstrings:
pip install -e '.[docs]'
make -C docs html # renders into wiki/
On push to main, the docs GitHub Actions workflow builds and publishes them to
GitHub Pages (enable Pages with Settings → Pages → Source: GitHub Actions).
Examples in the docs embed interactive 3-D STL viewers; the renders are cached under
docs/_generated/ and docs/_extra/_stl/ — commit those caches so the images appear
on Pages, since CI has no PythonSCAD binary to render them.
License
BSD 2-Clause License — see LICENSE.
Metadata
Release files for pybosl2 0.7.13
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 |
|---|---|---|---|---|
| pybosl2-0.7.13.tar.gz | 1.0 MB | With provenance | Details for pybosl2-0.7.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pybosl2-0.7.13-py3-none-any.whl | Python 3 | none | any | Details for pybosl2-0.7.13-py3-none-any.whl |
Total release size: 1.7 MB
Release files / pybosl2-0.7.13.tar.gz
| Download URL | pybosl2-0.7.13.tar.gz |
|---|---|
| Size | 1.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2428392464cc2c9be2d2a45c1cb2716afe8a115e1298208e391ce8d5de6866e
|
|
BLAKE2b-256 checksum How to use checksums |
e6d9b276a1bd833226449f26eeb94d523cd9c74daf2550b34dd35fa1f50f3372
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 4, 2026.
Transparency logRelease files / pybosl2-0.7.13-py3-none-any.whl
| Download URL | pybosl2-0.7.13-py3-none-any.whl |
|---|---|
| Size | 677.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e71da10d7222ea3b8389391bb6f3ce73e555c48466bf4e8a3391269144454fe0
|
|
BLAKE2b-256 checksum How to use checksums |
fb78af442eaf23368bc4ccddcc667021bb2e0425666bd6197ff499d8c1e37271
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 4, 2026.
Transparency logSecurity for pybosl2 0.7.13
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
Both files in this release have been uploaded with provenance metadata.
Attestation for pybosl2-0.7.13.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 Sep 4, 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.