Skip to content

Commit f1f5829

Browse files
veeceeyclaude
andcommitted
Update stale docs references to pkg_resources as active module
Remove or update documentation that still refers to ``pkg_resources`` as an actively maintained module, following the deprecation completed in #5173. Changes include: - docs/setuptools.rst: Rewrite Transitional Note to reflect that pkg_resources-style namespace packages are deprecated - docs/development/index.rst: Remove mention of pkg_resources module and reference manual - docs/userguide/distribution.rst: Replace pkg_resources.parse_version() with packaging.version.parse() - docs/userguide/extension.rst: Reference importlib.metadata as the primary API for EGG-INFO access - docs/userguide/package_discovery.rst: Fix ``pkg_resource`` typo (missing 's'), fix ``pkgutils`` typo, add deprecation admonition to Legacy Namespace Packages section - setuptools/dist.py: Replace pkg_resources.require() format reference with PEP 508 in install_requires docstring Closes #5179 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7065935 commit f1f5829

7 files changed

Lines changed: 53 additions & 48 deletions

File tree

docs/development/index.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ Authority (PyPA) and led by Jason R. Coombs.
77

88
This document describes the process by which Setuptools is developed.
99
This document assumes the reader has some passing familiarity with
10-
*using* setuptools, the ``pkg_resources`` module, and pip. It
11-
does not attempt to explain basic concepts like inter-project
12-
dependencies, nor does it contain detailed lexical syntax for most
13-
file formats. Neither does it explain concepts like "namespace
14-
packages" or "resources" in any detail, as all of these subjects are
15-
covered at length in the setuptools developer's guide and the
16-
``pkg_resources`` reference manual.
10+
*using* setuptools and pip. It does not attempt to explain basic
11+
concepts like inter-project dependencies, nor does it contain detailed
12+
lexical syntax for most file formats. Neither does it explain concepts
13+
like "namespace packages" or "resources" in any detail, as all of these
14+
subjects are covered at length in the setuptools developer's guide.
1715

1816
Instead, this is **internal** documentation for how those concepts and
1917
features are *implemented* in concrete terms. It is intended for people

docs/setuptools.rst

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,21 @@ The developer's guide has been updated. See the :doc:`most recent version <userg
8686
TRANSITIONAL NOTE
8787
~~~~~~~~~~~~~~~~~
8888

89-
Setuptools automatically calls ``declare_namespace()`` for you at runtime,
90-
but future versions may *not*. This is because the automatic declaration
91-
feature has some negative side effects, such as needing to import all namespace
92-
packages during the initialization of the ``pkg_resources`` runtime, and also
93-
the need for ``pkg_resources`` to be explicitly imported before any namespace
94-
packages work at all. In some future releases, you'll be responsible
95-
for including your own declaration lines, and the automatic declaration feature
96-
will be dropped to get rid of the negative side effects.
97-
98-
During the remainder of the current development cycle, therefore, setuptools
99-
will warn you about missing ``declare_namespace()`` calls in your
100-
``__init__.py`` files, and you should correct these as soon as possible
101-
before the compatibility support is removed.
102-
Namespace packages without declaration lines will not work
103-
correctly once a user has upgraded to a later version, so it's important that
104-
you make this change now in order to avoid having your code break in the field.
105-
Our apologies for the inconvenience, and thank you for your patience.
89+
.. note::
90+
The ``pkg_resources``-style and ``pkgutil``-style namespace packages
91+
described below are **deprecated** and no longer supported.
92+
Please migrate to :pep:`420`-style implicit namespace packages.
93+
See :doc:`userguide/package_discovery` for details.
94+
95+
Setuptools historically called ``declare_namespace()`` at runtime using
96+
``pkg_resources``, but this mechanism has been deprecated. The
97+
``pkg_resources`` runtime required importing all namespace packages during
98+
initialization and needed to be explicitly imported before any namespace
99+
packages would work at all.
100+
101+
Projects should migrate to :pep:`420`-style implicit namespace packages,
102+
which do not require ``declare_namespace()`` calls or special
103+
``__init__.py`` files.
106104

107105

108106

docs/userguide/distribution.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ but here are a few tips that will keep you out of trouble in the corner cases:
8080
:pep:`440`-compliant.
8181

8282
* If you want to be certain that your chosen numbering scheme works the way
83-
you think it will, you can use the ``pkg_resources.parse_version()`` function
83+
you think it will, you can use the ``packaging.version.parse()`` function
8484
to compare different version numbers::
8585

