pypi packaging 26.4

one hour ago

What's Changed

Removals

  • Drop support for EOL Python 3.9. (#1354)

Features

  • Add prepare_environment() and Marker.evaluate_prepared() to evaluate many markers against one prepared environment. Pylock.select() now uses them. (#1469)
  • Add __replace__ to Requirement, Specifier, and SpecifierSet, for copy.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() and RangeRelation, which give containment and disjointness in one pass. (#1473)
  • Add interpreter_abi(). (#611)
  • Marker.evaluate() accepts a set of names for extra, to evaluate a marker against several selected extras at once. (#1438)
  • Add message, source, and span attributes to InvalidRequirement and InvalidMarker for 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 pylock and direct_url dataclasses use __slots__. Pickles from 26.3 still load. (#1366, #1548)
  • Version.__replace__() raises TypeError for unknown keyword arguments instead of ignoring them. (#1378)

Fixes for versions and specifiers

  • Parse plain strings in the iterable form of SpecifierSet, and raise TypeError for elements that are not Specifier or str. (#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 copy and pickle for VersionRange, which raised TypeError before. (#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 prereleases override of each specifier when a Requirement is pickled or copied. (#1462)
  • Raise InvalidMarker for markers nested more than 200 levels deep. (#1450)
  • Keep chains of & and | on markers flat, so long chains do not raise. (#1510)
  • Marker.evaluate() raises UndefinedComparison when extras or dependency_groups is a string instead of a set. (#1507)

Fixes for metadata and licenses

  • Validate and serialize inherited fields in Metadata subclasses. (#1454)
  • Reject Windows drive-relative License-File paths like C:LICENSE. (#1382)
  • Use one spelling, the first one, for case variants of a LicenseRef- identifier in canonicalize_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 platforms iterables in cpython_tags(), generic_tags(), and compatible_tags() instead of using the host platforms. (#1360)
  • Detect free-threaded builds in cpython_tags() when a generic ABI such as abi3 or none comes first in abis, or when abis holds only abi3t. (#1555)

Fixes for pylock and dependency groups

  • Pylock.select() raises PylockSelectError for an explicitly empty environments list (#1362), and for unknown extras and dependency groups. (#1376)
  • Get pylock file 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-version 2, such as 2.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_eval for plain marker strings. (#1429)
  • Speed up VersionRange construction, subtraction, comparison, disjointness checks, membership checks, and filtering. (#1458, #1460, #1471, #1506, #1542, #1551, #1556, #1558, #1562, #1563, #1564, #1568)
  • Speed up Version parsing, string conversion, and release validation. (#1520, #1523, #1524, #1538)
  • Speed up Specifier parsing, 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 pylock and requirements API reference (#1393), and for packaging.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 VersionRange and 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 Version in Specifier. (#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 pylock and direct_url objects. (#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

Full Changelog: 26.3...26.4

Don't miss a new packaging release

NewReleases is sending notifications on new releases.