Skip to content

Commit 2653573

Browse files
committed
fix: escape more invalid repo string characters
Fixes #2799
1 parent c981569 commit 2653573

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

python/private/pypi/whl_repo_name.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def whl_repo_name(filename, sha256):
4444
else:
4545
parsed = parse_whl_name(filename)
4646
name = normalize_name(parsed.distribution)
47-
version = parsed.version.replace(".", "_").replace("!", "_")
47+
version = parsed.version.replace(".", "_").replace("!", "_").replace("+", "_").replace("%", "_")
4848
python_tag, _, _ = parsed.python_tag.partition(".")
4949
abi_tag, _, _ = parsed.abi_tag.partition(".")
5050
platform_tag, _, _ = parsed.platform_tag.partition(".")

tests/pypi/whl_repo_name/whl_repo_name_tests.bzl

+12
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ def _test_platform_whl(env):
5454

5555
_tests.append(_test_platform_whl)
5656

57+
def _test_name_with_plus(env):
58+
got = whl_repo_name("gptqmodel-2.0.0+cu126torch2.6-cp312-cp312-linux_x86_64.whl", "")
59+
env.expect.that_str(got).equals("gptqmodel_2_0_0_cu126torch2_6_cp312_cp312_linux_x86_64")
60+
61+
_tests.append(_test_name_with_plus)
62+
63+
def _test_name_with_percent(env):
64+
got = whl_repo_name("gptqmodel-2.0.0%2Bcu126torch2.6-cp312-cp312-linux_x86_64.whl", "")
65+
env.expect.that_str(got).equals("gptqmodel_2_0_0_2Bcu126torch2_6_cp312_cp312_linux_x86_64")
66+
67+
_tests.append(_test_name_with_percent)
68+
5769
def whl_repo_name_test_suite(name):
5870
"""Create the test suite.
5971

0 commit comments

Comments
 (0)