pypa / bandersnatch

A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/
Academic Free License v3.0
453 stars 141 forks source link

Proper filter for aarch64, win32 #1201

Open JPrazak opened 2 years ago

JPrazak commented 2 years ago

Hi, Iam little bit confused with packages filtering. Plugin exclude_platfrom work well for py versions and 4 main platforms. Can I also blocklist/filter aarch64 and win32 packages or which filter I should use? Thank you.

89ao commented 2 years ago

maybe this can help you:

Platform/Python-specific binaries filtering
This filter allows advanced users not interesting in Windows/macOS/Linux specific binaries to not mirror the corresponding files.

You can also exclude Python versions by their minor version (ex. Python 2.6, 2.7) if you’re sure your mirror does not need to serve these binaries.

[plugins]
enabled =
    exclude_platform
[blocklist]
platforms =
    windows
    py2.6
    py2.7
Available platforms are:

windows

macos

freebsd

linux

Available python versions are:

py2.4 ~ py2.7

py3.1 ~ py3.10

or just use Regex filtering

JPrazak commented 2 years ago

Yes, I use this plugin and blocklist filter. It works very well as excepted for python versions, macos and freebsd. But I can't filter aarch64 or win32 packages. Thank You very much.

cooperlees commented 2 years ago

I wouldn't be surprised of bug(s) existing here. A lot of plugins have been community contributed and had little involvement from any core bandersnatch developer (me). Debug logging and running a local build of bandersnatch with more logging to workout why there are not working is probably needed here. Another way would be to improve our plugin unittests as at the end of the day it's just checking metadata in a way to workout if we download a package or not.

As always, a PR fixing, with unittests, would be accepted.

imnoterel commented 2 weeks ago

You can already do that to some extent.

Instead of just "linux" or "windows", you can put any platform type listed in the ExcludePlatformFilter._windowsPlatformTypes or ExcludePlatformFilter._linuxPlatformTypes found in src/bandersnatch_filter_plugins/filename_name.py in your blocklist and this particular platform will be excluded from your mirror.

In other words, this should work in your bandersnatch config :

[plugins]
enabled = 
    exclude_platform

[blocklist]
platforms = 
    linux-i686
    manylinux2014_aarch64
    .win32
    -win32

It's not properly documented and there are some platform types missing (musl for example) though. I can work on a small PR to add the missing platforms and update the documentation to give more details on how it works / which platforms are available if you want.

cooperlees commented 2 weeks ago

Thanks. Will totally take that PR(s).