bagit-gython is an experimental library that wraps bagit-python using an embedded modern Python interpreter. Its goal is to make Python's battle-tested implementation available to the Go ecosystem, avoiding the need to reimplement it from scratch. By leveraging Python's well-tested version, bagit-gython benefits from the extensive community of users and the robustness of the existing implementation.
It depends on go-embed-python, a CGO-free library that provides an embedded distribution of Python compatible with a number of architecture and operative systems.
Using bagit-python is easy. First, use go get
to install the latest version
of the library.
go get -u github.com/artefactual-labs/bagit-gython
Next, include bagit-gython in your application:
import "github.com/artefactual-labs/bagit-gython"
Check out example
, a small program that imports bagit-python to validate a
bag:
$ go run ./example/ -validate /tmp/invalid-bag/
Validation failed: invalid: Payload-Oxum validation failed. Expected 1 files and 0 bytes but found 2 files and 0 bytesexit status 1
$ go run ./example/ -validate /tmp/valid-bag/
Valid!
- darwin-amd64
- darwin-arm64
- linux-amd64
- linux-arm64
- windows-amd64
These are the platform-architecture combinations for which go-embed-python provides compatibility.
The specific version of bagit-python used by this project is specified in the
internal/dist/requirements.txt
file. Instead of using the latest official
release, we are using a commit from the main branch that includes compatibility
fixes for recent Python releases. This commit has not yet been included in an
official release.
- bagit-python project: https://github.com/LibraryOfCongress/bagit-python
- go-embed-python project: https://github.com/kluctl/go-embed-python
Apache 2.0. See LICENSE.