Skip to content

Releases: bazelbuild/rules_python

0.18.0

08 Feb 16:49
6c8ae76
Compare
Choose a tag to compare

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

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

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

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

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 = "36362b4d54fcb17342f9071e4c38d63ce83e2e57d7d5599ebdde4670b9760664",
    strip_prefix = "rules_python-0.18.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.0/rules_python-0.18.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 = "36362b4d54fcb17342f9071e4c38d63ce83e2e57d7d5599ebdde4670b9760664",
    strip_prefix = "rules_python-0.18.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.18.0/rules_python-0.18.0.tar.gz",
)

Relevant Changes

Post-release notes

  • bug #1056: This release does not work with Bazel 5. Please upgrade to 0.18.1

Coverage

rules_python now includes coverage as part of the toolchain as an opt-in feature. To get started, pass register_coverage_tool = True to python_register_toolchains or python_register_multi_toolchains.

runfiles wheel

The bazel-runfiles wheel is now published to https://pypi.org/project/bazel-runfiles/.

What's Changed

New Contributors

Full Changelog: 0.17.3...0.18.0

0.17.3

27 Jan 01:15
3aefaed
Compare
Choose a tag to compare

Note, the prior 0.17 tags (0.17.0, 0.17.1, and 0.17.2) were never published as releases and can be ignored.

Breaking Change

The Gazelle extension for Python has been updated to better integrate with the conventions of Python and Bazel. This includes changes to how test files with the prefix or suffix of "test_" and "*_test" are handled. If a test target is not present, these files will now be added to individual py_test targets. To align your projects with these changes, any test utility files that were previously included in py_library targets and have the aforementioned prefix or suffix, will need to be renamed for consistency.

To use the gazelle extension you must now fetch another external repository, rules_python_gazelle_plugin, see the snippet below.
Also, change your gazelle binary registration to load from this new repository:

gazelle(
    name = "gazelle",
    data = GAZELLE_PYTHON_RUNTIME_DEPS,
    gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary",
)

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

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

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

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

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 = "8c15896f6686beb5c631a4459a3aa8392daccaab805ea899c9d14215074b60ef",
    strip_prefix = "rules_python-0.17.3",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.17.3.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 = "8c15896f6686beb5c631a4459a3aa8392daccaab805ea899c9d14215074b60ef",
    strip_prefix = "rules_python-0.17.3/gazelle",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.17.3.tar.gz",
)

What's Changed

  • Update runfiles lib by @fmeum in #982
  • Refactor poor naming and unused code in wheel_installer by @groodt in #990
  • Add new Python versions including 3.11 by @jvolkman in #992
  • runfiles: Drop outdated comments about vendoring by @fmeum in #986
  • Implement py_proto_library by @comius in #832
  • runfiles: Fix usage instructions by @fmeum in #985
  • chore: fix red CI - buildifier was broken by #832 by @alexeagle in #996
  • runfiles: Import CurrentRepository from Bazel by @fmeum in #988
  • Fix misleading error message by @suzaku in #927
  • runfiles: Apply repo mapping to Rlocation path by @fmeum in #998
  • fix(deps): declare our dependency on bazel_skylib by @alexeagle in #1001
  • chore: publish a runfiles library as a wheel by @alexeagle in #995
  • feat: allow patching the interpreter fetched via toolchains by @mattem in #1004
  • Redirect stdout when checking imports. by @aptenodytes-forsteri in #1007
  • Fix Python interpreter target labels with @@ prefixes. by @oxidase in #940
  • cleanup: remove vendored copy of skylib by @alexeagle in #1003
  • generate py_test without test by @linzhp in #999
  • Add runtime dependencies to gazelle extension by @linzhp in #993
  • fix: allow omitting the strip_prefix in tool_versions by @lummax in #975
  • refactor(gazelle): Move plugin to a separate directory. by @aignas in #983
  • fix: windows *.lib interface in python_headers by @lummax in #976
  • python_repository: Exclude pycache files by @illicitonion in #907
  • runfiles: Remove dead code by @fmeum in #1011
  • runfiles: Add proper test coverage for an edge case by @fmeum in #1012
  • refactor: pull implementations out of packaging.bzl by @alexeagle in #1013
  • Fix requirement parser by @tgeng in #1009
  • feat(gazelle)!: Move the plugin to a separate workspace by @aignas in #972
  • refactor: py_wheel now a macro by @alexeagle in #1014
  • fix: ensure 'patches' attr is included for the canonical representation of the toolchain by @mattem in #1018
  • feat: produce publishable distribution archives by @alexeagle in #1019
  • fix(release): use correct GH workflows syntax by @alexeagle in #1020
  • feat: allow absolute urls in tool_versions by @lummax in #973
  • chore: revert publish wheel on releases by @alexeagle in #1022

