-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pypi): use local version specifiers for patched whl output (#2365)
Before this change the installation of the patched wheels using `uv` or similar would break. This change fixes that by using local version specifier, which is better than using a build tag when installing the wheels. Before the change: ```console $ cd examples/bzlmod $ bazel build @pip//requests:whl $ uv pip install <path to requests wheel in the example> error: The wheel filename "requests-2.25.1-patched-py2.py3-none-any.whl" has an invalid build tag: must start with a digit ``` After: ``` $ uv pip install <path to requests wheel in the example> Resolved 5 packages in 288ms Prepared 5 packages in 152ms Installed 5 packages in 13ms + certifi==2024.8.30 + chardet==4.0.0 + idna==2.10 + requests==2.25.1+patched (from file:///home/aignas/src/github/aignas/rules_python/examples/bzlmod/bazel-bzlmod/external/rules_python~~pip~pip_39_requests_py2_none_any_c210084e/requests-2.25.1+patched-py2.py3-none-any.whl) + urllib3==1.26.20 ```
- Loading branch information
Showing
5 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
load(":patch_whl_tests.bzl", "patch_whl_test_suite") | ||
|
||
patch_whl_test_suite(name = "patch_whl_tests") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2024 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"" | ||
|
||
load("@rules_testing//lib:test_suite.bzl", "test_suite") | ||
load("//python/private/pypi:patch_whl.bzl", "patched_whl_name") # buildifier: disable=bzl-visibility | ||
|
||
_tests = [] | ||
|
||
def _test_simple(env): | ||
got = patched_whl_name("foo-1.2.3-py3-none-any.whl") | ||
env.expect.that_str(got).equals("foo-1.2.3+patched-py3-none-any.whl") | ||
|
||
_tests.append(_test_simple) | ||
|
||
def _test_simple_local_version(env): | ||
got = patched_whl_name("foo-1.2.3+special-py3-none-any.whl") | ||
env.expect.that_str(got).equals("foo-1.2.3+special.patched-py3-none-any.whl") | ||
|
||
_tests.append(_test_simple_local_version) | ||
|
||
def patch_whl_test_suite(name): | ||
"""Create the test suite. | ||
Args: | ||
name: the name of the test suite | ||
""" | ||
test_suite(name = name, basic_tests = _tests) |