What's Changed
Removals
- Drop support for EOL Python 3.9. (#1354)
Features
- Add
prepare_environment()andMarker.evaluate_prepared()to evaluate many markers against one prepared environment.Pylock.select()now uses them. (#1469) - Add
__replace__toRequirement,Specifier, andSpecifierSet, forcopy.replace()on Python 3.13+. (#1377, #1457) - Add
VersionRange.from_bounds()to make a range from explicit bounds. (#1475) - Add
VersionRange.snap_bounds()to move range endpoints onto known versions. (#1477) - Add
VersionRange.relation()andRangeRelation, which give containment and disjointness in one pass. (#1473) - Add
interpreter_abi(). (#611) Marker.evaluate()accepts a set of names forextra, to evaluate a marker against several selected extras at once. (#1438)- Add
message,source, andspanattributes toInvalidRequirementandInvalidMarkerfor syntax errors. (#1547, #1554)
Behavior adaptations
str()of markers joined with&or|has fewer parentheses when unambiguous. Evaluation and parsed markers do not change. (#1510)- The
pylockanddirect_urldataclasses use__slots__. Pickles from 26.3 still load. (#1366, #1548) Version.__replace__()raisesTypeErrorfor unknown keyword arguments instead of ignoring them. (#1378)
Fixes for versions and specifiers
- Parse plain strings in the iterable form of
SpecifierSet, and raiseTypeErrorfor elements that are notSpecifierorstr. (#1485) - Reject an empty arbitrary-equality version (
===) in specifiers and requirements. (#1430) - Reject non-ASCII letters in
~=pre, post, and dev segments. (#1384) - Keep the explicit pre-release opt-in of a literal pre-release version that overlaps an ordinary bound in a
VersionRange. (#1511) - Support
copyandpickleforVersionRange, which raisedTypeErrorbefore. (#1504)
Fixes for requirements and markers
- Reject all whitespace in the URL of a requirement, including Unicode whitespace such as a no-break space. (#1379)
- Parse
===followed by a comma and a spaced specifier in a requirement. (#1531) - Keep the
prereleasesoverride of each specifier when aRequirementis pickled or copied. (#1462) - Raise
InvalidMarkerfor markers nested more than 200 levels deep. (#1450) - Keep chains of
&and|on markers flat, so long chains do not raise. (#1510) Marker.evaluate()raisesUndefinedComparisonwhenextrasordependency_groupsis a string instead of a set. (#1507)
Fixes for metadata and licenses
- Validate and serialize inherited fields in
Metadatasubclasses. (#1454) - Reject Windows drive-relative
License-Filepaths likeC:LICENSE. (#1382) - Use one spelling, the first one, for case variants of a
LicenseRef-identifier incanonicalize_license_expression(). (#1412) - Reject non-ASCII
LicenseRef-identifiers before normalization. (#1481)
Fixes for tags and filenames
- Reject wheel build tags that contain a line break. (#1427)
- Keep explicitly empty
platformsiterables incpython_tags(),generic_tags(), andcompatible_tags()instead of using the host platforms. (#1360) - Detect free-threaded builds in
cpython_tags()when a generic ABI such asabi3ornonecomes first inabis, or whenabisholds onlyabi3t. (#1555)
Fixes for pylock and dependency groups
Pylock.select()raisesPylockSelectErrorfor an explicitly emptyenvironmentslist (#1362), and for unknown extras and dependency groups. (#1376)- Get
pylockfile names from paths with mixed Windows path separators. (#1436) - Require the complete file name to match in
is_valid_pylock_path(). (#1446) - Reject pre-releases of
lock-version2, such as2.0rc1. (#1522) - Collect errors from all includes in dependency groups, including sibling includes after a parse error and includes in malformed groups, and report each failing group once. (#1411, #1439, #1492)
- Name the correct group when a dependency group includes itself with a different spelling. (#1519)
Performance
- Support lazy imports on Python 3.15+. (#1129)
- Cache the canonical form of a
Specifier. (#1372) - Speed up and cache
str(Marker). (#1371, #1459) - Avoid
literal_evalfor plain marker strings. (#1429) - Speed up
VersionRangeconstruction, subtraction, comparison, disjointness checks, membership checks, and filtering. (#1458, #1460, #1471, #1506, #1542, #1551, #1556, #1558, #1562, #1563, #1564, #1568) - Speed up
Versionparsing, string conversion, and release validation. (#1520, #1523, #1524, #1538) - Speed up
Specifierparsing, string conversion, hashing, and equality. (#1529, #1544, #1571) - Speed up
Specifier.contains()for simple comparisons. (#1536) - Speed up marker and requirement parsing. (#1494, #1495, #1525, #1545)
- Validate license expressions without compiling Python code. (#1527)
Documentation
- Add a GitHub link next to the page icons. (#1444)
- Use autodoc for the
pylockandrequirementsAPI reference (#1393), and forpackaging.tags.INTERPRETER_SHORT_NAMES. (#1491) - Fix duplicated words in comments and docstrings. (#1516)
- Update the contribution guide for batched changelog edits and remove PyPy 3.9 from the nox example. (#1383, #1456)
Benchmarks
- Add Python 3.15 to the benchmarks. (#1380)
- Add
VersionRangeand PubGrub resolver benchmarks. (#1541, #1543, #1570) - Report benchmark changes in a summary table and as PR comments. (#1526, #1528)
- Make the cold benchmarks independent of internal caches, and do not filter compatible release examples in tests. (#1407, #1508)
Internal
- Modernize the code for Python 3.10. (#1347, #1365, #1367, #1368, #1369)
- Give an unbounded end of a range one spelling, so that it compares and hashes the same. (#1392)
- Remove unused constants in
metadata. (#1488) - Speed up the test suite. (#1385, #1386, #1387, #1388, #1389, #1390, #1391)
- Support parallel nox sessions. (#1381)
- Simplify the cached spec
VersioninSpecifier. (#1539) - Update the downstream test projects. (#1400, #1479, #1490, #1493)
- Type the marker tree and parser return values precisely. (#1513, #1517)
- Skip GC freezing for property tests, and cover overlapping pre-release literals in ranges. (#1514, #1515)
- Test that pickles from 26.2 and 26.3 load, including
pylockanddirect_urlobjects. (#1550) - Update CI: test feature branches, always run lint, check all test jobs, set up in parallel, and pin the oldest Python jobs to Ubuntu 24.04. (#1355, #1414, #1423, #1441, #1442, #1443, #1463)
- Update GitHub Actions and pre-commit hooks. (#1401, #1402, #1432, #1433, #1483, #1484)
New Contributors
- @glaziermag made their first contribution in #1414
- @Johnny-Kao made their first contribution in #1429
- @Str0k made their first contribution in #1411
- @feiiiiii5 made their first contribution in #1427
- @Boulea7 made their first contribution in #1430
- @kokotatan made their first contribution in #1436
- @fhgffy made their first contribution in #1446
- @LouisDeconinck made their first contribution in #1407
- @HyperionBurn made their first contribution in #1456
- @duriantaco made their first contribution in #1488
- @AryanRG made their first contribution in #1454
- @simpleqt made their first contribution in #1485
- @zheng-guannan577 made their first contribution in #1491
- @AlvaroBalbin made their first contribution in #1481
- @MarcoGorelli made their first contribution in #1513
- @anticipate218 made their first contribution in #1511
- @ninglinLiu made their first contribution in #1516
- @DicksonWu654 made their first contribution in #1494
- @g4lb made their first contribution in #1520
- @kun654 made their first contribution in #1519
- @KRRT7 made their first contribution in #1450
- @parijat1222q made their first contribution in #1504
- @farisbasha made their first contribution in #1553
- @CharoenwitKunna made their first contribution in #1565
Full Changelog: 26.3...26.4