Skip to content

Commit fddda37

Browse files
authored
Merge pull request #4486 from pypa/bugfix/4476-reset-backports
Reset the backports module when enabling vendored packages.
2 parents 17b735a + 299d276 commit fddda37

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

newsfragments/4476.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reset the backports module when enabling vendored packages.

pkg_resources/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
import _imp
7676

7777
sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip
78+
# workaround for #4476
79+
sys.modules.pop('backports', None)
7880

7981
# capture these to bypass sandboxing
8082
from os import utime

ruff.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ ignore = [
4343
"ISC002",
4444
]
4545

46+
# Suppress nuisance warnings about E402 due to workaround for #4476
47+
[lint.per-file-ignores]
48+
"setuptools/__init__.py" = ["E402"]
49+
"pkg_resources/__init__.py" = ["E402"]
50+
4651
[format]
4752
# Enable preview to get hugged parenthesis unwrapping
4853
preview = true

setuptools/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from typing import TYPE_CHECKING
88

99
sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip
10+
# workaround for #4476
11+
sys.modules.pop('backports', None)
1012

1113
import _distutils_hack.override # noqa: F401
1214
import distutils.core

0 commit comments

Comments
 (0)