Skip to content

Conversation

@branchv
Copy link

@branchv branchv commented Jul 8, 2025

Fixes #602

Replaces pkg_resources (deprecated, no longer bundled with Python since 3.12) with importlib following the migration guide:

  • pkg_resources.resource_filename is now importlib.files
  • The later returns a Traversable (a limited pathlib.Path API) rather than a file guaranteed to be on disk (i.e. for a zipapp). So we need to walk the (possibly virtual) directories ourselves using iterdir and read the files using read_bytes.

Also, I took the opportunity to migrate to pyproject.toml, the modern replacement for setup.py favoring static metadata (also replacing the need for pytest.ini and setup.cfg). This required:

  • Adding build to build sdist + wheels
  • Replacing unmaintained bumpversion with successor bump-my-version

If you want to sanity check the new build:

$ uv build -o ./dist/before
$ git switch pkg_resources && rm *.egg-info && uv build -o ./dist/after
$ uvx diffoscope --exclude-directory-metadata=recursive ./dist/before/*.tar.gz ./dist/after/*.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate from pkg_resources to importlib

1 participant