Skip to main content

KupCAD for Python

Builds the model of a KupCAD script, with its parameters, as STL, 3MF, glTF, OBJ, STEP, SVG or DXF, and formats, lints and reads the parameters of scripts. It runs libkupcad, the KupCAD core as a C library, in your process: nothing to install besides the package, which has no dependencies.

pip install kupcad
from pathlib import Path

import kupcad

source = Path("bracket.kup").read_text(encoding="utf-8")
model = kupcad.build(source, format="stl", params={"width": 60, "label": "A"})
Path("bracket.stl").write_bytes(model.data)
print(model.report.output)  # what the script printed
for warning in model.report.warnings:
    print(f"{warning.line}: {warning.message}")

What it does

  • kupcad.build(source, *, format, params, files, memory_limit, timeout, draco) runs the script and returns a kupcad.Model: its data (bytes) in the format (one of kupcad.FORMATS, the library's: stl, 3mf, glb, gltf, obj, step, svg, dxf), and the run's report, what the script printed and the kupcad.RunWarnings it warned of, where.
    • params: the parameters' values by name, as kupcad build -p takes them: {"width": 60, "thread": "m4", "holes": [[5, 5], [35, 5]]}. Values are checked against each parameter's rules.
    • files: the files the script imports, by their path from its folder (a str, or a Path by its forward slashes), text or bytes: {"lib/gears.kup": Path("lib/gears.kup").read_text(encoding="utf-8"), "a.ttf": font}. A script reads no other file, and its exports (export_stl) write nothing.
    • memory_limit: the most memory, in bytes, the script may hold: its values and its geometry graph, not the kernel's meshes; no limit by default.
    • timeout: the most time, in seconds, the build may take, to the millisecond; no limit by default (or math.inf). A script that never ends otherwise holds its thread for good: a native call can't be interrupted, by Ctrl-C or a signal, which are raised once it returns.
    • draco=True compresses a GLB's or a glTF's meshes.
  • kupcad.format(source): the source as kupcad fmt formats it.
  • kupcad.check(source): what kupcad check finds, a list of kupcad.Finding (severity, rule, message, where, and the fix if there is one). Syntax errors are findings here.
  • kupcad.params(source): the parameters the script declares and its metadata, the schema kupcad doc prints, to build a form from.
  • kupcad.library_version(): the version of libkupcad loaded.

Errors

  • kupcad.ScriptError (a kupcad.Error) when the script doesn't parse or compile, raises, runs past its timeout or memory_limit, or leaves no model. A value one of its parameters refuses is one too: the script raises ValueError at the param that refuses it. The message says where and why ("2:5: Invalid expression ...", "RuntimeError: Plate too thin"), and its report holds what the script printed until then.
  • ValueError for a format that isn't one, a limit that isn't positive, or parameter values JSON can't hold (NaN) or that aren't by name (a list); TypeError for values JSON has no type for (a set), or a source or a file that isn't text or bytes.
  • MemoryError when the process itself runs out of memory, and kupcad.Error itself when libkupcad fails on its own, a bug of KupCAD's.

Threads and processes

A build releases the GIL while it runs, so other threads go on, and builds on several threads run at once: libkupcad's calls share nothing. A process may fork between builds (gunicorn's --preload, multiprocessing's fork), whatever threads built before: the last build to end ends the worker threads the builds started, and each process starts its own; but not while a build runs on another thread. The core runs in your process, so a bug it stops on stops the process too. To run scripts you don't trust, or keep a crash away from a web server, run the kupcad CLI as a process of its own.

Platforms

Each wheel carries its libkupcad: Linux (x86_64, aarch64; glibc 2.28 or later), macOS 15 or later (arm64, x86_64) and Windows (x64, arm64), for any Python from 3.10, with THIRD_PARTY_NOTICES.md and the license texts of what it is built from beside it, in the kupcad package; each is attested as built by the kupcad repository's release from its tag, on PyPI and on GitHub (gh attestation verify <wheel> --repo kupcad/kupcad). Elsewhere (musl, BSD), build libkupcad with zig build lib in the kupcad repository's core/ and a wheel with it, as the Development section says.

Development

In the kupcad repository:

(cd core && zig build lib -Doptimize=safe)    # core/zig-out/lib/libkupcad.*
cd bindings/python
python -m venv .venv
.venv/bin/pip install -e . --group dev
.venv/bin/pytest                              # on the checkout's libkupcad
.venv/bin/ruff check && .venv/bin/ruff format --check && .venv/bin/mypy

A wheel carries the library it is built with, and the notices core/scripts/collect-licenses.sh <the library's folder> (run from the repository root) puts beside it: KUPCAD_LIBRARY=<library> KUPCAD_WHEEL_PLATFORM=<platform tag> python -m build --wheel --no-isolation, with the dev group's build and hatchling, as the release builds one for each platform (a relative KUPCAD_LIBRARY is from bindings/python/).

Metadata

Release files for kupcad 0.1.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for kupcad 0.1.14
File Actions
kupcad-0.1.14-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for kupcad-0.1.14-py3-none-win_arm64.whl
kupcad-0.1.14-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for kupcad-0.1.14-py3-none-win_amd64.whl
kupcad-0.1.14-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for kupcad-0.1.14-py3-none-manylinux_2_28_x86_64.whl
kupcad-0.1.14-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for kupcad-0.1.14-py3-none-manylinux_2_28_aarch64.whl
kupcad-0.1.14-py3-none-macosx_15_0_x86_64.whl Python 3 none macOS 15.0+ x86-64 Details for kupcad-0.1.14-py3-none-macosx_15_0_x86_64.whl
kupcad-0.1.14-py3-none-macosx_15_0_arm64.whl Python 3 none macOS 15.0+ ARM64 Details for kupcad-0.1.14-py3-none-macosx_15_0_arm64.whl

Total release size: 29.0 MB

Release files / kupcad-0.1.14-py3-none-win_arm64.whl

Download URL kupcad-0.1.14-py3-none-win_arm64.whl
Size 4.7 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
0415c36d772a14d6e3dfb1d31859160794d199c39656af9049f4ecc8b59f8b36
BLAKE2b-256 checksum
How to use checksums
5a0d35491eae12ad74a9e101caa78e1bb5cc061a7e47aa9d5b62aa5085ef8646
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 Nov 28, 2026.

Transparency log

Release files / kupcad-0.1.14-py3-none-win_amd64.whl

Download URL kupcad-0.1.14-py3-none-win_amd64.whl
Size 5.2 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
ce391e03c0860d1535e9e519018683b798fead60cdfd23c8a8787efe5c9032e4
BLAKE2b-256 checksum
How to use checksums
9abc6191d5fdbc5f28c2f14817658da1e8f61b33bc696a2b81510ceee53fcec3
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 Nov 28, 2026.

Transparency log

Release files / kupcad-0.1.14-py3-none-manylinux_2_28_x86_64.whl

Download URL kupcad-0.1.14-py3-none-manylinux_2_28_x86_64.whl
Size 5.2 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
361a5ccd81f86a5a54364b00105e2ee75445d579e238672552247a2ab31f1dee
BLAKE2b-256 checksum
How to use checksums
208ec966d0545ba4596cd9e98da656e180bce62f884b614d42393bce0fb4ceeb
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 Nov 28, 2026.

Transparency log

Release files / kupcad-0.1.14-py3-none-manylinux_2_28_aarch64.whl

Download URL kupcad-0.1.14-py3-none-manylinux_2_28_aarch64.whl
Size 4.8 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
06c63aa11c6ddbbecac91fcc5ceed3f526de766ca2a1ea1cb3f4e07d14e11770
BLAKE2b-256 checksum
How to use checksums
df1cbc4b1eaf4b5964d1d7cf7fb7b644c2b0dbd50c4cd2538b0616e219190b90
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 Nov 28, 2026.

Transparency log

Release files / kupcad-0.1.14-py3-none-macosx_15_0_x86_64.whl

Download URL kupcad-0.1.14-py3-none-macosx_15_0_x86_64.whl
Size 4.8 MB
Tags Python 3 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
391bc41ecced4a00d66818a7c0878283ce2ae0a0a91f0caef80d1f4515fa51b0
BLAKE2b-256 checksum
How to use checksums
c0f8ed1254a635dc29930af8f6a9ba7f4f38f1f7fbb09a0cb56e9a6f1b1b1600
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 Nov 28, 2026.

Transparency log

Release files / kupcad-0.1.14-py3-none-macosx_15_0_arm64.whl

Download URL kupcad-0.1.14-py3-none-macosx_15_0_arm64.whl
Size 4.4 MB
Tags Python 3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
cf6844f1c8883b069b76e4bed3d23a4f54dfc16865c62683ae583c5b5efc51e3
BLAKE2b-256 checksum
How to use checksums
fd76ee3ee2e3850ecea6b7d681f4891d9b8a0fe846fc6d1d292c226150d93195
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 Nov 28, 2026.

Transparency log

Security for kupcad 0.1.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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for kupcad-0.1.14-py3-none-win_arm64.whl

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 Nov 28, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page