Skip to content

Releases: bazel-contrib/rules_python

0.7.0

11 Mar 16:04
4f826d1
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 = "15f84594af9da06750ceb878abbf129241421e3abbd6e36893041188db67f2fb",
    strip_prefix = "rules_python-0.7.0",
    url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.7.0.tar.gz",
)

News

rules_python can now fetch a hermetic pre-built Python interpreter from the excellent https://github.com/indygreg/python-build-standalone project.
Thank you @indygreg for providing this resource!

To use it, see the docs for python_register_toolchains on https://github.com/bazelbuild/rules_python#getting-started

What's Changed

  • Fix buildozer command for substituting deps by @hrfuller in #596
  • Added .gitignore files to example directories by @UebelAndre in #599
  • Fix undefined name in purelib.py by @hrfuller in #604
  • changes to pip_repository source files now re-trigger the repo rule by @UebelAndre in #601
  • Added support for annotating rendered pip dependencies by @UebelAndre in #589
  • bump: go version from 1.16 to 1.17.6 by @f0rmiga in #610
  • Fixed extra_pip_arg parsing error in pip_repository rules. by @UebelAndre in #613
  • fix compile_pip_requirements on windows by @jheaff1 in #595
  • Use @rules_python//python/runfiles for examples and tests by @UebelAndre in #614
  • Make python only bzl_library target publicly visible by @UebelAndre in #611
  • restrict visibility on filegroup target only consumed in 1 place by @thundergolfer in #605
  • Added integration test for testing nuances of pip_repository macros by @UebelAndre in #615
  • Removed examples that are not platform agnostic by @UebelAndre in #620
  • Fixed buildifier defects by @UebelAndre in #621
  • Fix false positive tests in CI for Windows by @UebelAndre in #598
  • chore: bump local version of bazel used to 4.2.0 by @mattem in #616
  • Fixed incorrect custom compile commands from compile_pip_requirements by @UebelAndre in #627
  • conditionally log unused annotations by @UebelAndre in #629
  • Exclude dist-info data from pip_repository targets by @UebelAndre in #626
  • feat: concurrent parsing for Gazelle by @f0rmiga in #630
  • Updated pip_repository data ignore patterns by @UebelAndre in #632
  • Allow *.dist-info/WHEEL files into pip_repository generated targets by @UebelAndre in #634
  • feat: support pip_parse in Gazelle by @f0rmiga in #633
  • Allow METADATA files in pip_repository generated targets by @UebelAndre in #637
  • feat: cpython toolchains by @f0rmiga in #618
  • fix: lazy fetch checksums for toolchains by @f0rmiga in #648
  • feat: allow overriding tool versions and base url for predefined Python interpreters by @mattem in #647
  • chore: update GitHub archive url to produce stable SHA by @alexeagle in #650

New Contributors

Full Changelog: 0.6.0...0.7.0

0.6.0

05 Jan 00:06
b842276
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 = "a30abdfc7126d497a7698c29c46ea9901c6392d6ed315171a6df5ce433aa4502",
    strip_prefix = "rules_python-0.6.0",
    url = "https://github.com/bazelbuild/rules_python/archive/0.6.0.tar.gz",
)

Breaking Changes

If you used the gazelle plugin, the workspace call to modules_mapping() should now be moved to a BUILD file as it is a regular rule. See the updates to examples/build_file_generation in https://github.com/bazelbuild/rules_python/pull/578/files

Users of pip_parse (or pip_repository(incremental=True)) will have the generated repositories change, e.g. from @pip_pypi__amqp//:pkg to @amqp//:pkg. If you use the requirements() helper, this won't affect you, but if you referred to the generated labels directly it will.
You can add the attribute repo_prefix = "pip_pypi__" on pip_parse to restore the previous default.

What's Changed

New Contributors

Full Changelog: 0.4.0...0.6.0

0.5.0

26 Oct 02:28
Compare
Choose a tag to compare

WORKSPACE setup

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

Warning

#571 reports that the pip_parse rule which is newly promoted from experimental may be non-deterministic. We don't recommend using it until that issue is resolved.

Breaking changes

rules_python supports Bazel Long-Term Support versions, 4.0.0 or higher. The repository rules will fail with an error if your Bazel version is older.
You can patch out that check if you really want to upgrade rules_python with Bazel 3 or lower, however this isn't supported.

What's Changed

  • Fix regression in parsing requirements due to invalid entry points config. by @UebelAndre in #536
  • Add tags pypi_name and pypi_version to generated py_library targets by @alexeagle in #530
  • Exposed docs for compile_pip_requirements by @UebelAndre in #534
  • Revert "py_library generated from wheel shouldn't include tests/ fold… by @alexeagle in #539
  • Updated min tested Bazel version to 4.0.0 by @UebelAndre in #533
  • Added additional tests for pip_parse and pip_install utilties by @UebelAndre in #524
  • docs: enforce that api docs are up-to-date by @alexeagle in #540
  • fix: rules_python 0.4.0 is not recent enough for pip_install example by @thundergolfer in #547
  • Typo: s/requiremenst/requirements by @b0ri5 in #552
  • fix bazel_integration_test runner to allow non-release URLs by @alexeagle in #556
  • Remove 'experimental' from pip_parse section by @jvolkman in #551
  • Update docstrings for packaging rules/macros by @thundergolfer in #535
  • Turn //python/private into a package. by @UebelAndre in #555
  • Added stamp attribute to py_wheel by @UebelAndre in #554
  • Add support for relative requirements in pip_install by @aaliddell in #433