86-
>>> from pkg_resources import parse_version
87-
>>> parse_version("1.9.a.dev") == parse_version("1.9a0dev")
86+
>>> from packaging.version import parse
87+
>>> parse("1.9a0.dev0") == parse("1.9a0.dev0")
8888
True
89-
>>> parse_version("2.1-rc2") < parse_version("2.1")
89+
>>> parse("2.1rc2") < parse("2.1")
9090
True
91-
>>> parse_version("0.6a9dev-r41475") < parse_version("0.6a9")
91+
>>> parse("0.6a9.dev0") < parse("0.6a9")
9292
True
9393

9494
Once you've decided on a version numbering scheme for your project, you can

docs/userguide/extension.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ Adding new EGG-INFO Files
179179

180180
Some extensible applications or frameworks may want to allow third parties to
181181
develop plugins with application or framework-specific metadata included in
182-
the plugins' EGG-INFO directory, for easy access via the ``pkg_resources``
183-
metadata API. The easiest way to allow this is to create an extension
182+
the plugins' EGG-INFO directory, for easy access via the
183+
:mod:`importlib.metadata` API (or its predecessor ``pkg_resources``).
184+
The easiest way to allow this is to create an extension
184185
to be used from the plugin projects' setup scripts (via ``setup_requires``)
185186
that defines a new setup keyword, and then uses that data to write an EGG-INFO
186187
file when the ``egg_info`` command is run.

docs/userguide/package_discovery.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -505,19 +505,26 @@ available to your interpreter.
505505

506506
Legacy Namespace Packages
507507
=========================
508+
509+
.. deprecated::
510+
The ``pkg_resources``-style and ``pkgutil``-style namespace packages
511+
described below are **deprecated and no longer supported**.
512+
Please migrate to :pep:`420`-style implicit namespace packages.
513+
508514
The fact you can create namespace packages so effortlessly above is credited
509515
to :pep:`420`. It used to be more
510516
cumbersome to accomplish the same result. Historically, there were two methods
511-
to create namespace packages. One is the ``pkg_resources`` style supported by
512-
``setuptools`` and the other one being ``pkgutils`` style offered by
513-
``pkgutils`` module in Python. Both are now considered *deprecated* despite the
514-
fact they still linger in many existing packages. These two differ in many
515-
subtle yet significant aspects and you can find out more on `Python packaging
516-
user guide <https://packaging.python.org/guides/packaging-namespace-packages/>`_.
517+
to create namespace packages. One is the ``pkg_resources`` style formerly
518+
supported by ``setuptools`` and the other one being ``pkgutil`` style offered
519+
by the ``pkgutil`` module in Python. Both are now **deprecated and no longer
520+
supported** despite the fact they still linger in many existing packages.
521+
These two differ in many subtle yet significant aspects and you can find out
522+
more on the `Python packaging user guide
523+
<https://packaging.python.org/guides/packaging-namespace-packages/>`_.
517524

518525

519-
``pkg_resource`` style namespace package
520-
----------------------------------------
526+
``pkg_resources`` style namespace package
527+
-----------------------------------------
521528
This is the method ``setuptools`` directly supports. Starting with the same
522529
layout, there are two pieces you need to add to it. First, an ``__init__.py``
523530
file directly under your namespace package directory that contains the
@@ -562,7 +569,7 @@ the previous section.
562569

563570
``pkgutil`` style namespace package
564571
-----------------------------------
565-
This method is almost identical to the ``pkg_resource`` except that the
572+
This method is almost identical to the ``pkg_resources`` style except that the
566573
``namespace_packages`` declaration is omitted and the ``__init__.py``
567574
file contains the following:
568575

newsfragments/5179.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated documentation to remove stale references to ``pkg_resources`` as an active module -- by :user:`veeceey`

setuptools/dist.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,14 @@ class Distribution(_Distribution):
246246
effectively adds the following new optional keyword arguments to 'setup()':
247247
248248
'install_requires' -- a string or sequence of strings specifying project
249-
versions that the distribution requires when installed, in the format
250-
used by 'pkg_resources.require()'. They will be installed
251-
automatically when the package is installed. If you wish to use
252-
packages that are not available in PyPI, or want to give your users an
253-
alternate download location, you can add a 'find_links' option to the
254-
'[easy_install]' section of your project's 'setup.cfg' file, and then
255-
setuptools will scan the listed web pages for links that satisfy the
256-
requirements.
249+
versions that the distribution requires when installed, in the
250+
:pep:`508` format (e.g. ``'requests>=2.0'``). They will be
251+
installed automatically when the package is installed. If you wish
252+
to use packages that are not available in PyPI, or want to give your
253+
users an alternate download location, you can add a 'find_links'
254+
option to the '[easy_install]' section of your project's 'setup.cfg'
255+
file, and then setuptools will scan the listed web pages for links
256+
that satisfy the requirements.
257257
258258
'extras_require' -- a dictionary mapping names of optional "extras" to the
259259
additional requirement(s) that using those extras incurs. For example,

0 commit comments

Comments
 (0)