Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Unreleased changes template.
### Changed
* (pypi) {obj}`pip.override` will now be ignored instead of raising an error,
fixes [#2550](https://github.com/bazelbuild/rules_python/issues/2550).
* (rules) deprecation warnings for deprecated symbols have been turned off by
default for now and can be enabled with `RULES_PYTHON_DEPRECATION_WARNINGS`
env var.

{#v0-0-0-fixed}
### Fixed
Expand Down
7 changes: 6 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ python.toolchain(
is_default = True,
python_version = "3.11",
)
use_repo(python, "python_3_11", "python_versions", "pythons_hub")
use_repo(
python,
"python_3_11",
"pythons_hub",
python = "python_versions",
)

# This call registers the Python toolchains.
register_toolchains("@pythons_hub//:all")
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ load("//:internal_dev_setup.bzl", "rules_python_internal_setup")

rules_python_internal_setup()

load("@pythons_hub//:versions.bzl", "MINOR_MAPPING", "PYTHON_VERSIONS")
load("@pythons_hub//:versions.bzl", "PYTHON_VERSIONS")
load("//python:repositories.bzl", "python_register_multi_toolchains")

python_register_multi_toolchains(
name = "python",
default_version = MINOR_MAPPING.values()[-3], # Use 3.11.10
default_version = "3.11",
# Integration tests verify each version, so register all of them.
python_versions = PYTHON_VERSIONS,
)
Expand Down
6 changes: 6 additions & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ When `1`, bzlmod extensions will print debug information about what they're
doing. This is mostly useful for development to debug errors.
:::

:::{envvar} RULES_PYTHON_DEPRECATION_WARNINGS

When `1`, the rules_python will warn users about deprecated functionality that will
be removed in a subsequent major `rules_python` version. Defaults to `0` if unset.
:::

:::{envvar} RULES_PYTHON_ENABLE_PYSTAR

When `1`, the rules_python Starlark implementation of the core rules is used
Expand Down
5 changes: 3 additions & 2 deletions examples/bzlmod/other_module/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
load("@python_versions//3.11:defs.bzl", compile_pip_requirements_311 = "compile_pip_requirements")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")

# NOTE: To update the requirements, you need to uncomment the rules_python
# override in the MODULE.bazel.
compile_pip_requirements_311(
compile_pip_requirements(
name = "requirements",
src = "requirements.in",
python_version = "3.11",
requirements_txt = "requirements_lock_3_11.txt",
)
8 changes: 3 additions & 5 deletions examples/bzlmod/other_module/other_module/pkg/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
load(
"@python_3_11//:defs.bzl",
py_binary_311 = "py_binary",
)
load("@rules_python//python:py_binary.bzl", "py_binary")
load("@rules_python//python:py_library.bzl", "py_library")

py_library(
Expand All @@ -15,11 +12,12 @@ py_library(
# This is used for testing mulitple versions of Python. This is
# used only when you need to support multiple versions of Python
# in the same project.
py_binary_311(
py_binary(
name = "bin",
srcs = ["bin.py"],
data = ["data/data.txt"],
main = "bin.py",
python_version = "3.11",
visibility = ["//visibility:public"],
deps = [
":lib",
Expand Down
39 changes: 22 additions & 17 deletions examples/bzlmod/tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
load("@python_versions//3.10:defs.bzl", py_binary_3_10 = "py_binary", py_test_3_10 = "py_test")
load("@python_versions//3.11:defs.bzl", py_binary_3_11 = "py_binary", py_test_3_11 = "py_test")
load("@python_versions//3.9:defs.bzl", py_binary_3_9 = "py_binary", py_test_3_9 = "py_test")
load("@pythons_hub//:versions.bzl", "MINOR_MAPPING")
load("@rules_python//python:py_binary.bzl", "py_binary")
load("@rules_python//python:py_test.bzl", "py_test")
load("@rules_python//python/config_settings:transition.bzl", py_versioned_binary = "py_binary", py_versioned_test = "py_test")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

py_binary(
Expand All @@ -13,25 +9,28 @@ py_binary(
main = "version.py",
)

py_binary_3_9(
py_binary(
name = "version_3_9",
srcs = ["version.py"],
main = "version.py",
python_version = "3.9",
)

py_binary_3_10(
py_binary(
name = "version_3_10",
srcs = ["version.py"],
main = "version.py",
python_version = "3.10",
)

py_binary_3_11(
py_binary(
name = "version_3_11",
srcs = ["version.py"],
main = "version.py",
python_version = "3.11",
)

py_versioned_binary(
py_binary(
name = "version_3_10_versioned",
srcs = ["version.py"],
main = "version.py",
Expand All @@ -49,21 +48,23 @@ py_test(
deps = ["//libs/my_lib"],
)

py_test_3_9(
py_test(
name = "my_lib_3_9_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
python_version = "3.9",
deps = ["//libs/my_lib"],
)

py_test_3_10(
py_test(
name = "my_lib_3_10_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
python_version = "3.10",
deps = ["//libs/my_lib"],
)

py_versioned_test(
py_test(
name = "my_lib_versioned_test",
srcs = ["my_lib_test.py"],
main = "my_lib_test.py",
Expand Down Expand Up @@ -92,33 +93,36 @@ py_test(
main = "version_test.py",
)

py_test_3_9(
py_test(
name = "version_3_9_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.9"},
main = "version_test.py",
python_version = "3.9",
)

py_test_3_10(
py_test(
name = "version_3_10_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.10"},
main = "version_test.py",
python_version = "3.10",
)

py_versioned_test(
py_test(
name = "version_versioned_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.10"},
main = "version_test.py",
python_version = "3.10",
)

py_test_3_11(
py_test(
name = "version_3_11_test",
srcs = ["version_test.py"],
env = {"VERSION_CHECK": "3.11"},
main = "version_test.py",
python_version = "3.11",
)

py_test(
Expand All @@ -133,7 +137,7 @@ py_test(
main = "cross_version_test.py",
)

py_test_3_10(
py_test(
name = "version_3_10_takes_3_9_subprocess_test",
srcs = ["cross_version_test.py"],
data = [":version_3_9"],
Expand All @@ -143,9 +147,10 @@ py_test_3_10(
"VERSION_CHECK": "3.10",
},
main = "cross_version_test.py",
python_version = "3.10",
)

py_versioned_test(
py_test(
name = "version_3_10_takes_3_9_subprocess_test_2",
srcs = ["cross_version_test.py"],
data = [":version_3_9"],
Expand Down
17 changes: 9 additions & 8 deletions examples/multi_python_versions/requirements/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
load("@python//3.10:defs.bzl", compile_pip_requirements_3_10 = "compile_pip_requirements")
load("@python//3.11:defs.bzl", compile_pip_requirements_3_11 = "compile_pip_requirements")
load("@python//3.8:defs.bzl", compile_pip_requirements_3_8 = "compile_pip_requirements")
load("@python//3.9:defs.bzl", compile_pip_requirements_3_9 = "compile_pip_requirements")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")

compile_pip_requirements_3_8(
compile_pip_requirements(
name = "requirements_3_8",
src = "requirements.in",
python_version = "3.8",
requirements_txt = "requirements_lock_3_8.txt",
)

compile_pip_requirements_3_9(
compile_pip_requirements(
name = "requirements_3_9",
src = "requirements.in",
python_version = "3.9",
requirements_txt = "requirements_lock_3_9.txt",
)

compile_pip_requirements_3_10(
compile_pip_requirements(
name = "requirements_3_10",
src = "requirements.in",
python_version = "3.10",
requirements_txt = "requirements_lock_3_10.txt",
)

compile_pip_requirements_3_11(
compile_pip_requirements(
name = "requirements_3_11",
src = "requirements.in",
python_version = "3.11",
requirements_txt = "requirements_lock_3_11.txt",
)
Loading