Visitar URL original
Account for environment markers when comparing package version with requirements by danielhollas · Pull Request #532 · aiidalab/aiidalab · GitHub
Skip to content

Account for environment markers when comparing package version with requirements - #532

Merged
danielhollas merged 3 commits into
mainfrom
markers
Sep 23, 2026
Merged

danielhollas merged 3 commits into
mainfrom
markers

Conversation

@danielhollas

@danielhollas danielhollas commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes two issues pertaining to how we decide whether an installed package fulfills a given app's requirement.

The first bug is described in #531; we were not taking into account PEP 496 environment marker, e.g. ipywidgets~=7.7; python_version<3.10

A somewhat more subtle issue was concerning installed packages with pre-release versions of installed packages. The way that packaging (and pip as well) generally worked that pre-release packages cannot fulfill a requirement, unless that requirement specifically asks for pre-release. That's reasonable in general, but it would fail if we e.g. had a requirement without any version constraint (e.g. a requirement pointing to GitHub repo). In this case, installed pre-released package should fulfill this.

This second issue is fixed by bumping the minimum version packaging package, which changed this behaviour. I've added a regression test for this.

The test suite was generated by Claude Sonnet, but I went through it and added some more test while removing those that were superfluous. There's still perhaps a bit more tests than needed (we're essentially testing the packaging functionality, but given that version handling is so finicky I think it is okay.

Fixes #531

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.43%. Comparing base (9606f98) to head (ad9b614).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #532      +/-   ##
==========================================
+ Coverage   73.28%   73.43%   +0.14%     
==========================================
  Files          18       18              
  Lines        1688     1690       +2     
==========================================
+ Hits         1237     1241       +4     
+ Misses        451      449       -2     
Flag Coverage Δ
py-3.12 73.43% <100.00%> (+0.14%) ⬆️
py-3.9 73.43% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Autogenerated by Claude Sonnet,
checked and tweaked by me.
@danielhollas
danielhollas marked this pull request as ready for review September 23, 2026 10:46
Comment thread tests/test_utils.py
Comment on lines +166 to +176
def test_prerelease_fulfills_when_requirement_has_no_specifier(self):
pkg = Package("requests", "0.0.1a0")
req = Requirement("requests")
assert pkg.fulfills(req) is True

def test_prerelease_fulfills_when_requirement_has_git_url(self):
pkg = Package("aiidalab-widgets-base", "3.0.0a3")
req = Requirement(
"aiidalab_widgets_base@git+https://github.com/aiidalab/aiidalab-widgets-base@master"
)
assert pkg.fulfills(req) is True

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are a regression tests for the second issue about pre-releases.

They both fail with packaging==25.0 but pass with packaging==26.0

@edan-bainglass edan-bainglass left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense. LGTM! Thanks @danielhollas.

@danielhollas
danielhollas merged commit 607b5ea into main Sep 23, 2026
9 checks passed
@danielhollas
danielhollas deleted the markers branch September 23, 2026 12:35
danielhollas added a commit that referenced this pull request Oct 19, 2026
Follow-up to #532

_find_incompatibilities_python now skips any requirement whose marker
doesn't apply before looking up the package.
A requirement like pywin32; sys_platform == 'win32' on Linux
no longer makes the app incompatible.
@danielhollas danielhollas added the bug Something isn't working label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compatibility checking code doesn't take into account environment markers

2 participants