Skip to content

Fix: Allow packages with only prerelease versions to be installed#6486

Merged
matteius merged 3 commits intomainfrom
fix/prerelease-only-packages-6485
Dec 10, 2025
Merged

Fix: Allow packages with only prerelease versions to be installed#6486
matteius merged 3 commits intomainfrom
fix/prerelease-only-packages-6485

Conversation

@matteius
Copy link
Copy Markdown
Member

Summary

This PR fixes issue #6485 where packages like opentelemetry-semantic-conventions that only have prerelease versions (e.g., 0.60b0) could not be installed without using the --pre flag.

Problem

The fix for #6395 changed the prerelease handling to use prereleases=False instead of prereleases=None. This correctly prevented transitive dependencies with prerelease specifiers from enabling prereleases globally, but it also broke packages that have only prerelease versions available.

Per PEP 440, when no stable versions satisfy the constraints, prereleases should be considered. The previous fix explicitly disabled this fallback behavior.

Solution

The fix modifies get_applicable_candidates() in the package finder to:

  1. First filter with prereleases=False (to prevent locking to prerelease version without --pre being used #6395 regression)
  2. If no stable versions match AND candidates exist, retry with prereleases=None to allow PEP 440's fallback behavior

This preserves the fix for #6395 (transitive dependencies with prerelease specifiers don't enable prereleases for all packages) while allowing packages that genuinely only have prerelease versions to be installed.

Testing

Added unit tests in tests/unit/test_dependencies.py to verify:

  • Prerelease-only packages are allowed when no stable versions exist
  • Mixed versions still exclude prereleases when stable versions exist
  • The --pre flag works as expected
  • Specifier constraints work correctly with prerelease-only packages

Fixes #6485


Pull Request opened by Augment Code with guidance from the PR author

This fixes issue #6485 where packages like opentelemetry-semantic-conventions
that only have prerelease versions (e.g., 0.60b0) could not be installed
without using the --pre flag.

The fix modifies get_applicable_candidates() in the package finder to:
1. First filter with prereleases=False (to prevent #6395 regression)
2. If no stable versions match AND candidates exist, retry with
   prereleases=None to allow PEP 440's fallback behavior

This preserves the fix for #6395 (transitive dependencies with prerelease
specifiers don't enable prereleases for all packages) while allowing
packages that genuinely only have prerelease versions to be installed.

Fixes #6485
- Sort imports alphabetically (I001)
- Add newline at end of file (W292)
The patch file was malformed with incorrect line numbers and missing
context lines. Regenerated the patch using git diff to ensure proper
format that can be applied during vendoring.
@matteius matteius force-pushed the fix/prerelease-only-packages-6485 branch from aeb4ea6 to 7a113f0 Compare December 10, 2025 22:01
@matteius matteius merged commit 6fb15ab into main Dec 10, 2025
19 of 20 checks passed
@matteius matteius deleted the fix/prerelease-only-packages-6485 branch December 10, 2025 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can`t install opentelemetry-semantic-conventions

1 participant