New Contributors

Full Changelog: 0.16.2...0.17.3

0.16.2

10 Jan 22:08
70cce26
Compare
Choose a tag to compare

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

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

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

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

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 = "48a838a6e1983e4884b26812b2c748a35ad284fd339eb8e2a6f3adf95307fbcd",
    strip_prefix = "rules_python-0.16.2",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.16.2.tar.gz",
)

What's Changed

  • fix: gazelle panics when "# gazelle:ignore" doesn't have a value by @stdll00 in #915
  • Remove unused code by @groodt in #933
  • Various updates build_file_generation example by @chrislovecnm in #869
  • Fix CI after bazel 6.0.0 by @groodt in #938
  • Refactor wheel_installer by @groodt in #937
  • Updates lockfiles by @groodt in #943
  • fix: embed stamped version in py_wheel METADATA by @mattoberle in #935
  • chore(gazelle): clarify a particular failure message by @srabraham in #939
  • pip: 22.2.1 -> 22.3.1; build: 0.8.0 -> 0.9.0; installer: 0.5.1 -> 0.6.0; pip-tools: 6.8.0 -> 6.12.1 by @groodt in #944
  • Update name of compile_pip_requirements by @groodt in #945
  • Rename BUILD -> BUILD.bazel by @groodt in #946
  • Add missing .gitignore for //examples/pip_parse_vendored by @groodt in #947
  • Removes unused "incremental" property by @groodt in #948
  • Disable bytecode optimization during wheel installation by @groodt in #949
  • Fix broken link. by @phst in #955
  • Don’t use keyword argument for TestEnvironment. by @phst in #954
  • Fix hyphen in requirement didn't work with bzlmod (#952) by @acr92 in #957
  • chore(docs): fix bad html formatting by @alexeagle in #959
  • Fully switch to bazel 6.0.0 in all places by @aignas in #960
  • Use 'os' instead of 'ioutil' in gazelle tests by @aignas in #962
  • Refactor and separate concerns of external python package handling code by @groodt in #953

New Contributors

Full Changelog: 0.16.1...0.16.2

0.16.1

06 Dec 22:02
9bf7c49
Compare
Choose a tag to compare

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

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

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

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

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 = "497ca47374f48c8b067d786b512ac10a276211810f4a580178ee9b9ad139323a",
    strip_prefix = "rules_python-0.16.1",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.16.1.tar.gz",
)

What's Changed

New Contributors

Full Changelog: 0.15.1...0.16.1

0.15.1

01 Dec 22:46
c572cdc
Compare
Choose a tag to compare

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

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

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

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

Using WORKSPACE:

Paste this snippet into your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "bazel_skylib",
    sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
    ],
)
http_archive(
    name = "rules_python",
    sha256 = "bc4e59e17c7809a5b373ba359e2c974ed2386c58634819ac5a89c0813c15705c",
    strip_prefix = "rules_python-0.15.1",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.15.1.tar.gz",
)

What's Changed

  • fix: pip_compile to handle multiple generated requirements.in by @f0rmiga in #909
  • ci: add debian11 to the matrix by @f0rmiga in #910

Full Changelog: 0.15.0...0.15.1

0.15.0

29 Nov 17:58
518c873
Compare
Choose a tag to compare

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

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

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

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

Using WORKSPACE:

Paste this snippet into your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "bazel_skylib",
    sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
    ],
)
http_archive(
    name = "rules_python",
    sha256 = "fda23c37fbacf7579f94d5e8f342d3a831140e9471b770782e83846117dd6596",
    strip_prefix = "rules_python-0.15.0",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.15.0.tar.gz",
)

What's Changed

  • Expose python3n.lib as libpython's interface_library by @jlaxson in #890
  • Fix //docs:update by @philsc in #876
  • fix: correct bcr metadata template filename by @kormide in #892
  • fix: fix a bug where some transitive deps could not be resolved via bzlmod by @kormide in #893
  • feat: multi-toolchain support by @f0rmiga in #846
  • bump: python toolchain releases by @f0rmiga in #902
  • Correctly reference os-specific labels from central alias repo by @jlaxson in #889
  • Document how to get started working on rules_python by @rickeylev in #891
  • fix: #895 append _py if ending with .py by @rbuckland in #897
  • fix: missing RunEnvironmentInfo by @f0rmiga in #904

New Contributors

Full Changelog: 0.14.0...0.15.0

0.14.0

20 Nov 18:16
912a505
Compare
Choose a tag to compare

Using Bzlmod with Bazel 6

