From 7db2628bf1ff0ec35c51704cdb8a3f1e78beccdb Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 18 May 2024 14:36:08 +0200 Subject: [PATCH] Update py toolchain and runfiles handling --- MODULE.bazel | 41 +++++++++-------------------- WORKSPACE | 2 +- appimage/private/tool/BUILD | 3 +-- appimage/private/tool/mkappimage.py | 2 +- requirements.in | 1 - requirements.txt | 3 --- 6 files changed, 15 insertions(+), 37 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index fbcdd0a..a60c57a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -21,33 +21,16 @@ use_repo( register_toolchains("//appimage:all") -PYTHON_VERSIONS = [ - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", -] - +_DEFAULT_PYTHON = "3.12" python = use_extension("@rules_python//python/extensions:python.bzl", "python") - -[ - python.toolchain( - is_default = python_version == PYTHON_VERSIONS[-1], - python_version = python_version, - ) - for python_version in PYTHON_VERSIONS -] - -pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") - -[ - pip.parse( - hub_name = "rules_appimage_py_deps", - python_version = python_version, - requirements_lock = "//:requirements.txt", - ) - for python_version in PYTHON_VERSIONS -] - -use_repo(pip, "rules_appimage_py_deps") +python.toolchain(is_default = True, python_version = _DEFAULT_PYTHON) +use_repo(python, "python_" + _DEFAULT_PYTHON.replace(".", "_"), "python_versions", "pythons_hub") +register_toolchains("@pythons_hub//:all") + +dev_pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True) +dev_pip.parse( + hub_name = "rules_appimage_py_deps", + python_version = _DEFAULT_PYTHON, + requirements_lock = "//:requirements.txt", +) +use_repo(dev_pip, "rules_appimage_py_deps") diff --git a/WORKSPACE b/WORKSPACE index d077833..181670b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -10,7 +10,7 @@ py_repositories() python_register_toolchains( name = "rules_appimage_python", - python_version = "3.11", + python_version = "3.12", ) load("@rules_appimage_python//:defs.bzl", rules_appimage_py_interpreter = "interpreter") diff --git a/appimage/private/tool/BUILD b/appimage/private/tool/BUILD index aac57d6..e0da500 100644 --- a/appimage/private/tool/BUILD +++ b/appimage/private/tool/BUILD @@ -1,4 +1,3 @@ -load("@rules_appimage_py_deps//:requirements.bzl", "requirement") load("@rules_python//python:defs.bzl", "py_binary", "py_library") py_library( @@ -6,7 +5,7 @@ py_library( srcs = ["mkappimage.py"], data = ["@squashfs-tools//:mksquashfs"], visibility = ["//visibility:public"], - deps = [requirement("bazel-runfiles")], + deps = ["@rules_python//python/runfiles"], ) py_binary( diff --git a/appimage/private/tool/mkappimage.py b/appimage/private/tool/mkappimage.py index b768ccf..5e73811 100644 --- a/appimage/private/tool/mkappimage.py +++ b/appimage/private/tool/mkappimage.py @@ -11,7 +11,7 @@ from pathlib import Path from typing import Iterable, NamedTuple -import runfiles as bazel_runfiles +from python import runfiles as bazel_runfiles _ManifestDataT = dict[str, list[str | dict[str, str]]] diff --git a/requirements.in b/requirements.in index b2aa3d9..2f6c9d2 100644 --- a/requirements.in +++ b/requirements.in @@ -1,2 +1 @@ -bazel-runfiles==0.31.0 pytest==8.1.1 diff --git a/requirements.txt b/requirements.txt index e4116ff..16fe3e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,9 +4,6 @@ # # bazel run //:requirements.update # -bazel-runfiles==0.32.2 \ - --hash=sha256:2ed5cc73da6a44dff127105dacdbbd7632fde4eaf30f11d5ec1521f80d26d8fd - # via -r requirements.in iniconfig==2.0.0 \ --hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \ --hash=sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374