artefactual-labs / bagit-gython

An experimental Go library that integrates Python's reliable BagIt implementation using an embedded modern Python interpreter.
https://pkg.go.dev/github.com/artefactual-labs/bagit-gython
Apache License 2.0
0 stars 0 forks source link
bagit bagit-python go golang golang-library python

bagit-gython

Go Reference

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.

Installing

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"

Usage

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!

Supported architectures

These are the platform-architecture combinations for which go-embed-python provides compatibility.

Version of bagit-python

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.

Acknowledgement

License

Apache 2.0. See LICENSE.