Skip to content

Commit 7065935

Browse files
authored
Move pkg_resources docs away from the main documents and signal it is no longer supported (#5173)
2 parents 41595af + 9911384 commit 7065935

File tree

4 files changed

+50
-11
lines changed

4 files changed

+50
-11
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
redirects = {
147147
"userguide/keywords": "/deprecated/changed_keywords.html",
148148
"userguide/commands": "/deprecated/commands.html",
149+
"pkg_resources": "/deprecated/pkg_resources.html",
149150
}
150151

151152
# Add support for inline tabs

docs/deprecated/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ objectives.
2323
distutils-legacy
2424
functionalities
2525
commands
26+
pkg_resources
2627

2728
Notes for Consumers of Packages Built with Setuptools
2829
=====================================================
Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,61 @@
22
Package Discovery and Resource Access using ``pkg_resources``
33
=============================================================
44

5-
The ``pkg_resources`` module distributed with ``setuptools`` provides an API
5+
.. attention:: **This documentation is retained solely for historical purposes**
6+
7+
``pkg_resources`` has long been **discouraged** due to architectural
8+
limitations that led to persistent performance issues.
9+
These limitations were inherent to its design (e.g. importing on startup,
10+
scanning the entire environment for metadata, and eager, global
11+
working‑set management) and could not be corrected.
12+
13+
.. version-deprecated:: v67.5.0
14+
``pkg_resources`` issued official deprecation warnings as early as
15+
``setuptools`` **v67.5.0**.
16+
17+
.. version-removed:: v82.0.0
18+
``pkg_resources`` is no longer maintained, no longer used internally by
19+
``setuptools``, and is no longer included in current
20+
distributions/installations as of ``setuptools`` **v82.0.0**.
21+
22+
Projects must migrate away from ``pkg_resources``. The recommended
23+
replacements are:
24+
25+
* Resource access: use :mod:`importlib.resources`
26+
(or its backport :pypi:`importlib_resources`).
27+
* Distribution metadata & entry points: use :mod:`importlib.metadata`
28+
(or its backport :pypi:`importlib_metadata`).
29+
* Requirement and version parsing: use :pypi:`packaging`.
30+
This includes parsing and evaluating ``extras`` and markers via
31+
``packaging.requirements.Requirement`` and ``packaging.markers.Marker``.
32+
Note that automatic installation or detection of extras is not provided;
33+
projects requiring that behaviour must implement it themselves using
34+
a combination of ``packaging``, ``importlib.metadata`` and other tools
35+
as building blocks.
36+
* Coexistence of multiple versions of a package: please consider using a different
37+
approach, as this functionality is not supported by Python itself.
38+
Alternatives include isolated environments and orchestration tools
39+
(:mod:`venv`, :pypi:`tox`, :pypi:`nox`, etc.).
40+
* Handling of ``.egg`` distributions: please consider using a different
41+
approach, as the ``.egg`` and ``easy_install`` mechanisms have also been
42+
discontinued.
43+
Please use currently supported packaging formats
44+
(see :external+PyPUG:`specifications/section-distribution-formats`)
45+
and build/installation workflows (see :pep:`517`).
46+
47+
**Note:** The following documentation may no longer accurately describe the
48+
behaviour of the distributed package and has been frozen at the last
49+
``setuptools`` release that still contained ``pkg_resources``.
50+
51+
52+
The ``pkg_resources`` module provides an API
653
for Python libraries to access their resource files, and for extensible
754
applications and frameworks to automatically discover plugins. It also
855
provides runtime support for using C extensions that are inside zipfile-format
956
eggs, support for merging packages that have separately-distributed modules or
1057
subpackages, and APIs for managing Python's current "working set" of active
1158
packages.
1259

13-
.. attention::
14-
Use of ``pkg_resources`` is deprecated in favor of
15-
:mod:`importlib.resources`, :mod:`importlib.metadata`
16-
and their backports (:pypi:`importlib_resources`, :pypi:`importlib_metadata`).
17-
Some useful APIs are also provided by :pypi:`packaging` (e.g. requirements
18-
and version parsing).
19-
Users should refrain from new usage of ``pkg_resources`` and
20-
should work to port to importlib-based solutions.
21-
2260

2361
--------
2462
Overview

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ with :pypi:`pip` and uploaded to `PyPI <https://pypi.org>`_.
2121

2222
User guide <userguide/index>
2323
build_meta
24-
pkg_resources
2524
references/keywords
2625
setuptools
2726

0 commit comments

Comments
 (0)