@@ -151,61 +151,37 @@ toolchain_aliases(
151151 rctx .file ("defs.bzl" , content = """\
152152 # Generated by python/private/toolchains_repo.bzl
153153
154- load("{rules_python}//python/config_settings:transition.bzl", "with_deprecation")
154+ load("{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements")
155+ load("{rules_python}//python/private:deprecation.bzl", "with_deprecation")
156+ load("{rules_python}//python/private:text_util.bzl", "render")
155157load("{rules_python}//python:py_binary.bzl", _py_binary = "py_binary")
156158load("{rules_python}//python:py_test.bzl", _py_test = "py_test")
157159load(
158160 "{rules_python}//python/entry_points:py_console_script_binary.bzl",
159161 _py_console_script_binary = "py_console_script_binary",
160162)
161- load("{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements")
162163
163- def py_binary(** kwargs):
164- return _py_binary(
165- ** with_deprecation(
166- kwargs,
167- symbol_name = "py_binary" ,
168- python_version = "{python_version} ",
169- deprecated = "@{name}//:defs .bzl",
170- ),
164+ def _with_deprecation( kwargs, *, name ):
165+ kwargs["python_version"] = "{python_version}"
166+ return with_deprecation.symbol (
167+ kwargs,
168+ symbol_name = name ,
169+ old_load = "@{name}//:defs.bzl ",
170+ new_load = "@rules_python//python:{{}} .bzl".format(name) ,
171+ snippet = render.call(name, **{{k: repr(v) for k,v in kwargs.items()}})
171172 )
172173
173- def py_console_script_binary(name, **kwargs):
174- return _py_console_script_binary(
175- name = name,
176- binary_rule = _py_binary,
177- **with_deprecation(
178- kwargs,
179- symbol_name = "py_console_script_binary",
180- load_name = "/entry_points:py_console_script_binary",
181- python_version = "{python_version}",
182- deprecated = "@{name}//:defs.bzl",
183- ),
184- )
174+ def py_binary(**kwargs):
175+ return _py_binary(**_with_deprecation(kwargs, name = "py_binary"))
185176
186- def py_test(name, **kwargs):
187- return _py_test(
188- name = name,
189- **with_deprecation(
190- kwargs,
191- symbol_name = "py_test",
192- python_version = "{python_version}",
193- deprecated = "@{name}//:defs.bzl",
194- ),
195- )
177+ def py_console_script_binary(**kwargs):
178+ return _py_console_script_binary(**_with_deprecation(kwargs, name = "py_console_script_binary"))
196179
197- def compile_pip_requirements(name, **kwargs):
198- return _compile_pip_requirements(
199- name = name,
200- **with_deprecation(
201- kwargs,
202- symbol_name = "compile_pip_requirements",
203- load_name = "pip",
204- python_version = "{python_version}",
205- deprecated = "@{name}//:defs.bzl",
206- ),
207- )
180+ def py_test(**kwargs):
181+ return _py_test(**_with_deprecation(kwargs, name = "py_test"))
208182
183+ def compile_pip_requirements(**kwargs):
184+ return _compile_pip_requirements(**_with_deprecation(kwargs, name = "compile_pip_requirements"))
209185""" .format (
210186 name = rctx .attr .name ,
211187 python_version = rctx .attr .python_version ,
@@ -332,66 +308,42 @@ def _multi_toolchain_aliases_impl(rctx):
332308 rctx .file (file , content = """\
333309 # Generated by python/private/toolchains_repo.bzl
334310
335- load("@@{rules_python}//python/config_settings:transition.bzl", "with_deprecation")
336- load("@@{rules_python}//python:py_binary.bzl", _py_binary = "py_binary")
337- load("@@{rules_python}//python:py_test.bzl", _py_test = "py_test")
311+ load("{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements")
312+ load("{rules_python}//python/private:deprecation.bzl", "with_deprecation")
313+ load("{rules_python}//python/private:text_util.bzl", "render")
314+ load("{rules_python}//python:py_binary.bzl", _py_binary = "py_binary")
315+ load("{rules_python}//python:py_test.bzl", _py_test = "py_test")
338316load(
339- "@@ {rules_python}//python/entry_points:py_console_script_binary.bzl",
317+ "{rules_python}//python/entry_points:py_console_script_binary.bzl",
340318 _py_console_script_binary = "py_console_script_binary",
341319)
342- load("@@{rules_python}//python:pip.bzl", _compile_pip_requirements = "compile_pip_requirements")
343320
344- def py_binary(** kwargs):
345- return _py_binary(
346- ** with_deprecation(
347- kwargs,
348- symbol_name = "py_binary" ,
349- python_version = "{ python_version}",
350- deprecated = "@{name}//{python_version}:defs .bzl",
351- ),
321+ def _with_deprecation( kwargs, *, name ):
322+ kwargs["python_version"] = "{python_version}"
323+ return with_deprecation.symbol (
324+ kwargs,
325+ symbol_name = name ,
326+ old_load = "@{name}//{ python_version}:defs.bzl ",
327+ new_load = "@rules_python//python:{{}} .bzl".format(name) ,
328+ snippet = render.call(name, **{{k: repr(v) for k,v in kwargs.items()}})
352329 )
353330
354- def py_console_script_binary(name, **kwargs):
355- return _py_console_script_binary(
356- name = name,
357- binary_rule = _py_binary,
358- **with_deprecation(
359- kwargs,
360- symbol_name = "py_console_script_binary",
361- load_name = "/entry_points:py_console_script_binary",
362- python_version = "{python_version}",
363- deprecated = "@{name}//{python_version}:defs.bzl",
364- ),
365- )
331+ def py_binary(**kwargs):
332+ return _py_binary(**_with_deprecation(kwargs, name = "py_binary"))
366333
367- def py_test(name, **kwargs):
368- return _py_test(
369- name = name,
370- **with_deprecation(
371- kwargs,
372- symbol_name = "py_test",
373- python_version = "{python_version}",
374- deprecated = "@{name}//{python_version}:defs.bzl",
375- ),
376- )
334+ def py_console_script_binary(**kwargs):
335+ return _py_console_script_binary(**_with_deprecation(kwargs, name = "py_console_script_binary"))
377336
378- def compile_pip_requirements(name, **kwargs):
379- return _compile_pip_requirements(
380- name = name,
381- **with_deprecation(
382- kwargs,
383- symbol_name = "compile_pip_requirements",
384- load_name = "pip",
385- python_version = "{python_version}",
386- deprecated = "@{name}//{python_version}:defs.bzl",
387- ),
388- )
337+ def py_test(**kwargs):
338+ return _py_test(**_with_deprecation(kwargs, name = "py_test"))
389339
340+ def compile_pip_requirements(**kwargs):
341+ return _compile_pip_requirements(**_with_deprecation(kwargs, name = "compile_pip_requirements"))
390342""" .format (
391343 repository_name = repository_name ,
392344 name = rctx .attr .name ,
393345 python_version = python_version ,
394- rules_python = rules_python ,
346+ rules_python = "@" + rules_python ,
395347 ))
396348 rctx .file ("{}/BUILD.bazel" .format (python_version ), "" )
397349
0 commit comments