Skip to content

0.35.0

Compare
Choose a tag to compare
@github-actions github-actions released this 15 Aug 20:31
· 161 commits to main since this release
425dfb0

Using Bzlmod with Bazel 6

NOTE: bzlmod support is still beta. APIs subject to change.

Add to your MODULE.bazel file:

bazel_dep(name = "rules_python", version = "0.35.0")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")

pip.parse(
    hub_name = "pip",
    python_version = "3.11",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

Using WORKSPACE

Paste this snippet into your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "be04b635c7be4604be1ef20542e9870af3c49778ce841ee2d92fcb42f9d9516a",
    strip_prefix = "rules_python-0.35.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.35.0/rules_python-0.35.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

Gazelle plugin

Paste this snippet into your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "be04b635c7be4604be1ef20542e9870af3c49778ce841ee2d92fcb42f9d9516a",
    strip_prefix = "rules_python-0.35.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.35.0/rules_python-0.35.0.tar.gz",
)

# To compile the rules_python gazelle extension from source,
# we must fetch some third-party go dependencies that it uses.

load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()

Changed

  • (pypi) A better log message when the wheel is built from an sdist or
    when the wheel is downloaded using download_only feature to aid debugging.
  • (gazelle): Simplify and make gazelle_python.yaml have only top level package name.
    It would work well in cases to reduce merge conflicts and ease the change review.
  • (toolchains): Change some old toochain versions to use 20240726 release to
    include dependency updates 3.8.19, 3.9.19, 3.10.14, 3.11.9
  • (toolchains): Bump default toolchain versions to:
    • 3.12 -> 3.12.4
  • (rules) PYTHONSAFEPATH is inherited from the calling environment to allow
    disabling it (Requires {obj}--bootstrap_impl=script)
    (#2060).

Fixed

  • (pypi) compile_pip_requirements now sets the USERPROFILE env variable on
    Windows to work around an issue where setuptools fails to locate the user's
    home directory.
  • (pypi) correctly handle absolute URLs in parse_simpleapi_html.bzl.
  • (rules) Fixes build targets linking against @rules_python//python/cc:current_py_cc_libs
    in host platform builds on macOS, by editing the LC_ID_DYLIB field of the hermetic interpreter's
    libpython3.x.dylib using install_name_tool, setting it to its absolute path under Bazel's
    execroot.
  • (rules) Signals are properly received when using {obj}--bootstrap_impl=script
    (for non-zip builds).
    (#2043)
  • (rules) Fixes Python builds when the --build_python_zip is set to false on
    Windows. See #1840.
  • (rules) Fixes Mac + --build_python_zip + {obj}--bootstrap_impl=script
    (#2030).
  • (rules) User dependencies come before runtime site-packages when using
    {obj}--bootstrap_impl=script.
    (#2064).
  • (rules) Version-aware rules now return both @_builtins and @rules_python
    providers instead of only one.
    (#2114).
  • (pypi) Fixed pypi parse_simpleapi_html function for feeds with package metadata
    containing ">" sign
  • (toolchains) Added missing executable permission to
    //python/runtime_env_toolchains interpreter script so that it is runnable.
    (#2085).
  • (pip) Correctly use the sdist downloaded by the bazel downloader when using
    experimental_index_url feature. Fixes
    #2091.
  • (gazelle) Make gazelle_python_manifest.update manual to avoid unnecessary
    network behavior.
  • (bzlmod): The conflicting toolchains during python extension will no longer
    cause warnings by default. In order to see the warnings for diagnostic purposes
    set the env var RULES_PYTHON_REPO_DEBUG_VERBOSITY to one of INFO, DEBUG or TRACE.
    Fixes #1818.
  • (runfiles) Make runfiles lookups work for the situation of Bazel 7,
    Python 3.9 (or earlier, where safepath isn't present), and the Rlocation call
    in the same directory as the main file.
    Fixes #1631.

Added

  • (pypi) compile_pip_requirements supports multiple requirements input files as srcs.
  • (rules) PYTHONSAFEPATH is inherited from the calling environment to allow
    disabling it (Requires {obj}--bootstrap_impl=script)
    (#2060).
  • (gazelle) Added python_generation_mode_per_package_require_test_entry_point
    in order to better accommodate users who use a custom macro,
    pytest-bazel, rules_python_pytest or rules_py
    py_test_main in order to integrate with pytest. Currently the default
    flag value is set to true for backwards compatible behaviour, but in the
    future the flag will be flipped be false by default.
  • (toolchains) New Python versions available: 3.12.4 using the 20240726 release.
  • (pypi) Support env markers in requirements files. Note, that this means that
    if your requirements files contain env markers, the Python interpreter will
    need to be run during bzlmod phase to evaluate them. This may incur
    downloading an interpreter (for hermetic-based builds) or cause non-hermetic
    behavior (if using a system Python).

List of PRs:

  • chore: include aignas to PyPI code reviewers by @aignas in #2034
  • fix(windows): symlink bootstrap script when not building zip by @KoltesDigital in #2015
  • fix: pypi parse_simpleapi_html.bzl is robust to metadata containing ">" sign by @mihaidusmanu in #2031
  • build(deps): bump certifi from 2023.7.22 to 2024.7.4 in /tools/publish by @dependabot in #2041
  • refactor: use http_archive for the stdlib list by @sitaktif in #2037
  • build(deps): bump charset-normalizer from 3.0.1 to 3.3.2 in /tools/publish by @dependabot in #2028
  • build(deps): bump certifi from 2024.6.2 to 2024.7.4 in /docs/sphinx by @dependabot in #2046
  • fix: use exec to invoke the stage-2 bootstrap for non-zip case by @chowder in #2047
  • chore: add cxxopt std=c++14 to BCR presubmit config by @rickeylev in #2051
  • tests: add integration test for build_python_zip by @rickeylev in #2045
  • refactor: don't load repo-phase objects from build-phase by @rickeylev in #2056
  • fix(gazelle): Use the correct rules_go label in gazelle/manifest/defs.bzl by @dougthor42 in #2058
  • feat: Introduce an experimental uv toolchain by @groodt in #1989
  • refactor: Address a few improvements on uv toolchain by @groodt in #2062
  • build(deps): bump setuptools from 65.6.3 to 70.0.0 in /examples/pip_parse by @dependabot in #2065
  • build(deps): bump zipp from 3.11.0 to 3.19.2 in /tools/publish by @dependabot in #2066
  • fix: make mac zip builds work by @rickeylev in #2052
  • internal: repos to create a toolchain from a locally installed Python by @rickeylev in #2000
  • refactor(pypi): split out more utils and start passing 'abi_os_arch' around by @aignas in #2069
  • refactor(pypi): split out code for env marker evaluation for reuse by @aignas in #2068
  • docs: document some environment variables by @rickeylev in #2077
  • refactor(internal): move the os/arch detection to repo_utils by @aignas in #2075
  • fix(uv): fix UV_BIN usage with current_toolchain by @aignas in #2074
  • docs: describe annotations attr of pip_parse by @bruno-digitbio in #1667
  • feat!: Following generation mode when generating test targets by @linzhp in #2044
  • feat: inherit PYTHONSAFEPATH env var from outer process by @rickeylev in #2076
  • fix: insert user imports before runtime site-packages by @rickeylev in #2073
  • fix(pypi): fix the whl selection algorithm after #2069 by @aignas in #2078
  • fix(sphinxdocs): use Label in the readthedocs_install macro by @aignas in #2080
  • refactor: use logger in repo_utils.execute_* functions by @rickeylev in #2082
  • refactor: move python/repositories.bzl implementation under python/private by @rickeylev in #2083
  • build(deps): bump sphinxcontrib-htmlhelp from 2.0.5 to 2.0.6 in /docs/sphinx by @dependabot in #2084
  • fix: add missing +x to runtime env toolchain interpreter script by @rickeylev in #2086
  • fix: use downloaded archive in sdist by @chrisirhc in #2091
  • feat(gazelle): simplify gazelle_python.yaml by @hunshcn in #2048
  • chore: bump toolchain versions by @betaboon in #2102
  • tests: make toolchain tests run in the same build instead of bazel-in-bazel integration tests by @rickeylev in #2095
  • fix(gazelle): make gazelle_python_manifest.genrule manual by @hunshcn in #2097
  • build(deps): bump sphinxcontrib-qthelp from 1.0.7 to 2.0.0 in /docs/sphinx by @dependabot in #2101
  • test(toolchain): use flag_values in test platform defs by @aignas in #2106
  • fix(bzlmod): silence duplicate version registrations by @aignas in #2111
  • docs: docgen underlying rules for macro-wrapped rules by @rickeylev in #2107
  • fix: make versioned rules return both builtin and rules_python providers by @rickeylev in #2116
  • tests: fix example bzlmod coverage test for latest Bazel by @rickeylev in #2119
  • fix: Fix up search path of bootstrapped Python toolchain dylib by @nicholasjng in #2089
  • fix: correctly handle absolute URLs in parse_simpleapi_html.bzl by @WSUFan in #2112
  • docs: move Sphinx object inventory for Bazel under sphinxdocs by @rickeylev in #2117
  • feat(pypi): support env markers in requirements files by @aignas in #2059
  • fix: support runfiles.CurrentRepository with non-hermetic sys.path by @fmeum in #1634
  • feat: update compile_pip_requirements to support multiple input files by @cj81499 in #1067
  • chore: update changelog for 0.35.0 release by @rickeylev in #2124

New Contributors

Full Changelog: 0.34.0...0.35.0