Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest x packages breaks pinned version functionality #1599

Closed
miicha opened this issue Nov 6, 2023 · 1 comment
Closed

Latest x packages breaks pinned version functionality #1599

miicha opened this issue Nov 6, 2023 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@miicha
Copy link
Contributor

miicha commented Nov 6, 2023

My usecase

  • I'd like to have a slim mirror for offline usage based on a selection of a few packages
  • packages are initially given in a requirmentss.txt and externally expanded to a requirements.txt with all dependencies (including version range)
  • To keep the required storage low, I'd like to fetch max X versions while honoring the pinned versions given in the requirements.txt

Problem

Because all filters are applied in a loop in package.py, the last X versions plugin wins and older required versions are not downloaded:

if not all(plugin.filter(release_data) for plugin in release_filters):
    del self.releases[version]

Possible solution

  • The pinned filter should have priority and "pre-filter" the available versions
  • the next step is not yet clear to me, but I can see 3 options:
    1. afterwards we can either filter the remaining versions to keep only X, but this is problematic because we don't know if different packages have different version ranges since we would need to keep at least one version from each range
    2. alternatively last X version filtering might be suppressed for packages that have pinned versions / version range leading to more packages to be downloaded
    3. the pinned versions filtering itself takes care of fetching only the newest version from each given range (would be my favorite solution)

Since I need this functionality quite urgently, I would create a "work in progress" PR with solution 2. If you have some additional ideas or requirements, I would adjust it accordingly.

miicha added a commit to miicha/bandersnatch that referenced this issue Nov 6, 2023
@cooperlees cooperlees added bug Something isn't working enhancement New feature or request labels Nov 7, 2023
@cooperlees
Copy link
Contributor

Thanks for proposing and looking into this. We've never prioritized getting plugin's ordering correct so we apply correctly as it really increases the complexity of the plugin system, as you're seeing.

I like the sounds of checking if there are specific per package version ranges etc. and exempting them from the keep option.

If you could prove this all works with unit tests it will increase my ability to merge this efficiently. I'd even accept adding this to the integration tests we run too.

miicha added a commit to miicha/bandersnatch that referenced this issue Nov 7, 2023
…rsion filtering is applied (remove commented code)
miicha added a commit to miicha/bandersnatch that referenced this issue Nov 7, 2023
…ering as well as clarifying comments in documentation
miicha added a commit to miicha/bandersnatch that referenced this issue Nov 7, 2023
miicha added a commit to miicha/bandersnatch that referenced this issue Nov 7, 2023
miicha added a commit to miicha/bandersnatch that referenced this issue Nov 7, 2023
…rsion filtering is applied (remove commented code)
miicha added a commit to miicha/bandersnatch that referenced this issue Nov 7, 2023
…ering as well as clarifying comments in documentation
miicha added a commit to miicha/bandersnatch that referenced this issue Nov 7, 2023
miicha added a commit to miicha/bandersnatch that referenced this issue Nov 10, 2023
cooperlees added a commit that referenced this issue Nov 12, 2023
* #1599 - disable additional package version filtering if pinned version filtering is applied

* #1599 - disable additional package version filtering if pinned version filtering is applied (remove commented code)

* #1599 - add unit test for combined pinned and latest version filtering as well as clarifying comments in documentation

* #1599 - add changelog entry for combined pinned and latest version filtering

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update src/bandersnatch_filter_plugins/allowlist_name.py

* #1599 - clean added unit test

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants