Pack OpenSCAD includes into an efficient single file.
Project description
OpenSCAD Packer
Pack an OpenSCAD entry file and all its use/include dependencies into a single self-contained .scad file.
Instead of distributing a project as a directory tree of files (and requiring recipients to have the same libraries installed), OpenSCAD Packer bundles everything into one file. It uses tree-shaking to include only the functions and modules that are actually called — directly or transitively — so the output stays lean even when pulling from large libraries.
How it works
use <lib.scad>— the library is parsed and only the reachable function and module definitions are inlined. Variables and top-level calls are discarded (matching OpenSCAD's ownusesemantics).include <file.scad>— function and module definitions are tree-shaken into the output; top-level assignments and module calls are always preserved (they affect variables and rendered geometry).- Libraries that cannot be found cause an immediate error with a clear message. Pass extra search directories with
-Lif your libraries live outside the standard OpenSCAD path.
Installation
Requires Python 3.11+ and uv.
uv tool install openscad-packer
This installs the openscad-packer command globally via uv's tool isolation.
Alternatively, add it as a dependency in your own uv project:
uv add openscad-packer
Usage
openscad-packer pack [OPTIONS] INPUT
Arguments:
INPUT Entry .scad file to pack.
Options:
-o, --output PATH Output file. Defaults to stdout.
-L, --library-path PATH Extra library search directory (repeatable).
--help
Examples
Pack to a file:
openscad-packer pack my_model.scad -o my_model_packed.scad
Pack to stdout (useful for piping or inspection):
openscad-packer pack my_model.scad
Point to libraries that are not on the standard OpenSCAD path:
openscad-packer pack my_model.scad -o packed.scad -L ./vendor/BOSL2 -L ./vendor/NopSCADlib
Library search order
For each use/include path, the tool searches in this order:
- Directories supplied via
-L(in the order given) - The directory containing the file that references the library
- Directories in the
OPENSCADPATHenvironment variable - The platform default:
~/Documents/OpenSCAD/libraries
Developer guide
Prerequisites
- Python 3.11 or later
- uv — used for environment management and running the tool
Clone and set up
git clone https://github.com/NascentMaker/OpenSCAD-Packer.git
cd OpenSCAD-Packer
uv sync --dev
uv sync --dev creates a virtual environment at .venv/, installs all runtime dependencies, and installs the dev group (pytest, pytest-cov, coverage).
Note:
uv syncwithout--devomits the dev group and will not install pytest.
Run the CLI locally
uv run openscad-packer pack entry.scad -o packed.scad
Run the tests
uv run pytest
Branch coverage is enabled automatically. After the run, an HTML report is written to htmlcov/index.html.
To run a subset of tests:
uv run pytest -v -k "tree_shak"
Project structure
openscad_packer/
cli.py # click entry point — pack command
packer.py # Packer class: collect phase + assemble phase
shaker.py # AST walker, tree-shaking, reachability analysis
resolver.py # Library path resolution
tests/
conftest.py
test_cli.py
test_packer.py
test_resolver.py
test_shaker.py
Building a distribution
uv build
This produces a wheel and sdist in dist/. To publish to PyPI:
uv publish
License
OpenSCAD Packer is released under the GNU Affero General Public License v3.0.
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
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 openscad_packer-2026.6.1.tar.gz.
File metadata
- Download URL: openscad_packer-2026.6.1.tar.gz
- Upload date:
- Size: 40.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c41c2660690c6ae0dfc5c056e72bc2b4bdbdd24eefb86d1160dbd34293b2a01
|
|
| MD5 |
97182aca7388421d7cff29ee888edd94
|
|
| BLAKE2b-256 |
02ac28e00ecb861dbfb68e965236e3ee418c1609bd15541750a8b31206302997
|
Provenance
The following attestation bundles were made for openscad_packer-2026.6.1.tar.gz:
Publisher:
publish.yml on NascentMaker/OpenSCAD-Packer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openscad_packer-2026.6.1.tar.gz -
Subject digest:
9c41c2660690c6ae0dfc5c056e72bc2b4bdbdd24eefb86d1160dbd34293b2a01 - Sigstore transparency entry: 1715262620
- Sigstore integration time:
-
Permalink:
NascentMaker/OpenSCAD-Packer@a6118143662f9434954c6122e62822ca6b7c60f4 -
Branch / Tag:
refs/tags/v2026.6.1 - Owner: https://github.com/NascentMaker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a6118143662f9434954c6122e62822ca6b7c60f4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openscad_packer-2026.6.1-py3-none-any.whl.
File metadata
- Download URL: openscad_packer-2026.6.1-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
154c41cdbe8c2bb6afd1adf77ba718808eac1d1d3484590d536133380d72b55e
|
|
| MD5 |
751230903fdda0d25dede62e3875375e
|
|
| BLAKE2b-256 |
a8289bd4d914977a116a4fab52f157977332643dabb8fb83b82b4aa67e0557ca
|
Provenance
The following attestation bundles were made for openscad_packer-2026.6.1-py3-none-any.whl:
Publisher:
publish.yml on NascentMaker/OpenSCAD-Packer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openscad_packer-2026.6.1-py3-none-any.whl -
Subject digest:
154c41cdbe8c2bb6afd1adf77ba718808eac1d1d3484590d536133380d72b55e - Sigstore transparency entry: 1715262667
- Sigstore integration time:
-
Permalink:
NascentMaker/OpenSCAD-Packer@a6118143662f9434954c6122e62822ca6b7c60f4 -
Branch / Tag:
refs/tags/v2026.6.1 - Owner: https://github.com/NascentMaker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a6118143662f9434954c6122e62822ca6b7c60f4 -
Trigger Event:
push
-
Statement type: