Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 188598a

Browse filesBrowse files
aignasrickeylev
andauthored
chore: remove internal usage of deprecated py_binary ad py_test (bazel-contrib#2569)
This goes together with bazel-contrib#2565 to remove the internal usage of the deprecated symbols. This also fixes the compile_pip_requirements symbol to print the correct deprecation message. Builds on top of 611eda8 The example message that would be printed is as follows: ``` The 'py_test' symbol in '@+python+python_3_11//:defs.bzl' is deprecated. It is an alias to the regular rule; use it directly instead: load("@rules_python//python:py_test.bzl", "py_test") py_test( name = "versioned_py_test", srcs = ["dummy.py"], main = "dummy.py", python_version = "3.11.11", ) ``` --------- Co-authored-by: Richard Levasseur <richardlev@gmail.com>
1 parent 50a9a2e commit 188598a
Copy full SHA for 188598a

File tree

22 files changed

+336
-119
lines changed
Filter options

22 files changed

+336
-119
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Unreleased changes template.
5454
### Changed
5555
* (pypi) {obj}`pip.override` will now be ignored instead of raising an error,
5656
fixes [#2550](https://github.com/bazelbuild/rules_python/issues/2550).
57+
* (rules) deprecation warnings for deprecated symbols have been turned off by
58+
default for now and can be enabled with `RULES_PYTHON_DEPRECATION_WARNINGS`
59+
env var.
5760

5861
{#v0-0-0-fixed}
5962
### Fixed

‎MODULE.bazel

Copy file name to clipboardExpand all lines: MODULE.bazel
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ python.toolchain(
4646
is_default = True,
4747
python_version = "3.11",
4848
)
49-
use_repo(python, "python_3_11", "python_versions", "pythons_hub")
49+
use_repo(
50+
python,
51+
"python_3_11",
52+
"pythons_hub",
53+
python = "python_versions",
54+
)
5055

5156
# This call registers the Python toolchains.
5257
register_toolchains("@pythons_hub//:all")

‎WORKSPACE

Copy file name to clipboardExpand all lines: WORKSPACE
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ load("//:internal_dev_setup.bzl", "rules_python_internal_setup")
6868

6969
rules_python_internal_setup()
7070

71-
load("@pythons_hub//:versions.bzl", "MINOR_MAPPING", "PYTHON_VERSIONS")
71+
load("@pythons_hub//:versions.bzl", "PYTHON_VERSIONS")
7272
load("//python:repositories.bzl", "python_register_multi_toolchains")
7373

7474
python_register_multi_toolchains(
7575
name = "python",
76-
default_version = MINOR_MAPPING.values()[-3], # Use 3.11.10
76+
default_version = "3.11",
7777
# Integration tests verify each version, so register all of them.
7878
python_versions = PYTHON_VERSIONS,
7979
)

‎docs/environment-variables.md

Copy file name to clipboardExpand all lines: docs/environment-variables.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ When `1`, bzlmod extensions will print debug information about what they're
4040
doing. This is mostly useful for development to debug errors.
4141
:::
4242

43+
:::{envvar} RULES_PYTHON_DEPRECATION_WARNINGS
44+
45+
When `1`, the rules_python will warn users about deprecated functionality that will
46+
be removed in a subsequent major `rules_python` version. Defaults to `0` if unset.
47+
:::
48+
4349
:::{envvar} RULES_PYTHON_ENABLE_PYSTAR
4450

4551
When `1`, the rules_python Starlark implementation of the core rules is used
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
load("@python_versions//3.11:defs.bzl", compile_pip_requirements_311 = "compile_pip_requirements")
1+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
22

33
# NOTE: To update the requirements, you need to uncomment the rules_python
44
# override in the MODULE.bazel.
5-
compile_pip_requirements_311(
5+
compile_pip_requirements(
66
name = "requirements",
77
src = "requirements.in",
8+
python_version = "3.11",
89
requirements_txt = "requirements_lock_3_11.txt",
910
)

‎examples/bzlmod/other_module/other_module/pkg/BUILD.bazel

Copy file name to clipboardExpand all lines: examples/bzlmod/other_module/other_module/pkg/BUILD.bazel
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
load(
2-
"@python_3_11//:defs.bzl",
3-
py_binary_311 = "py_binary",
4-
)
1+
load("@rules_python//python:py_binary.bzl", "py_binary")
52
load("@rules_python//python:py_library.bzl", "py_library")
63

74
py_library(
@@ -15,11 +12,12 @@ py_library(
1512
# This is used for testing mulitple versions of Python. This is
1613
# used only when you need to support multiple versions of Python
1714
# in the same project.
18-
py_binary_311(
15+
py_binary(
1916
name = "bin",
2017
srcs = ["bin.py"],
2118
data = ["data/data.txt"],
2219
main = "bin.py",
20+
python_version = "3.11",
2321
visibility = ["//visibility:public"],
2422
deps = [
2523
":lib",

‎examples/bzlmod/tests/BUILD.bazel

Copy file name to clipboardExpand all lines: examples/bzlmod/tests/BUILD.bazel
+22-17Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
load("@python_versions//3.10:defs.bzl", py_binary_3_10 = "py_binary", py_test_3_10 = "py_test")
2-
load("@python_versions//3.11:defs.bzl", py_binary_3_11 = "py_binary", py_test_3_11 = "py_test")
3-
load("@python_versions//3.9:defs.bzl", py_binary_3_9 = "py_binary", py_test_3_9 = "py_test")
41
load("@pythons_hub//:versions.bzl", "MINOR_MAPPING")
52
load("@rules_python//python:py_binary.bzl", "py_binary")
63
load("@rules_python//python:py_test.bzl", "py_test")
7-
load("@rules_python//python/config_settings:transition.bzl", py_versioned_binary = "py_binary", py_versioned_test = "py_test")
84
load("@rules_shell//shell:sh_test.bzl", "sh_test")
95

106
py_binary(
@@ -13,25 +9,28 @@ py_binary(
139
main = "version.py",
1410
)
1511

16-
py_binary_3_9(
12+
py_binary(
1713
name = "version_3_9",
1814
srcs = ["version.py"],
1915
main = "version.py",
16+
python_version = "3.9",
2017
)
2118

22-
py_binary_3_10(
19+
py_binary(
2320
name = "version_3_10",
2421
srcs = ["version.py"],
2522
main = "version.py",
23+
python_version = "3.10",
2624
)
2725

28-
py_binary_3_11(
26+
py_binary(
2927
name = "version_3_11",
3028
srcs = ["version.py"],
3129
main = "version.py",
30+
python_version = "3.11",
3231
)
3332

34-
py_versioned_binary(
33+
py_binary(
3534
name = "version_3_10_versioned",
3635
srcs = ["version.py"],
3736
main = "version.py",
@@ -49,21 +48,23 @@ py_test(
4948
deps = ["//libs/my_lib"],
5049
)
5150

52-
py_test_3_9(
51+
py_test(
5352
name = "my_lib_3_9_test",
5453
srcs = ["my_lib_test.py"],
5554
main = "my_lib_test.py",
55+
python_version = "3.9",
5656
deps = ["//libs/my_lib"],
5757
)
5858

59-
py_test_3_10(
59+
py_test(
6060
name = "my_lib_3_10_test",
6161
srcs = ["my_lib_test.py"],
6262
main = "my_lib_test.py",
63+
python_version = "3.10",
6364
deps = ["//libs/my_lib"],
6465
)
6566

66-
py_versioned_test(
67+
py_test(
6768
name = "my_lib_versioned_test",
6869
srcs = ["my_lib_test.py"],
6970
main = "my_lib_test.py",
@@ -92,33 +93,36 @@ py_test(
9293
main = "version_test.py",
9394
)
9495

95-
py_test_3_9(
96+
py_test(
9697
name = "version_3_9_test",
9798
srcs = ["version_test.py"],
9899
env = {"VERSION_CHECK": "3.9"},
99100
main = "version_test.py",
101+
python_version = "3.9",
100102
)
101103

102-
py_test_3_10(
104+
py_test(
103105
name = "version_3_10_test",
104106
srcs = ["version_test.py"],
105107
env = {"VERSION_CHECK": "3.10"},
106108
main = "version_test.py",
109+
python_version = "3.10",
107110
)
108111

109-
py_versioned_test(
112+
py_test(
110113
name = "version_versioned_test",
111114
srcs = ["version_test.py"],
112115
env = {"VERSION_CHECK": "3.10"},
113116
main = "version_test.py",
114117
python_version = "3.10",
115118
)
116119

117-
py_test_3_11(
120+
py_test(
118121
name = "version_3_11_test",
119122
srcs = ["version_test.py"],
120123
env = {"VERSION_CHECK": "3.11"},
121124
main = "version_test.py",
125+
python_version = "3.11",
122126
)
123127

124128
py_test(
@@ -133,7 +137,7 @@ py_test(
133137
main = "cross_version_test.py",
134138
)
135139

136-
py_test_3_10(
140+
py_test(
137141
name = "version_3_10_takes_3_9_subprocess_test",
138142
srcs = ["cross_version_test.py"],
139143
data = [":version_3_9"],
@@ -143,9 +147,10 @@ py_test_3_10(
143147
"VERSION_CHECK": "3.10",
144148
},
145149
main = "cross_version_test.py",
150+
python_version = "3.10",
146151
)
147152

148-
py_versioned_test(
153+
py_test(
149154
name = "version_3_10_takes_3_9_subprocess_test_2",
150155
srcs = ["cross_version_test.py"],
151156
data = [":version_3_9"],
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
load("@python//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
2-
load("@python//3.11:defs.bzl", compile_pip_requirements_3_11 = "compile_pip_requirements")
3-
load("@python//3.8:defs.bzl", compile_pip_requirements_3_8 = "compile_pip_requirements")
4-
load("@python//3.9:defs.bzl", compile_pip_requirements_3_9 = "compile_pip_requirements")
1+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
52

6-
compile_pip_requirements_3_8(
3+
compile_pip_requirements(
74
name = "requirements_3_8",
85
src = "requirements.in",
6+
python_version = "3.8",
97
requirements_txt = "requirements_lock_3_8.txt",
108
)
119

12-
compile_pip_requirements_3_9(
10+
compile_pip_requirements(
1311
name = "requirements_3_9",
1412
src = "requirements.in",
13+
python_version = "3.9",
1514
requirements_txt = "requirements_lock_3_9.txt",
1615
)
1716

18-
compile_pip_requirements_3_10(
17+
compile_pip_requirements(
1918
name = "requirements_3_10",
2019
src = "requirements.in",
20+
python_version = "3.10",
2121
requirements_txt = "requirements_lock_3_10.txt",
2222
)
2323

24-
compile_pip_requirements_3_11(
24+
compile_pip_requirements(
2525
name = "requirements_3_11",
2626
src = "requirements.in",
27+
python_version = "3.11",
2728
requirements_txt = "requirements_lock_3_11.txt",
2829
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.