bagit is described as follows:
bagit is a Python library and command line utility for working with BagIt style packages.
I created a Google Colab notebook for trying out this library.
https://colab.research.google.com/github/nakamura196/ndl_ocr/blob/main/bagit_python.ipynb
I hope this serves as a useful reference for using bagit.