Skip to main content

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 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

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 pybosl2.shapes3d as s3
import pybosl2.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
                              # pybosl2/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 (set PYTHONSCAD_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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybosl2-0.6.4.tar.gz (412.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybosl2-0.6.4-py3-none-any.whl (356.2 kB view details)

Uploaded Python 3

File details

Details for the file pybosl2-0.6.4.tar.gz.

File metadata

  • Download URL: pybosl2-0.6.4.tar.gz
  • Upload date:
  • Size: 412.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pybosl2-0.6.4.tar.gz
Algorithm Hash digest
SHA256 aa91037159a81986eb64b8019226a03ff00acfcdf91199d6ca97498d9921c184
MD5 8ba7b4522dcf81ba852e13b118fb246b
BLAKE2b-256 725294d2fd21c921487e8afbe31459d703558c527e60d1bf46af2cbe4154ac0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybosl2-0.6.4.tar.gz:

Publisher: release.yml on pinkfish/pybosl2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybosl2-0.6.4-py3-none-any.whl.

File metadata

  • Download URL: pybosl2-0.6.4-py3-none-any.whl
  • Upload date:
  • Size: 356.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pybosl2-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ead6671cd54e02f4c3348443fd14a6faa3e68bde2793d74a101aedf60ef445a0
MD5 1ddb7d370069fade347d61cc97c812e4
BLAKE2b-256 8f01e2d19c08cb2a6bdde68b7bb46c0c5ed6b0b4ca3302dff0a75c85f1aa3fb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybosl2-0.6.4-py3-none-any.whl:

Publisher: release.yml on pinkfish/pybosl2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page