Skip to content

monkeypatch: remove pkg_resources.fixup_namespace_packages call in syspath_prepend #13807

@bluetech

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.

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