Skip to content

monkeypatch: remove pkg_resources.fixup_namespace_packages call in syspath_prepend #13807

Description

@bluetech

monkeypatch.syspath_prepend calls it:

def syspath_prepend(self, path) -> None:
"""Prepend ``path`` to ``sys.path`` list of import locations."""
if self._savesyspath is None:
self._savesyspath = sys.path[:]
sys.path.insert(0, str(path))
# https://github.com/pypa/setuptools/blob/d8b901bc/docs/pkg_resources.txt#L162-L171
# this is only needed when pkg_resources was already loaded by the namespace package
if "pkg_resources" in sys.modules:
from pkg_resources import fixup_namespace_packages
fixup_namespace_packages(str(path))

This is needed for legacy namespace package support, which is now deprecated, along with the entire pkg_resources package.

I saw recently that zope packages which were the last holdouts I was familiar with had switched to new namespace package style, zope.event, zope.interface.

Let's start removing it. The main reason is that it requires us to have a setuptools dev dependency, ignore its deprecation warnings and keep it working.

Let's deprecate it and remove in pytest 10.

Activity

  1. self-assigned this
    on Oct 13, 2025
  2. added
    type: proposalproposal for a new feature, often to gather opinions or design the API around the new feature
    on Oct 13, 2025
  3. added theissue type on Oct 13, 2025
  4. added
    type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog
    type: deprecationfeature that will be removed in the future
    plugin: monkeypatchrelated to the monkeypatch builtin plugin
    on Oct 13, 2025
  5. added 7 commits that reference this issue on Oct 13, 2025
    37a4631
    c1b3168
    0cbebd5
    8d5b135
    06588dd
    94a24bc
    8fb067f
  6. added a commit that references this issue on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

plugin: monkeypatchrelated to the monkeypatch builtin plugintype: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelogtype: deprecationfeature that will be removed in the futuretype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions