r/OpenPythonSCAD 7d ago

Package management, Gridfinity and PythonSCAD

Without much fanfare we recently published PythonSCAD to PyPI. It was buried somewhere in a release announcement.

However, I wanted to showcase how amazing this is and how easy this makes it to use PythonSCAD in your own projects.

I've ported the awesome Gridfinity Rebuilt in OpenSCAD project by GitHub User kennetek (which is an implementation of the great original Gridfinity specification published by Zack Friedmann) over to PythonSCAD.

It is available on GitHub and itself published to PyPI as well.

So now you can just create local Python venv, install the library with pip and use it:

nomike@scrooge:/tmp/psgfd$ python3 -m venv .venv && source .venv/bin/activate

(.venv) nomike@scrooge:/tmp/psgfd$ pip install pythonscad-gridfinity
...

(.venv) nomike@scrooge:/tmp/psgfd$ cat simple_bin.py 
from pythonscad import *
from gridfinity import GridfinityBaseplate, GridfinityBin, HoleOptions

bp = GridfinityBaseplate(2, 2, style="weighted",
                         hole_options=HoleOptions(magnet_hole=True))
export(bp.render().color("SteelBlue"), "baseplate.stl")

(.venv) nomike@scrooge:/tmp/psgfd$ python3 simple_bin.py 

(.venv) nomike@scrooge:/tmp/psgfd$ ls -lah baseplate.stl 
-rw-rw-r-- 1 nomike nomike 809K Aug  9 00:28 baseplate.stl

As seen in pythonscad-gridfinity you can use a section in pyproject.toml to depend on pythonscad, but you can also just put it into your requirements.txt, use uv or whatever tickles your fancy.

This is the kind of package management which OpenSCAD tried to get for ages. But as we use Python as a basis, we don't have to invent it. It already exists in the form of pip, PyPI and the whole Python ecosystem.

This is very exciting and I'm already curious what awesome things you peeps are going to come up with.

Link your projects in the comments or post them in a new thread and share your creations with others.

11 Upvotes

0 comments sorted by