Python ports of the BOSL2 OpenSCAD library for use with PythonSCAD
Project description
pybosl2
Python ports of the BOSL2 OpenSCAD library,
for use with PythonSCAD. The package is imported as
bosl2, 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
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):
import bosl2.shapes3d as s3
import bosl2.shapes2d as s2
part = s3.cuboid([20, 20, 10]).up(5)
Development & tests
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
# bosl2/math.py etc. can shadow stdlib modules
source .venv/bin/activate
pip install -e '.[test]' # installs pybosl2 + pytest + numpy + pythonscad
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.
pysolidfive (bundled separate package)
The repo also vendors pysolidfive — a small, self-contained
libfive / signed-distance-function shape library for PythonSCAD. It is a separate
piece: it does not depend on bosl2, ships in the same wheel as its own top-level
pysolidfive package, and keeps its own tests, docs, and pyproject.toml.
Its test-suite runs against the numeric mock_libfive stand-in bundled in
pysolidfive/tests, so it needs only numpy (no pythonscad wheel). It uses
unittest rather than pytest — the package eagerly import libfives at load, which
is incompatible with pytest's package-based collection:
cd pysolidfive/tests
python -m unittest discover -s . -t .
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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybosl2-0.6.3.tar.gz.
File metadata
- Download URL: pybosl2-0.6.3.tar.gz
- Upload date:
- Size: 464.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
599bdeb33c77ebd7caa6d20db80bbba9d5cb8773439776923b256d023d417f47
|
|
| MD5 |
eeef598b52ac5cfb62558be2b6dd4dd7
|
|
| BLAKE2b-256 |
cf1b723b187d8735c7fc594439df4e86ff9745be75f2e07249e82e43ed92a318
|
Provenance
The following attestation bundles were made for pybosl2-0.6.3.tar.gz:
Publisher:
release.yml on pinkfish/pybosl2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybosl2-0.6.3.tar.gz -
Subject digest:
599bdeb33c77ebd7caa6d20db80bbba9d5cb8773439776923b256d023d417f47 - Sigstore transparency entry: 2259131072
- Sigstore integration time:
-
Permalink:
pinkfish/pybosl2@e41e9727f25448386c4f6ab0422d170be99544a0 -
Branch / Tag:
refs/tags/v0.6.3 - Owner: https://github.com/pinkfish
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e41e9727f25448386c4f6ab0422d170be99544a0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pybosl2-0.6.3-py3-none-any.whl.
File metadata
- Download URL: pybosl2-0.6.3-py3-none-any.whl
- Upload date:
- Size: 437.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52b2bf0e6c187fcd142a1a05c303015cd720f14fcea563335b783c045caae4ef
|
|
| MD5 |
7ef195daf89530febf907f7ebdfff85b
|
|
| BLAKE2b-256 |
fb245f75a6bc242803c53e8122fd04119cbe9727870c364ad13201385840a70b
|
Provenance
The following attestation bundles were made for pybosl2-0.6.3-py3-none-any.whl:
Publisher:
release.yml on pinkfish/pybosl2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybosl2-0.6.3-py3-none-any.whl -
Subject digest:
52b2bf0e6c187fcd142a1a05c303015cd720f14fcea563335b783c045caae4ef - Sigstore transparency entry: 2259131113
- Sigstore integration time:
-
Permalink:
pinkfish/pybosl2@e41e9727f25448386c4f6ab0422d170be99544a0 -
Branch / Tag:
refs/tags/v0.6.3 - Owner: https://github.com/pinkfish
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e41e9727f25448386c4f6ab0422d170be99544a0 -
Trigger Event:
release
-
Statement type: