Skip to content

Commit

Permalink
Reset the backports module when enabling vendored packages.
Browse files Browse the repository at this point in the history
Closes #4476
  • Loading branch information
jaraco committed Jul 18, 2024
1 parent 17b735a commit 8225fe0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions newsfragments/4476.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reset the backports module when enabling vendored packages.
2 changes: 2 additions & 0 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
import _imp

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
# workaround for #4476
sys.modules.pop('backports', None)

# capture these to bypass sandboxing
from os import utime
Expand Down
5 changes: 5 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ ignore = [
"ISC002",
]

# Suppress nuisance warnings about E402 due to workaround for #4476
[tool.ruff.lint.per-file-ignores]
"setuptools/__init__.py" = ["E402"]
"pkg_resources/__init__.py" = ["E402"]

[format]
# Enable preview to get hugged parenthesis unwrapping
preview = true
Expand Down
2 changes: 2 additions & 0 deletions setuptools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from typing import TYPE_CHECKING

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
# workaround for #4476
sys.modules.pop('backports', None)

import _distutils_hack.override # noqa: F401
import distutils.core
Expand Down

0 comments on commit 8225fe0

Please sign in to comment.