diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 4fa6885..545c48c 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -20,6 +20,11 @@ jobs: run: | set -euo pipefail + export RULES_PYTHON_RELEASE=$(curl -s https://api.github.com/repos/bazelbuild/rules_python/releases/latest | jq -c .) + export RULES_PYTHON_TAG=$(echo $RULES_PYTHON_RELEASE | jq -r '.tag_name') + export RULES_PYTHON_URL=$(echo $RULES_PYTHON_RELEASE | jq -r '.assets[].browser_download_url') + export RULES_PYTHON_SHA256=$(curl -s $RULES_PYTHON_URL | sha256sum) + git config user.name "${{ github.triggering_actor }}" git config user.email "${{ github.triggering_actor }}@users.noreply.github.com" diff --git a/.github/workflows/release-notes.md b/.github/workflows/release-notes.md index 910b0ae..2777a5e 100644 --- a/.github/workflows/release-notes.md +++ b/.github/workflows/release-notes.md @@ -25,6 +25,24 @@ Paste this snippet into your `WORKSPACE` file: ```starlark load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +toolchain_name = "python" +python_version = "3.12" + +# Setup rules_python +http_archive( + name = "rules_python", + sha256 = "${RULES_PYTHON_SHA256}", + strip_prefix = "rules_python-${RULES_PYTHON_TAG}", + url = "${RULES_PYTHON_URL}", +) + +load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") + +py_repositories() + +python_register_toolchains(toolchain_name, python_version) + +# Setup rules_ophiuchus http_archive( name = "rules_ophiuchus", sha256 = "${SHA256}", @@ -32,10 +50,11 @@ http_archive( url = "https://github.com/oxidase/rules_ophiuchus/releases/download/v${TAG}/${ARCHIVE}", ) -load("@rules_ophiuchus//python:poetry_parse.bzl", "poetry_parse") load("@rules_ophiuchus//python:repositories.bzl", install_poetry_dependencies = "install_dependencies") -install_poetry_dependencies() +install_poetry_dependencies(toolchain_name, python_version) + +load("@rules_ophiuchus//python:poetry_parse.bzl", "poetry_parse") poetry_parse( name = "poetry", diff --git a/python/repositories.bzl b/python/repositories.bzl index 6230ef2..eb880c2 100644 --- a/python/repositories.bzl +++ b/python/repositories.bzl @@ -56,15 +56,12 @@ poetry_deps_repo = repository_rule( ) def _internal_definitions_repo_impl(rctx): - generator = "{} by {}".format(rctx.attr.generator_name, rctx.attr.generator_function) - rctx.file("BUILD", "") - rctx.file("defs.bzl", """# Generated by {generator} + rctx.file("defs.bzl", """ python_host = "{python_host}" python_version = "{python_version}" python_toolchain_prefix = "{python_toolchain_prefix}" """.format( - generator = generator, python_host = rctx.attr.python_host, python_version = rctx.attr.python_version, python_toolchain_prefix = rctx.attr.python_toolchain_prefix,