@@ -73,11 +73,11 @@ _tests.append(_test_all_legacy_aliases_are_created)
7373
7474def _test_bzlmod_aliases (env ):
7575 actual = render_pkg_aliases (
76- default_version = "3.2.3 " ,
76+ default_version = "3.2" ,
7777 repo_name = "pypi" ,
7878 rules_python = "rules_python" ,
7979 whl_map = {
80- "bar-baz" : ["3.2.3 " ],
80+ "bar-baz" : ["3.2" ],
8181 },
8282 )
8383
9494 name = "pkg",
9595 actual = select(
9696 {
97- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:pkg",
97+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg",
9898 "//conditions:default": "@pypi_32_bar_baz//:pkg",
9999 },
100100 ),
@@ -104,7 +104,7 @@ alias(
104104 name = "whl",
105105 actual = select(
106106 {
107- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:whl",
107+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl",
108108 "//conditions:default": "@pypi_32_bar_baz//:whl",
109109 },
110110 ),
@@ -114,7 +114,7 @@ alias(
114114 name = "data",
115115 actual = select(
116116 {
117- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:data",
117+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data",
118118 "//conditions:default": "@pypi_32_bar_baz//:data",
119119 },
120120 ),
@@ -124,7 +124,7 @@ alias(
124124 name = "dist_info",
125125 actual = select(
126126 {
127- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:dist_info",
127+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info",
128128 "//conditions:default": "@pypi_32_bar_baz//:dist_info",
129129 },
130130 ),
@@ -141,7 +141,7 @@ def _test_bzlmod_aliases_with_no_default_version(env):
141141 repo_name = "pypi" ,
142142 rules_python = "rules_python" ,
143143 whl_map = {
144- "bar-baz" : ["3.2.3 " , "3.1.3 " ],
144+ "bar-baz" : ["3.2" , "3.1" ],
145145 },
146146 )
147147
@@ -154,7 +154,7 @@ No matching wheel for current configuration's Python version.
154154
155155The current build configuration's Python version doesn't match any of the Python
156156versions available for this wheel. This wheel supports the following Python versions:
157- 3.1.3 , 3.2.3
157+ 3.1, 3.2
158158
159159As matched by the `@rules_python//python/config_settings:is_python_<version>`
160160configuration settings.
@@ -177,8 +177,8 @@ alias(
177177 name = "pkg",
178178 actual = select(
179179 {
180- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:pkg",
181- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:pkg",
180+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:pkg",
181+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg",
182182 },
183183 no_match_error = _NO_MATCH_ERROR,
184184 ),
@@ -188,8 +188,8 @@ alias(
188188 name = "whl",
189189 actual = select(
190190 {
191- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:whl",
192- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:whl",
191+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:whl",
192+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl",
193193 },
194194 no_match_error = _NO_MATCH_ERROR,
195195 ),
@@ -199,8 +199,8 @@ alias(
199199 name = "data",
200200 actual = select(
201201 {
202- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:data",
203- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:data",
202+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:data",
203+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data",
204204 },
205205 no_match_error = _NO_MATCH_ERROR,
206206 ),
@@ -210,8 +210,8 @@ alias(
210210 name = "dist_info",
211211 actual = select(
212212 {
213- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:dist_info",
214- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:dist_info",
213+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:dist_info",
214+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info",
215215 },
216216 no_match_error = _NO_MATCH_ERROR,
217217 ),
@@ -224,11 +224,18 @@ _tests.append(_test_bzlmod_aliases_with_no_default_version)
224224
225225def _test_bzlmod_aliases_for_non_root_modules (env ):
226226 actual = render_pkg_aliases (
227- default_version = "3.2.4" ,
227+ # NOTE @aignas 2024-01-17: if the default X.Y version coincides with the
228+ # versions that are used in the root module, then this would be the same as
229+ # as _test_bzlmod_aliases.
230+ #
231+ # However, if the root module uses a different default version than the
232+ # non-root module, then we will have a no-match-error because the default_version
233+ # is not in the list of the versions in the whl_map.
234+ default_version = "3.3" ,
228235 repo_name = "pypi" ,
229236 rules_python = "rules_python" ,
230237 whl_map = {
231- "bar-baz" : ["3.2.3 " , "3.1.3 " ],
238+ "bar-baz" : ["3.2" , "3.1" ],
232239 },
233240 )
234241
@@ -241,7 +248,7 @@ No matching wheel for current configuration's Python version.
241248
242249The current build configuration's Python version doesn't match any of the Python
243250versions available for this wheel. This wheel supports the following Python versions:
244- 3.1.3 , 3.2.3
251+ 3.1, 3.2
245252
246253As matched by the `@rules_python//python/config_settings:is_python_<version>`
247254configuration settings.
@@ -264,8 +271,8 @@ alias(
264271 name = "pkg",
265272 actual = select(
266273 {
267- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:pkg",
268- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:pkg",
274+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:pkg",
275+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:pkg",
269276 },
270277 no_match_error = _NO_MATCH_ERROR,
271278 ),
@@ -275,8 +282,8 @@ alias(
275282 name = "whl",
276283 actual = select(
277284 {
278- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:whl",
279- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:whl",
285+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:whl",
286+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:whl",
280287 },
281288 no_match_error = _NO_MATCH_ERROR,
282289 ),
@@ -286,8 +293,8 @@ alias(
286293 name = "data",
287294 actual = select(
288295 {
289- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:data",
290- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:data",
296+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:data",
297+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:data",
291298 },
292299 no_match_error = _NO_MATCH_ERROR,
293300 ),
@@ -297,8 +304,8 @@ alias(
297304 name = "dist_info",
298305 actual = select(
299306 {
300- "@@rules_python//python/config_settings:is_python_3.1.3 ": "@pypi_31_bar_baz//:dist_info",
301- "@@rules_python//python/config_settings:is_python_3.2.3 ": "@pypi_32_bar_baz//:dist_info",
307+ "@@rules_python//python/config_settings:is_python_3.1": "@pypi_31_bar_baz//:dist_info",
308+ "@@rules_python//python/config_settings:is_python_3.2": "@pypi_32_bar_baz//:dist_info",
302309 },
303310 no_match_error = _NO_MATCH_ERROR,
304311 ),
@@ -311,12 +318,12 @@ _tests.append(_test_bzlmod_aliases_for_non_root_modules)
311318
312319def _test_bzlmod_aliases_are_created_for_all_wheels (env ):
313320 actual = render_pkg_aliases (
314- default_version = "3.2.3 " ,
321+ default_version = "3.2" ,
315322 repo_name = "pypi" ,
316323 rules_python = "rules_python" ,
317324 whl_map = {
318- "bar" : ["3.1.2 " , "3.2.3 " ],
319- "foo" : ["3.1.2 " , "3.2.3 " ],
325+ "bar" : ["3.1" , "3.2" ],
326+ "foo" : ["3.1" , "3.2" ],
320327 },
321328 )
322329
0 commit comments