Lessons from this week's removal of the #pkg_resources module:

- If you don't use the `--no-build-isolation` argument of `pip install`, then `--require-hashes` is only partly effective and your builds may break whenever incompatible changes are made to #setuptools or other build dependencies.

- If you use `--no-build-isolation`, you need multiple `pip install` calls: first for all the needed build dependencies (a.k.a. `setup_requires`), then for the packages you actually want.

#Python #pip

After literal decades of work, #setuptools maintainers are finally retiring #pkg_resources in v82.0.0. I've been diligent to migrate every package I came across that used it for years, but it's very likely still being used in the wild, so here's a bit of context if you see failing builds in the coming days and don't understand what's happening;
#pkg_resources was shipped alongside #setuptools, which has been the de-facto standard (and only option up until ~2018 (#PEP517)) build backend for #Python packages. #setuptools was *never* part of the standard library, however it used to be (and still is, in many cases) distributed with it for convenience, so many projects have depended on it for ages, some of which have never explicitly declared it as a dependency (neither build-time or runtime). #pkg_resources had the same exact problems, but worse, because you couldn't even find it on #PyPI under its own name. I suspect many Python dev will only learn about this now that the package is suddenly missing.
In many cases, solutions include:
- migrating to importlib.metadata (python>=3.8), or its third party counterpart #importlib_metadata if somehow you still need to support Python 3.7 or older
- migrating to importlib.resources (Python>=3.11), or #importlib_resources for older Pythons
- dropping #setuptools / #pkg_resources completely: if all you need is a dead-simple, well maintained build backend for pure-Python projects, I highly recommend #flit_core. It's trivial to use, only supports static metadata and has never blown my face away after years using it every chance I get.

If you read this far, please boost for reach. Thanks !

#packaging #dependency #dependency_hell #softwaredevelopment

Setuptools deprecated pkg_resources in docs for ~two years, then with a DeprecationWarning for ~two years, then a UserWarning for ~one year.

2021-04: Deprecate in docs (v56.0.0)
https://github.com/pypa/setuptools/commit/8fe85c22cee7fde5e6af571b30f864bad156a010

2023-03: Officially deprecate with DeprecationWarning (v67.5.0)
https://github.com/pypa/setuptools/pull/3843

2025-05: Promote to UserWarning with earliest removal deadline of 2025-11-30 (v80.9.0)
https://github.com/pypa/setuptools/pull/5014

2026-02: Remove (v82.0.0)
https://github.com/pypa/setuptools/pull/5007

#Python #setuptools #pkg_resources

Officially declare pkg_resources as deprecated. Closes #2531. · pypa/setuptools@8fe85c2

Official project repository for the Setuptools build system - Officially declare pkg_resources as deprecated. Closes #2531. · pypa/setuptools@8fe85c2

GitHub
`pkg_resources.extern.packaging.markers` and `canonicalize_name` can be used to evaluate and simplify dependency markers in a Python package. For example, to check if a package is compatible with the current environment, we can canonicalize its name and evaluate the markers. #python #pkg_resources #extern #packaging #markers
A simple use case for pkg_resources.extern.jaraco.context is acquiring a resource from a repository, and using pkg_resources.extern.repo_context to manage the context of that resource. #python #pkg_resources #extern #jaraco #context

A simple use case of pkg_resources.extern.packaging.tags and mac_platforms is to identify the platform (e.g., macOS) in a Python package.

#python #pkg_resources #extern #packaging #tags

`jaraco.text.yield_lines` allows iterating through lines of text. When combined with `pkg_resources`, it can read and process lines from a resource file. #python #pkg_resources #yield_lines