Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions src/bandersnatch/tests/plugins/test_filename.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class BasePluginTestCase(TestCase):
cwd = None

def setUp(self) -> None:
filename_name.ExcludePlatformFilter._patterns = []
filename_name.ExcludePlatformFilter._packagetypes = []
Comment on lines 18 to +20
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExcludePlatformFilter._patterns / _packagetypes are class-level caches. Resetting them in setUp() helps within this module, but the values will remain mutated after the last test and can leak into later test modules (causing initialize_plugin() to skip re-initialization). Consider also resetting these caches in tearDown() (or using addCleanup) to leave global state clean for the rest of the test suite.

Copilot uses AI. Check for mistakes.
self.cwd = os.getcwd()
self.tempdir = TemporaryDirectory()
os.chdir(self.tempdir.name)
Expand Down Expand Up @@ -193,3 +195,66 @@ def test_exclude_platform(self) -> None:

# the release "0.2" should have been deleted since there is no more file in it
assert len(pkg.releases.keys()) == 3


class TestExcludePlatformFilterLinuxPep600(BasePluginTestCase):
config_contents = """\
[plugins]
enabled =
exclude_platform

[blocklist]
platforms =
linux
"""

def test_exclude_linux_platform_tags(self) -> None:
"""
When excluding linux, ensure PEP 600 manylinux tags are excluded too.
"""
mock_config(self.config_contents)

mirror = BandersnatchMirror(Path("."), Master(url="https://foo.bar.com"))
pkg = Package("foobar", 1)
pkg._metadata = {
"info": {"name": "foobar", "version": "1.0"},
"releases": {
"1.0": [
{
"packagetype": "bdist_wheel",
"filename": "foobar-1.0-py3-none-any.whl",
"flag": "KEEP",
},
{
"packagetype": "bdist_wheel",
"filename": "foobar-1.0-cp312-cp312-manylinux_2_17_x86_64.whl",
"flag": "DROP",
},
{
"packagetype": "bdist_wheel",
"filename": "foobar-1.0-cp312-cp312-manylinux2014_x86_64.whl",
"flag": "DROP",
},
{
"packagetype": "bdist_wheel",
"filename": "foobar-1.0-cp312-cp312-musllinux_1_1_x86_64.whl",
"flag": "DROP",
},
{
"packagetype": "bdist_wheel",
"filename": "manylinux_foo-1.0-py3-none-any.whl",
"flag": "KEEP",
},
]
},
}

# count the files we should keep
rv = pkg.releases.values()
keep_count = sum(f["flag"] == "KEEP" for r in rv for f in r)

pkg.filter_all_releases_files(mirror.filters.filter_release_file_plugins())

rv = pkg.releases.values()
assert sum(f["flag"] == "KEEP" for r in rv for f in r) == keep_count
assert sum(f["flag"] == "DROP" for r in rv for f in r) == 0
1 change: 1 addition & 0 deletions src/bandersnatch_filter_plugins/filename_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ExcludePlatformFilter(FilterReleaseFilePlugin):
"manylinux2014_ppc64", # PEP 599
"manylinux2014_ppc64le", # PEP 599
"manylinux2014_s390x", # PEP 599
"-manylinux_", # PEP 600 (manylinux_<glibc-major>_<glibc-minor>_<arch>)
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new PEP 600 pattern is "-manylinux_", which only matches when the tag is preceded by a hyphen. Wheel platform tags can be a dot-separated list (e.g. ...-manylinux2014_x86_64.manylinux_2_17_x86_64.whl), where a PEP 600 tag may be preceded by . instead. Consider also matching .manylinux_ (or parsing the wheel filename and matching only against the platform tag field) so PEP 600 tags are reliably excluded regardless of position.

Suggested change
"-manylinux_", # PEP 600 (manylinux_<glibc-major>_<glibc-minor>_<arch>)
"-manylinux_", # PEP 600 (manylinux_<glibc-major>_<glibc-minor>_<arch>) in hyphen-separated tags
".manylinux_", # PEP 600 (manylinux_<glibc-major>_<glibc-minor>_<arch>) in dot-separated tags

Copilot uses AI. Check for mistakes.
"musllinux", # PEP 656
]

Expand Down
Loading