New Contributors

Full Changelog: 0.4.0...0.5.0

0.4.0

12 Sep 22:58
Compare
Choose a tag to compare

Changes from last release

0.3.0...0.4.0

WORKSPACE setup

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    sha256 = "954aa89b491be4a083304a2cb838019c8b8c3720a7abb9c4cb81ac7a24230cea",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_python/releases/download/0.4.0/rules_python-0.4.0.tar.gz",
        "https://github.com/bazelbuild/rules_python/releases/download/0.4.0/rules_python-0.4.0.tar.gz",
    ],
)

Using the rules

See the source.

0.3.0

23 Jun 05:36
Compare
Choose a tag to compare

New Features

Contributions

Incompatible Changes

None

WORKSPACE setup

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz",
    sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b",
)

Using the rules

See the source.

0.2.0

31 Mar 04:39
Compare
Choose a tag to compare

New Features

  • Wheel building code has graduated out of //experimental. See #418
  • rules_python no longer mistakenly depends on bazel-skylib.
  • Support for incremental wheel downloading if using a locked requirements file. See #432

Incompatible Changes

  • pip_install packaging rule no longer supports Python 3.5 (which is end-of-life) due to upgrade of pip. See: #412

WORKSPACE setup

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    sha256 = "778197e26c5fbeb07ac2a2c5ae405b30f6cb7ad1f5510ea6fdac03bded96cc6f",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_python/releases/download/0.2.0/rules_python-0.2.0.tar.gz",
        "https://github.com/bazelbuild/rules_python/releases/download/0.2.0/rules_python-0.2.0.tar.gz",
    ],
)

Using the rules

See the source.

0.1.0

15 Oct 22:29
Compare
Choose a tag to compare

WORKSPACE setup

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

Incompatible Changes

(Note that, per semver, our version starts with 0. so any minor release can have breaking changes)

We have deprecated the pip_import rule and moved it to a "legacy" package. Bazel rulesets that attempt to import load("@rules_python//python:pip.bzl", "pip_import") will fail, as pip_import has been replaced
by load("@rules_python//python:pip.bzl", "pip_install")
See https://github.com/bazelbuild/rules_python/tree/master/examples/pip_install for an example of using pip_install.

If you use a ruleset such as rules_docker which depends on pip_import then you'll need to update that ruleset along with rules_python 0.1.0. We are working to land changes in those dependents to make this possible, in the meantime see the Patches section below.

If there's a problem with pip_install which prevents you switching, please file an issue with us or discuss on Slack so we can resolve it.
We plan to remove it in a future breaking release.
In this case, note that you can still use pip_import during the transition.
You just replace your loads from @rules_python//python:pip.bzl with @rules_python//python/legacy_pip_import:pip.bzl.
See https://github.com/bazelbuild/rules_python/tree/master/examples/legacy_pip_import for an example of use.

Thank you to @dillon-giacoppo and the other contributors to rules_python_external for building this better way to get dependencies from pip!

Patches

rules_docker

If you use rules_docker you can patch their release by adding this file to your repo. NOTE: it will print a WARNING line because of using the deprecated API; a better patch to switch to pip_install is on the way.

rules_docker.pr1650.patch

diff repositories/py_repositories.bzl repositories/py_repositories.bzl
index 72bb27b..9ba152c 100644
--- repositories/py_repositories.bzl
+++ repositories/py_repositories.bzl
@@ -19,7 +19,7 @@ Provides functions to pull all Python external package dependencies of this
 repository.
 """

-load("@rules_python//python:pip.bzl", "pip_import", "pip_repositories")
+load("@rules_python//python/legacy_pip_import:pip.bzl", "pip_import", "pip_repositories")

 def py_deps():
     """Pull in external Python packages needed by py binaries in this repo.

then where you fetch rules_docker, add a patches attribute:

    http_archive(
        name = "io_bazel_rules_docker",
        patches = ["//:rules_docker.pr1650.patch"],
        ...
    )

(Note, this assumes you have a BUILD file in the workspace root. You can put the patch file in any package you like)

Using the rules

See the source.

0.0.3

08 Sep 12:01
Compare
Choose a tag to compare
0.0.3 Pre-release
Pre-release

New Features

https://github.com/dillon-giacoppo/rules_python_external has been upstreamed into this project under experimental/.

WORKSPACE setup

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.3/rules_python-0.0.3.tar.gz",
    sha256 = "e46612e9bb0dae8745de6a0643be69e8665a03f63163ac6610c210e80d14c3e4",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()

Using the rules

See the source.

0.0.2

06 May 11:37
a0fbf98
Compare
Choose a tag to compare
0.0.2 Pre-release
Pre-release

WORKSPACE setup

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.2/rules_python-0.0.2.tar.gz",
    strip_prefix = "rules_python-0.0.2", 
    sha256 = "b5668cde8bb6e3515057ef465a35ad712214962f0b3a314e551204266c7be90c",
)
load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

# Only needed if using the packaging rules.
load("@rules_python//python:pip.bzl", "pip_repositories")

pip_repositories()

Using the rules

See the source.

0.0.1

09 Oct 04:25
9150caa
Compare
Choose a tag to compare
0.0.1 Pre-release
Pre-release

First versioned release.

WORKSPACE setup

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
    sha256 = "aa96a691d3a8177f3215b14b0edc9641787abaaa30363a080165d06ab65e1161",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()
# Only needed if using the packaging rules.
load("@rules_python//python:pip.bzl", "pip_repositories")
pip_repositories()

Using the rules

See the source.