Add to your MODULE.bazel file:

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

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

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# (Optional) Register a specific python toolchain instead of using the host version
python = use_extension("@rules_python//python:extensions.bzl", "python")

python.toolchain(
    name = "python3_9",
    python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
    "@python3_9_toolchains//:all",
)

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 = "a868059c8c6dd6ad45a205cca04084c652cfe1852e6df2d5aca036f6e5438380",
    strip_prefix = "rules_python-0.14.0",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.14.0.tar.gz",
)

What's Changed

New Contributors

Full Changelog: 0.13.0...0.14.0

0.13.0

25 Sep 10:33
f0efec5
Compare
Choose a tag to compare

WORKSPACE setup:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    sha256 = "8c8fe44ef0a9afc256d1e75ad5f448bb59b81aba149b8958f02f7b3a98f5d9b4",
    strip_prefix = "rules_python-0.13.0",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.13.0.tar.gz",
)

What's Changed

  • Make gazelle_python_manifest output deterministic by @abhishekshivanna in #813
  • specify timeout for gazelle manifest test by @garymm in #817
  • Allow overriding config attrs in pip_parse-generated install_deps by @jvolkman in #751
  • fix pip_compile pip_compile select_golden_requirements_file invocation arguments by @lripoche in #826
  • Disable `//python/tests/toolchains:python_3_8_10_x86_64-apple-darwin_… by @meteorcloudy in #830
  • Standardise on pip_parse by @groodt in #807

New Contributors

Full Changelog: 0.12.0...0.13.0

0.12.0

29 Aug 03:09
cf6542d
Compare
Choose a tag to compare

WORKSPACE setup:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    sha256 = "b593d13bb43c94ce94b483c2858e53a9b811f6f10e1e0eedc61073bd90e58d9c",
    strip_prefix = "rules_python-0.12.0",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.12.0.tar.gz",
)

What's Changed

  • Added label to py_wheel progress message. by @UebelAndre in #791
  • Add option to use "pip download" instead of "pip wheel" to download wheels for other platforms by @jesseschalken in #773
  • Revert "Add option to use "pip download" instead of "pip wheel" to do… by @groodt in #808
  • Fix missing python includes for Unix hosts by @UebelAndre in #809
  • Fix ability to download windows toolchains on case sensitive unix systems by @UebelAndre in #797
  • Revert "pip_compile: remove external/workspace_name prefix from gener… by @alexeagle in #794
  • Revert "Revert "Add option to use "pip download" instead of "pip wheel" to do…" by @groodt in #811

Full Changelog: 0.11.0...0.12.0

0.11.0

15 Aug 09:44
a2b7f42
Compare
Choose a tag to compare

WORKSPACE setup:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    sha256 = "c03246c11efd49266e8e41e12931090b613e12a59e6f55ba2efd29a7cb8b4258",
    strip_prefix = "rules_python-0.11.0",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.11.0.tar.gz",
)

What's Changed

  • pip-tools: 6.6.2 -> 6.8.0 by @groodt in #762
  • Make hermetic interpreters compatible to disallow_empty_glob by @martis42 in #761
  • [gazelle] Use filepath.WalkDir instead of filepath.Walk by @dzbarsky in #770
  • Exclude static libraries and tests to reduce zipped Python executables by @tetsuok in #758
  • exec_compatible_with -> target_compatible_with #704 by @molar in #747
  • fix: fail if the user is root by @f0rmiga in #749
  • Simplify glob pattern to exclude static libraries by @tetsuok in #771
  • pip: 22.1.2 -> pip-22.2.1 by @groodt in #774
  • Fix download of Windows Python toolchain on Linux by @jesseschalken in #769
  • chore: remove pkginfo from bzlmod file by @alexeagle in #778
  • 709/from imports by @aptenodytes-forsteri in #760
  • Add a consistent python interpreter symlink by @mattyclarkson in #782
  • Exclude unused libpython{python_version}.so to reduce the size of zipped Python executables by @tetsuok in #772
  • Update Python minor toolchain versions to allow smaller Python binaries by @tetsuok in #779
  • Added importlib + reqs to pip-compile for python < 3.8 by @Faqa in #781
  • feat(gazelle_python_manifest): provide a target with the given name by @mattem in #787
  • fix(gazelle): handle purelib and platlib packages that don't set 'Root-Is-Purelib: true' by @mattem in #768
  • Ran black and isort to fix files missed by commit hook by @UebelAndre in #790
  • Fix leading forward slashes in RECORD files produced by py_wheel. by @UebelAndre in #789
  • Add type annotations to runfiles library by @dzbarsky in #764

New Contributors

Full Changelog: 0.10.2...0.11.0