build(deps): bump packaging from 26.2 to 26.3 in /tools/publish (#4032) Bumps [packaging](https://github.com/pypa/packaging) from 26.2 to 26.3. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pypa/packaging/releases">packaging's releases</a>.</em></p> <blockquote> <h2>26.3</h2> <!-- raw HTML omitted --> <h2>What's Changed</h2> <h3>Features</h3> <ul> <li>Add a public <code>VersionRange</code> API and <code>SpecifierSet.to_range()</code>, representing the versions a specifier set accepts as an interval set that supports intersection, union, difference, complement, set relations, membership tests, and filtering. <code>VersionRange.to_specifier_set()</code> converts a range back to a <code>SpecifierSet</code> where a PEP 440 form exists. (<a href="https://redirect.github.com/pypa/packaging/pull/1267">#1267</a>, <a href="https://redirect.github.com/pypa/packaging/pull/1270">#1270</a>, <a href="https://redirect.github.com/pypa/packaging/pull/1298">#1298</a>)</li> <li>PEP 808: accept <code>Metadata-Version: 2.6</code>. (<a href="https://redirect.github.com/pypa/packaging/pull/1194">#1194</a>)</li> <li>Add a <code>limit</code> argument to <code>parse_tag()</code> for compressed tag sets. (<a href="https://redirect.github.com/pypa/packaging/issues/1220">#1220</a>)</li> <li>Add a <code>prefer_sdist_predicate</code> argument to <code>Pylock.select()</code> to prefer source distributions over wheels for selected packages. (<a href="https://redirect.github.com/pypa/packaging/pull/1334">#1334</a>)</li> <li>Add <code>pure_python_tags()</code> to generate the pure-Python tags for a Python version without touching the running platform. (<a href="https://redirect.github.com/pypa/packaging/pull/1346">#1346</a>)</li> <li>Add <code>SpecifierSet.is_subset()</code>, <code>SpecifierSet.is_superset()</code>, and <code>SpecifierSet.is_disjoint()</code>, which compare the versions two specifier sets accept. (<a href="https://redirect.github.com/pypa/packaging/pull/1313">#1313</a>)</li> </ul> <h3>Behavior adaptations</h3> <ul> <li>Drop support for Python 3.8; packaging now requires Python 3.9 or later. (<a href="https://redirect.github.com/pypa/packaging/pull/1157">#1157</a>)</li> <li>Prefer native <code>linux_*</code> platform tags over <code>manylinux</code> and <code>musllinux</code> tags on Linux. (<a href="https://redirect.github.com/pypa/packaging/issues/160">#160</a>)</li> </ul> <h3>Fixes for versions and specifiers</h3> <ul> <li>Raise <code>InvalidVersion</code> instead of <code>TypeError</code> when <code>Version</code> is given a non-string. (<a href="https://redirect.github.com/pypa/packaging/pull/1319">#1319</a>)</li> <li>Raise <code>InvalidVersion</code> for non-string pre-release letters passed to <code>Version.from_parts</code>. (<a href="https://redirect.github.com/pypa/packaging/pull/1241">#1241</a>)</li> <li>Fix an <code>AttributeError</code> when hashing internally trimmed versions. (<a href="https://redirect.github.com/pypa/packaging/pull/1242">#1242</a>)</li> <li>Fix <code>SpecifierSet.is_unsatisfiable</code> for post-release boundary intersections. (<a href="https://redirect.github.com/pypa/packaging/pull/1257">#1257</a>)</li> </ul> <h3>Fixes for requirements and markers</h3> <ul> <li>Make <code>Requirement.__hash__</code> consistent with <code>__eq__</code> for trailing-zero-equivalent specifiers (e.g. <code>foo==1.0.0</code> and <code>foo==1.0.0.0</code>), so equal requirements hash equal and deduplicate in sets and dicts. (<a href="https://redirect.github.com/pypa/packaging/pull/1232">#1232</a>)</li> <li>Normalize requested extra names before comparing or hashing requirements. (<a href="https://redirect.github.com/pypa/packaging/issues/644">#644</a>)</li> <li>Preserve a <code>Requirement</code>'s specifier <code>prereleases</code> override across a pickle round trip. (<a href="https://redirect.github.com/pypa/packaging/issues/1204">#1204</a>)</li> <li>Raise <code>InvalidRequirement</code> instead of <code>InvalidSpecifier</code> when a requirement contains an invalid specifier. (<a href="https://redirect.github.com/pypa/packaging/pull/1332">#1332</a>)</li> <li>Clarify the error for post-release prefix wildcards like <code>==1.0.post1.*</code>. (<a href="https://redirect.github.com/pypa/packaging/pull/1299">#1299</a>)</li> <li>Preserve quoting semantics when serializing marker values, so round-tripped markers parse back to the same marker. (<a href="https://redirect.github.com/pypa/packaging/pull/1213">#1213</a>)</li> <li>Keep the parentheses of a nested group when serializing markers. (<a href="https://redirect.github.com/pypa/packaging/pull/1316">#1316</a>)</li> <li>Normalize <code>extra</code> and <code>dependency_groups</code> values in nested markers at parse time. (<a href="https://redirect.github.com/pypa/packaging/pull/1246">#1246</a>, <a href="https://redirect.github.com/pypa/packaging/pull/1310">#1310</a>)</li> <li>Raise <code>UndefinedComparison</code> when a set-valued variable like <code>extras</code> is used outside the membership form. (<a href="https://redirect.github.com/pypa/packaging/pull/1265">#1265</a>)</li> <li>Raise <code>UndefinedEnvironmentName</code> (a <code>KeyError</code> subclass) for missing environment keys during marker evaluation. (<a href="https://redirect.github.com/pypa/packaging/pull/1276">#1276</a>)</li> <li>Wrap malformed string literal errors in <code>InvalidMarker</code> / <code>InvalidRequirement</code> instead of leaking a low-level error. (<a href="https://redirect.github.com/pypa/packaging/pull/1249">#1249</a>)</li> <li>Reject requirements and markers with a trailing line break. (<a href="https://redirect.github.com/pypa/packaging/pull/1345">#1345</a>)</li> </ul> <h3>Fixes for metadata and licenses</h3> <ul> <li>Collect all <code>from_email</code> validation errors into one <code>ExceptionGroup</code> instead of raising the first. (<a href="https://redirect.github.com/pypa/packaging/pull/1268">#1268</a>)</li> <li>Accept the UTF-8 charset case-insensitively in email payloads. (<a href="https://redirect.github.com/pypa/packaging/pull/1330">#1330</a>)</li> <li>Reject malformed <code>Description-Content-Type</code> values. (<a href="https://redirect.github.com/pypa/packaging/pull/1329">#1329</a>)</li> <li>Don't rewrite user values that contain <code>{field}</code> placeholders in error messages. (<a href="https://redirect.github.com/pypa/packaging/pull/1327">#1327</a>)</li> <li>Route multipart email payloads to <code>unparsed</code> instead of asserting. (<a href="https://redirect.github.com/pypa/packaging/pull/1247">#1247</a>)</li> <li>Make <code>InvalidMetadata</code> and <code>CyclicDependencyGroup</code> picklable. (<a href="https://redirect.github.com/pypa/packaging/pull/1328">#1328</a>)</li> <li>Fold every line boundary <code>str.splitlines</code> recognizes when writing a header with <code>RFC822Message</code>. (<a href="https://redirect.github.com/pypa/packaging/pull/1356">#1356</a>)</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/pypa/packaging/blob/main/CHANGELOG.rst">packaging's changelog</a>.</em></p> <blockquote> <p>26.3 - 2026-08-03</p> <pre><code> Features: <ul> <li>Add a public :class:<code>~packaging.ranges.VersionRange</code> API and<br /> :meth:<code>SpecifierSet.to_range() &lt;packaging.specifiers.SpecifierSet.to_range&gt;</code>,<br /> representing the versions a specifier set accepts as an interval set that<br /> supports intersection, union, difference, complement, set relations,<br /> membership tests, and filtering.<br /> :meth:<code>~packaging.ranges.VersionRange.to_specifier_set</code> converts a range back<br /> to a :class:<code>~packaging.specifiers.SpecifierSet</code> where a PEP 440 form exists.<br /> (:pull:<code>1267</code>, :pull:<code>1270</code>, :pull:<code>1298</code>)</li> <li>PEP 808: accept <code>Metadata-Version: 2.6</code>. (:pull:<code>1194</code>)</li> <li>Add a <code>limit</code> argument to <code>parse_tag()</code> for compressed tag sets.<br /> (:issue:<code>1220</code>)</li> <li>Add a <code>prefer_sdist_predicate</code> argument to <code>Pylock.select()</code> to prefer<br /> source distributions over wheels for selected packages. (:pull:<code>1334</code>)</li> <li>Add :func:<code>~packaging.tags.pure_python_tags</code> to generate the pure-Python<br /> tags for a Python version without touching the running platform.<br /> (:pull:<code>1346</code>)</li> <li>Add :meth:<code>SpecifierSet.is_subset() &lt;packaging.specifiers.SpecifierSet.is_subset&gt;</code>, :meth:<code>~packaging.specifiers.SpecifierSet.is_superset</code>,<br /> and :meth:<code>~packaging.specifiers.SpecifierSet.is_disjoint</code>, which compare the<br /> versions two specifier sets accept. (:pull:<code>1313</code>)</li> </ul> <p>Behavior adaptations:</p> <ul> <li>Drop support for Python 3.8; packaging now requires Python 3.9 or later.<br /> (:pull:<code>1157</code>)</li> <li>Prefer native <code>linux_*</code> platform tags over <code>manylinux</code> and <code>musllinux</code><br /> tags on Linux. (:issue:<code>160</code>)</li> </ul> <p>Fixes for versions and specifiers:</p> <ul> <li>Raise <code>InvalidVersion</code> instead of <code>TypeError</code> when <code>Version</code> is given a<br /> non-string. (:pull:<code>1319</code>)</li> <li>Raise <code>InvalidVersion</code> for non-string pre-release letters passed to<br /> <code>Version.from_parts</code>. (:pull:<code>1241</code>)</li> <li>Fix an <code>AttributeError</code> when hashing internally trimmed versions.<br /> (:pull:<code>1242</code>)</li> <li>Fix <code>SpecifierSet.is_unsatisfiable</code> for post-release boundary<br /> intersections. (:pull:<code>1257</code>)</li> </ul> <p>Fixes for requirements and markers:</p> <ul> <li>Make <code>Requirement.__hash__</code> consistent with <code>__eq__</code> for<br /> trailing-zero-equivalent specifiers (e.g. <code>foo==1.0.0</code> and<br /> <code>foo==1.0.0.0</code>), so equal requirements hash equal and deduplicate in<br /> sets and dicts. (:pull:<code>1232</code>)<br /> </tr></table><br /> </code></pre></li> </ul> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pypa/packaging/commit/929fd4b1410ac7ef61ef3f45b2f5d7e87711a9b5"><code>929fd4b</code></a> Bump for release</li> <li><a href="https://github.com/pypa/packaging/commit/f300ebf0c155e1f7ea6d62fba11dba4bac3d1944"><code>f300ebf</code></a> chore(deps): bump the pre-commit group with 5 updates (<a href="https://redirect.github.com/pypa/packaging/issues/1357">#1357</a>)</li> <li><a href="https://github.com/pypa/packaging/commit/f91d97566a966177ad7ea5a7c703b12a7273e3b1"><code>f91d975</code></a> ci(downstream): bump hatchling to 1.31.0 and fix its pytest rootdir (<a href="https://redirect.github.com/pypa/packaging/issues/1361">#1361</a>)</li> <li><a href="https://github.com/pypa/packaging/commit/b1a7124fe3d40c3302c029e9eb01ac3fc3496a54"><code>b1a7124</code></a> chore(deps): bump the github-actions group with 7 updates (<a href="https://redirect.github.com/pypa/packaging/issues/1358">#1358</a>)</li> <li><a href="https://github.com/pypa/packaging/commit/2d873eb6002021a8c007c933fbdab58b37a5079b"><code>2d873eb</code></a> fix(metadata): fold every line boundary when writing headers (<a href="https://redirect.github.com/pypa/packaging/issues/1356">#1356</a>)</li> <li><a href="https://github.com/pypa/packaging/commit/413d006fadf5b9b14d78ad444201d8189bff8c64"><code>413d006</code></a> docs: changelog for 26.3 (<a href="https://redirect.github.com/pypa/packaging/issues/1343">#1343</a>)</li> <li><a href="https://github.com/pypa/packaging/commit/4eb0753dba8fcaaac8eb75463374e448f0931558"><code>4eb0753</code></a> docs(metadata): explain selective field validation (<a href="https://redirect.github.com/pypa/packaging/issues/1342">#1342</a>)</li> <li><a href="https://github.com/pypa/packaging/commit/77e9ed42b6db9c5c011a5148047a356ebe42692a"><code>77e9ed4</code></a> feat(tags): add pure Python tag generator (<a href="https://redirect.github.com/pypa/packaging/issues/1346">#1346</a>)</li> <li><a href="https://github.com/pypa/packaging/commit/7cea5e88671ed14016e9ab3dd08eab064f596564"><code>7cea5e8</code></a> ci: drop 3.13t on Windows (3.13.14t may fail to build, run takes 9 minutes) (...</li> <li><a href="https://github.com/pypa/packaging/commit/45a8b3402db5ff82158f2d0eabaf8447aa7a50bf"><code>45a8b34</code></a> docs: add missing versionadded/versionchanged directives (<a href="https://redirect.github.com/pypa/packaging/issues/1344">#1344</a>)</li> <li>Additional commits viewable in <a href="https://github.com/pypa/packaging/compare/26.2...26.3">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This repository is the home of the core Python rules -- py_library, py_binary, py_test, and related symbols that provide the basis for Python support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.
Documentation for rules_python is at https://rules-python.readthedocs.io and in the Bazel Build Encyclopedia.
Examples live in the examples directory.
The core rules are stable. Their implementation is subject to Bazel's backward compatibility policy. This repository aims to follow semantic versioning.
The Bazel community maintains this repository. Neither Google nor the Bazel team provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases. See How to contribute page for information on our development workflow.
requirements.txt is how users have been defining dependencies for a long time. We support this to support legacy usecases or package managers that we don't support directly. Any additional information that we need will be retrieved from the SimpleAPI during the bzlmod extension evaluation phase. Then it will be written to the MODULE.bazel.lock file for future reuse. We have plans to support uv.lock file directly. uv is recommended for generating a fully locked requirements.txt file and we do provide a rule for it.py_binary, py_test rules should scale to large monorepos and we work hard to minimize the work done during analysis and build phase. What is more, the space requirements for should be minimal, so we strive to use symlinks rather than extracting wheels at build time. This means that for different configurations of the same build, we are not extracting the wheel multiple times thus scaling better over the time. From 2.0 onwards we are creating a virtual env for each target by creating an actual minimal virtual environment using symlinks. We plan on creating the traditional site-packages layout in the future by default.rules_python and this has resulted in a few PEPs supported within pure starlark - PEP440, PEP509.Common misconceptions:
rules_python has to keep backwards compatibility with google3. Whilst this might have been true in the past, rules_python is an open source project and any compatibility needs should come from the community - we have no requirement to keep this compatibility and are allowed to make our decisions. However, we do want to keep backwards compatibility as long as possible to not upset users with never ending migrations.rules_python is not caching pip downloads. With 2.0, we use Bazel's downloader by default and rely on bazel to provide the repository caching mechanisms. This means that for simpler setups this should result in transparent and scalable caching with the most recent bazel versions unless there are issues in the bazel itself.For detailed documentation, see https://rules-python.readthedocs.io
See Bzlmod support for more details.