Skip to content

Use pyproject and remove setup.py #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install coverage
pip install --editable .
- name: Run test
run: python -m unittest discover
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Run tests
run: uv run pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dist
MANIFEST
bagit.egg-info
.idea
uv.lock
*.log
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ COMPILED_MESSAGES=$(patsubst %.po,%.mo, $(wildcard locale/*/LC_MESSAGES/bagit-py
all: messages compile

clean:
rm -f locale/*/LC_MESSAGES/*.mo
rm -f src/bagit/locale/*/LC_MESSAGES/*.mo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gettext files have been moved down into src.

messages:
xgettext --language=python -d bagit-python --no-location -o locale/bagit-python.pot bagit.py
xgettext --language=python -d bagit-python --no-location -o src/bagit/locale/bagit-python.pot src/bagit/__init__.py
# Until http://savannah.gnu.org/bugs/?20923 is fixed:
sed -i '' -e 's/CHARSET/UTF-8/g' locale/bagit-python.pot
msgmerge --no-fuzzy-matching --lang=en --output-file=locale/en/LC_MESSAGES/bagit-python.po locale/en/LC_MESSAGES/bagit-python.po locale/bagit-python.pot
sed -i '' -e 's/CHARSET/UTF-8/g' src/bagit/locale/bagit-python.pot
msgmerge --no-fuzzy-matching --lang=en --output-file=src/bagit/locale/en/LC_MESSAGES/bagit-python.po src/bagit/locale/en/LC_MESSAGES/bagit-python.po src/bagit/locale/bagit-python.pot

%.mo: %.po
msgfmt -o $@ $<
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,23 @@ Contributing to bagit-python development
% git clone git://github.com/LibraryOfCongress/bagit-python.git
% cd bagit-python
# MAKE CHANGES
% python test.py
% uv run pytest

Running the tests
~~~~~~~~~~~~~~~~~

You can quickly run the tests using the built-in unittest framework:
You can quickly run the tests using `uv <https://docs.astral.sh/uv/>`_.

::

python -m unittest discover
uv run pytest

If you have Docker installed, you can run the tests under Linux inside a
container:

::

% docker build -t bagit:latest . && docker run -it bagit:latest
docker build -t bagit:latest . && docker run -it bagit:latest

Benchmarks
----------
Expand All @@ -246,7 +246,7 @@ bench utility:

::

% ./bench.py
./utils/bench.py

License
-------
Expand Down
39 changes: 32 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[build-system]
requires = ["setuptools>=64", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "bagit"
dynamic = ["version"]
description = "Create and validate BagIt packages"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [
{ name = "Ed Summers", email = "[email protected]" },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Andy wrote much of the original code, and Chris has added to it since I last touched it, so this seems right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's an interesting question: do we try to list everyone who's made significant contributions in the past, or only the people who want to get emails when someone needs help?

Copy link
Contributor Author

@edsu edsu Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point -- maybe just you and me at this point? I guess things are busy at the fruit store for Mr Boyko...

Or perhaps just you, since I don't have rights to this repository anymore. I remain interested though!

{ name = "Chris Adams", email = "[email protected]" },
{ name = "Ed Summers", email = "[email protected]" }
]
classifiers = [
"Intended Audience :: Developers",
Expand All @@ -18,6 +19,10 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Filesystems",
]
requires-python = ">= 3.9"

[project.scripts]
"bagit" = "bagit:main"

[project.urls]
Homepage = "https://libraryofcongress.github.io/bagit-python/"
Expand All @@ -27,14 +32,34 @@ Homepage = "https://libraryofcongress.github.io/bagit-python/"
[tool.ruff]
target-version = "py38"


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hatch-vcs seems like it is doing this work now when i do a uv build?

[tool.setuptools_scm]

[tool.isort]
line_length = 110
default_section = "THIRDPARTY"
known_first_party = "bagit"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to using pytest to run the tests...

[tool.pytest.ini_options]
testpaths = ["test.py"]
addopts = "-v"

[tool.coverage.run]
branch = true
include = "bagit.py"
include = "src"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.targets.sdist]
packages = ["src/bagit"]
include = [
"src/bagit/*.py",
"src/bagit/locale/*.po",
"src/bagit/locale/*.mo",
]


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding these here means that ruff will ensure they are available when running tests.

[dependency-groups]
dev = [
"coverage>=7.8.2",
"pytest>=8.4.0",
"ruff>=0.11.12",
]
61 changes: 0 additions & 61 deletions setup.py

This file was deleted.

7 changes: 2 additions & 5 deletions bagit.py → src/bagit/__init__.py
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that bagit.py is v1.0 compliant. At least there haven't been any complaints that it isn't?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't heard any arguments otherwise. It's been a long time since I worked through that RFC and https://github.com/LibraryOfCongress/bagit-conformance-suite

Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def make_bag(
)

LOGGER.info(_("Creating bagit.txt"))
txt = """BagIt-Version: 0.97\nTag-File-Character-Encoding: UTF-8\n"""
txt = """BagIt-Version: 1.0\nTag-File-Character-Encoding: UTF-8\n"""
with open_text_file("bagit.txt", "w") as bagit_file:
bagit_file.write(txt)

Expand Down Expand Up @@ -1479,10 +1479,7 @@ def _make_parser():

checksum_args = parser.add_argument_group(
_("Checksum Algorithms"),
_(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a formatting change that my local ruff suggested. I'm not sure why CI didn't care too...

"Select the manifest algorithms to be used when creating bags"
" (default=%s)"
)
_("Select the manifest algorithms to be used when creating bags (default=%s)")
% ", ".join(DEFAULT_CHECKSUMS),
)

Expand Down
20 changes: 15 additions & 5 deletions locale/bagit-python.pot → src/bagit/locale/bagit-python.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-26 10:28-0400\n"
"POT-Creation-Date: 2025-06-05 12:14-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -226,20 +226,23 @@ msgid ""
"%(found_byte_count)d bytes"
msgstr ""

msgid "Bag validation failed"
msgid "Bag is incomplete"
msgstr ""

#, python-format
msgid "Unable to calculate file hashes for %s"
msgstr ""

msgid "Bag validation failed"
msgstr ""

msgid "bagit.txt must not contain a byte-order mark"
msgstr ""

#, python-format
msgid ""
"%(path)s %(algorithm)s validation failed: expected=\"%(expected)s\" found="
"\"%(found)s\""
"%(path)s %(algorithm)s validation failed: expected=\"%(expected)s\" "
"found=\"%(found)s\""
msgstr ""

#, python-format
Expand Down Expand Up @@ -345,16 +348,23 @@ msgstr ""
msgid "bagit-python version %s"
msgstr ""

msgid "The number of processes must be 0 or greater"
msgid "The number of processes must be greater than 0"
msgstr ""

msgid "--fast is only allowed as an option for --validate!"
msgstr ""

msgid "--completeness-only is only allowed as an option for --validate!"
msgstr ""

#, python-format
msgid "%s valid according to Payload-Oxum"
msgstr ""

#, python-format
msgid "%s is complete and valid according to Payload-Oxum"
msgstr ""

#, python-format
msgid "%s is valid"
msgstr ""
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-26 10:28-0400\n"
"POT-Creation-Date: 2025-06-05 12:14-0400\n"
"PO-Revision-Date: 2017-04-27 15:02-0400\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -233,20 +233,23 @@ msgid ""
"%(found_byte_count)d bytes"
msgstr ""

msgid "Bag validation failed"
msgid "Bag is incomplete"
msgstr ""

#, python-format
msgid "Unable to calculate file hashes for %s"
msgstr "Unable to calculate file hashes for %s"

msgid "Bag validation failed"
msgstr ""

msgid "bagit.txt must not contain a byte-order mark"
msgstr ""

#, python-format
msgid ""
"%(path)s %(algorithm)s validation failed: expected=\"%(expected)s\" found="
"\"%(found)s\""
"%(path)s %(algorithm)s validation failed: expected=\"%(expected)s\" "
"found=\"%(found)s\""
msgstr ""

#, python-format
Expand Down Expand Up @@ -352,16 +355,23 @@ msgstr ""
msgid "bagit-python version %s"
msgstr ""

msgid "The number of processes must be 0 or greater"
msgid "The number of processes must be greater than 0"
msgstr ""

msgid "--fast is only allowed as an option for --validate!"
msgstr ""

msgid "--completeness-only is only allowed as an option for --validate!"
msgstr ""

#, python-format
msgid "%s valid according to Payload-Oxum"
msgstr "%s valid according to Payload-Oxum"

#, python-format
msgid "%s is complete and valid according to Payload-Oxum"
msgstr ""

#, python-format
msgid "%s is valid"
msgstr "%s is valid"
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def test_make_bag(self):
tagmanifest_txt = slurp_text_file(
j(self.tmpdir, "tagmanifest-md5.txt")
).splitlines()
self.assertIn("9e5ad981e0d29adc278f6a294b8c2aca bagit.txt", tagmanifest_txt)
self.assertIn("eaa2c609ff6371712f623f5531945b44 bagit.txt", tagmanifest_txt)
self.assertIn(
"a0ce6631a2a6d1a88e6d38453ccc72a5 manifest-md5.txt", tagmanifest_txt
)
Expand Down
File renamed without changes.
Loading
Loading