lostapathy / scad_bundler

A package manager for OpenSCAD powered by RubyGems
MIT License
15 stars 1 forks source link

scad_bundler

scad_bundler is a package manager for OpenSCAD. It's based on RubyGems and uses Bundler under the hood.

scad_bundler is a fully-featured package manager that:

Installation

You will need to have Ruby and RubyGems installed to use scad_bundler.

Once RubyGems is installed, install scad_bundler:

$ gem install scad_bundler

Usage

See this repo for an example project using scad_bundler.

Similar to how bundler works, scad_bundler dependencies are defined in a Scadfile and resolved versions are locked in a Scadfile.lock. To initialize your project and create and empty Scadfile

$ scad_bundle init

Dependencies can be declared inside your scadfile using bundler's full capabilities for a Gemfile. FIXME: add a simple example, and go into how version constraints work.

Once your dependencies have been listed, you can install them via:

$ scad_bundle install

scad_bundler will then work out compatible versions of the libraries and install them on your system. Then to fire up OpenSCAD:

$ scad_bundle exec openscad

scad_bundler will then start openscad with the OPENSCADPATH environment set properly to use all of your libraries.

To upgrade libraries, simple call:

$ scad_bundle update

Conventions and Best Practices for creating OpenSCAD Libraries

scad_bundler packages are packaged using a subset of features from RubyGems. Any documentation related to RubyGems can be used to create these libraries. Since we only use a subset of the functionality, it's probably easiest to copy the .gemspec file from an existing library like openscad_soften and modify from there. TODO: create a simple command like scad_bundle new to create a skeleton file.

Your package do not have to be published to rubygems.org in order to use them with scad_bundler. scad_bundler can also use packages from GitHub, local filesystem locations, or anywhere else supported by bundler.

(Draft) Conventions

Motivation

The motivation for scad_bundler is simple - create a first-class package manager for OpenSCAD to help advance the entire OpenSCAD ecosystem.

Having a package manager is an essential feature of modern languages, and OpenSCAD should be no different. A really solid package manager will allow us to build up components and utilities to simplify designs, so that users need not choose between starting at zero and manually wrangling files from Thingiverse. Having this base of knowledge will also help the OpenSCAD community to better identify and codify best practices for sharing code and designing models.

That package manager needs to support versioning and version constraints, so that packages can evolve over time and ship breaking changes rather than stagnate on the first API to coalesce.

Many OpenSCAD project sit dormant for a long time, then get revisited to fix or upgrade a part. Because of this, it's important that scad_bundler tracks library versions per-project, and different projects on your system can use different library versions. This removes the need to incorporate every library change into your project. This means we're free to improve and evolve our libraries over time, without worry about breaking existing code - that existing code can continue to use the same version of the library until we're ready to upgrade it.

It is my hope that building this knowledge base will also help the community hash out common problems "in userspace" either completely or substantially, so that the scope of changes proposed for OpenSCAD itself can be smaller, more focused, and better tested than many proposals that come up now.

FAQ

Why build on RubyGems and bundler?

RubyGems and bundler are a very stable base to build upon, and include very advanced support for specifying compatible library versions and then resolving those dependencies. Using this foundation is much more expedient than starting from scratch.

Why host openscad packages on rubygems.org?

Hosting a package repository is hard work and very security intensive. Using another open source project's repository get us going from day one, and frees us from all of the infrastructure and security headaches hosting our own would entail. If you don't want to post your package as a gem on rubygems.org, it's perfectly fine to post it on github and direct people to use that. Long term, it would be ideal to host a separate package repository but there's nothing wrong with starting out like this.

Why pass library information via an environment variable?

The initial goal of scad_bundler was to create a package manager that worked without requiring any modifications to OpenSCAD. Long-term, we would love to integrate more tightly with OpenSCAD, but this absolutely works for now.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lostapathy/scad_bundler.

TODO

License

The gem is available as open source under the terms of the MIT License.