From 3748711f010bd191b0867344d615f9dc98b6eaf9 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Wed, 8 Mar 2023 16:56:18 +0100 Subject: [PATCH 01/24] Initial implementation of python modules with poetry --- testing/python-poetry/.bazelrc | 3 + testing/python-poetry/BUILD.bazel | 0 testing/python-poetry/MODULE.bazel | 52 +++++ testing/python-poetry/WORKSPACE | 45 ++++ testing/python-poetry/WORKSPACE.bzlmod | 0 testing/python-poetry/flake.lock | 1 + testing/python-poetry/nixpkgs.nix | 1 + testing/python-poetry/non_module_deps.bzl | 11 + testing/python-poetry/poetry.lock | 221 ++++++++++++++++++ testing/python-poetry/poetry.nix | 21 ++ testing/python-poetry/pyproject.toml | 14 ++ testing/python-poetry/tests/BUILD.bazel | 18 ++ testing/python-poetry/tests/imports_test.py | 5 + .../tests/nixpkgs_repositories.bzl | 53 +++++ toolchains/python/python.bzl | 181 ++++++++++++++ 15 files changed, 626 insertions(+) create mode 100644 testing/python-poetry/.bazelrc create mode 100644 testing/python-poetry/BUILD.bazel create mode 100644 testing/python-poetry/MODULE.bazel create mode 100644 testing/python-poetry/WORKSPACE create mode 100644 testing/python-poetry/WORKSPACE.bzlmod create mode 120000 testing/python-poetry/flake.lock create mode 120000 testing/python-poetry/nixpkgs.nix create mode 100644 testing/python-poetry/non_module_deps.bzl create mode 100644 testing/python-poetry/poetry.lock create mode 100644 testing/python-poetry/poetry.nix create mode 100644 testing/python-poetry/pyproject.toml create mode 100644 testing/python-poetry/tests/BUILD.bazel create mode 100644 testing/python-poetry/tests/imports_test.py create mode 100644 testing/python-poetry/tests/nixpkgs_repositories.bzl diff --git a/testing/python-poetry/.bazelrc b/testing/python-poetry/.bazelrc new file mode 100644 index 000000000..ae8f32bd8 --- /dev/null +++ b/testing/python-poetry/.bazelrc @@ -0,0 +1,3 @@ +import %workspace%/../../.bazelrc.common +import %workspace%/../../.bazelrc.cc +import %workspace%/../../.bazelrc.java diff --git a/testing/python-poetry/BUILD.bazel b/testing/python-poetry/BUILD.bazel new file mode 100644 index 000000000..e69de29bb diff --git a/testing/python-poetry/MODULE.bazel b/testing/python-poetry/MODULE.bazel new file mode 100644 index 000000000..1e32df581 --- /dev/null +++ b/testing/python-poetry/MODULE.bazel @@ -0,0 +1,52 @@ +module(name = "rules_nixpkgs_python_testing") + +bazel_dep(name = "rules_nixpkgs_python") +local_path_override( + module_name = "rules_nixpkgs_python", + path = "../../toolchains/python", +) + +bazel_dep(name = "rules_nixpkgs_core") +local_path_override( + module_name = "rules_nixpkgs_core", + path = "../../core", +) + +bazel_dep(name = "rules_nixpkgs_java") +local_path_override( + module_name = "rules_nixpkgs_java", + path = "../../toolchains/java", +) + +bazel_dep(name = "rules_nixpkgs_cc") +local_path_override( + module_name = "rules_nixpkgs_cc", + path = "../../toolchains/cc", +) + +bazel_dep(name = "bazel_skylib", version = "1.0.3") +bazel_dep(name = "rules_cc", version = "0.0.4") + +# TODO[AH] Remove these transitive dependencies once nixpkgs_java_configure has +# become a module extension in rules_nixpkgs_java. +bazel_dep(name = "platforms", version = "0.0.4") +bazel_dep(name = "rules_java", version = "4.0.0") +java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") +use_repo(java_toolchains, "remote_java_tools") + +non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps") + +use_repo(non_module_deps, "nixpkgs_java_runtime") +use_repo(non_module_deps, "nixpkgs_java_runtime_toolchain") +register_toolchains("@nixpkgs_java_runtime_toolchain//:all") + +use_repo(non_module_deps, "nixpkgs_config_cc") +use_repo(non_module_deps, "nixpkgs_config_cc_info") +use_repo(non_module_deps, "nixpkgs_config_cc_toolchains") +register_toolchains("@nixpkgs_config_cc_toolchains//:all") + +use_repo(non_module_deps, "nixpkgs") +use_repo(non_module_deps, "nixpkgs_python_toolchain") +use_repo(non_module_deps, "nixpkgs_python_configure_test") +use_repo(non_module_deps, "nixpkgs_python_toolchain_python3") +register_toolchains("@nixpkgs_python_toolchain//:all") diff --git a/testing/python-poetry/WORKSPACE b/testing/python-poetry/WORKSPACE new file mode 100644 index 000000000..84476c4fb --- /dev/null +++ b/testing/python-poetry/WORKSPACE @@ -0,0 +1,45 @@ +workspace(name = "rules_nixpkgs_python_testing") + +local_repository( + name = "rules_nixpkgs_python", + path = "../../toolchains/python", +) + +local_repository( + name = "rules_nixpkgs_core", + path = "../../core", +) + +local_repository( + name = "rules_nixpkgs_java", + path = "../../toolchains/java", +) + +local_repository( + name = "rules_nixpkgs_cc", + path = "../../toolchains/cc", +) + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "bazel_skylib", + sha256 = "f24ab666394232f834f74d19e2ff142b0af17466ea0c69a3f4c276ee75f6efce", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz", + ], +) + +load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + +bazel_skylib_workspace() + +load( + "//tests:nixpkgs_repositories.bzl", + "nixpkgs_repositories", +) + +nixpkgs_repositories(bzlmod = False) + + diff --git a/testing/python-poetry/WORKSPACE.bzlmod b/testing/python-poetry/WORKSPACE.bzlmod new file mode 100644 index 000000000..e69de29bb diff --git a/testing/python-poetry/flake.lock b/testing/python-poetry/flake.lock new file mode 120000 index 000000000..23b0a9b50 --- /dev/null +++ b/testing/python-poetry/flake.lock @@ -0,0 +1 @@ +../../flake.lock \ No newline at end of file diff --git a/testing/python-poetry/nixpkgs.nix b/testing/python-poetry/nixpkgs.nix new file mode 120000 index 000000000..ead0b0058 --- /dev/null +++ b/testing/python-poetry/nixpkgs.nix @@ -0,0 +1 @@ +../../docs/nixpkgs.nix \ No newline at end of file diff --git a/testing/python-poetry/non_module_deps.bzl b/testing/python-poetry/non_module_deps.bzl new file mode 100644 index 000000000..1e758095b --- /dev/null +++ b/testing/python-poetry/non_module_deps.bzl @@ -0,0 +1,11 @@ +load( + "//tests:nixpkgs_repositories.bzl", + "nixpkgs_repositories", +) + +def _non_module_deps_impl(ctx): + nixpkgs_repositories(bzlmod = True) + +non_module_deps = module_extension( + implementation = _non_module_deps_impl, +) diff --git a/testing/python-poetry/poetry.lock b/testing/python-poetry/poetry.lock new file mode 100644 index 000000000..42f40d9e4 --- /dev/null +++ b/testing/python-poetry/poetry.lock @@ -0,0 +1,221 @@ +# This file is automatically @generated by Poetry and should not be changed by hand. + +[[package]] +name = "cffi" +version = "1.15.1" +description = "Foreign Function Interface for Python calling C code." +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "cffi-1.15.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a66d3508133af6e8548451b25058d5812812ec3798c886bf38ed24a98216fab2"}, + {file = "cffi-1.15.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:470c103ae716238bbe698d67ad020e1db9d9dba34fa5a899b5e21577e6d52ed2"}, + {file = "cffi-1.15.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:9ad5db27f9cabae298d151c85cf2bad1d359a1b9c686a275df03385758e2f914"}, + {file = "cffi-1.15.1-cp27-cp27m-win32.whl", hash = "sha256:b3bbeb01c2b273cca1e1e0c5df57f12dce9a4dd331b4fa1635b8bec26350bde3"}, + {file = "cffi-1.15.1-cp27-cp27m-win_amd64.whl", hash = "sha256:e00b098126fd45523dd056d2efba6c5a63b71ffe9f2bbe1a4fe1716e1d0c331e"}, + {file = "cffi-1.15.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:d61f4695e6c866a23a21acab0509af1cdfd2c013cf256bbf5b6b5e2695827162"}, + {file = "cffi-1.15.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:ed9cb427ba5504c1dc15ede7d516b84757c3e3d7868ccc85121d9310d27eed0b"}, + {file = "cffi-1.15.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:39d39875251ca8f612b6f33e6b1195af86d1b3e60086068be9cc053aa4376e21"}, + {file = "cffi-1.15.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:285d29981935eb726a4399badae8f0ffdff4f5050eaa6d0cfc3f64b857b77185"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3eb6971dcff08619f8d91607cfc726518b6fa2a9eba42856be181c6d0d9515fd"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:21157295583fe8943475029ed5abdcf71eb3911894724e360acff1d61c1d54bc"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5635bd9cb9731e6d4a1132a498dd34f764034a8ce60cef4f5319c0541159392f"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2012c72d854c2d03e45d06ae57f40d78e5770d252f195b93f581acf3ba44496e"}, + {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd86c085fae2efd48ac91dd7ccffcfc0571387fe1193d33b6394db7ef31fe2a4"}, + {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:fa6693661a4c91757f4412306191b6dc88c1703f780c8234035eac011922bc01"}, + {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:59c0b02d0a6c384d453fece7566d1c7e6b7bae4fc5874ef2ef46d56776d61c9e"}, + {file = "cffi-1.15.1-cp310-cp310-win32.whl", hash = "sha256:cba9d6b9a7d64d4bd46167096fc9d2f835e25d7e4c121fb2ddfc6528fb0413b2"}, + {file = "cffi-1.15.1-cp310-cp310-win_amd64.whl", hash = "sha256:ce4bcc037df4fc5e3d184794f27bdaab018943698f4ca31630bc7f84a7b69c6d"}, + {file = "cffi-1.15.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3d08afd128ddaa624a48cf2b859afef385b720bb4b43df214f85616922e6a5ac"}, + {file = "cffi-1.15.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3799aecf2e17cf585d977b780ce79ff0dc9b78d799fc694221ce814c2c19db83"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a591fe9e525846e4d154205572a029f653ada1a78b93697f3b5a8f1f2bc055b9"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3548db281cd7d2561c9ad9984681c95f7b0e38881201e157833a2342c30d5e8c"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:91fc98adde3d7881af9b59ed0294046f3806221863722ba7d8d120c575314325"}, + {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94411f22c3985acaec6f83c6df553f2dbe17b698cc7f8ae751ff2237d96b9e3c"}, + {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:03425bdae262c76aad70202debd780501fabeaca237cdfddc008987c0e0f59ef"}, + {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cc4d65aeeaa04136a12677d3dd0b1c0c94dc43abac5860ab33cceb42b801c1e8"}, + {file = "cffi-1.15.1-cp311-cp311-win32.whl", hash = "sha256:a0f100c8912c114ff53e1202d0078b425bee3649ae34d7b070e9697f93c5d52d"}, + {file = "cffi-1.15.1-cp311-cp311-win_amd64.whl", hash = "sha256:04ed324bda3cda42b9b695d51bb7d54b680b9719cfab04227cdd1e04e5de3104"}, + {file = "cffi-1.15.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50a74364d85fd319352182ef59c5c790484a336f6db772c1a9231f1c3ed0cbd7"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e263d77ee3dd201c3a142934a086a4450861778baaeeb45db4591ef65550b0a6"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cec7d9412a9102bdc577382c3929b337320c4c4c4849f2c5cdd14d7368c5562d"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4289fc34b2f5316fbb762d75362931e351941fa95fa18789191b33fc4cf9504a"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:173379135477dc8cac4bc58f45db08ab45d228b3363adb7af79436135d028405"}, + {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:6975a3fac6bc83c4a65c9f9fcab9e47019a11d3d2cf7f3c0d03431bf145a941e"}, + {file = "cffi-1.15.1-cp36-cp36m-win32.whl", hash = "sha256:2470043b93ff09bf8fb1d46d1cb756ce6132c54826661a32d4e4d132e1977adf"}, + {file = "cffi-1.15.1-cp36-cp36m-win_amd64.whl", hash = "sha256:30d78fbc8ebf9c92c9b7823ee18eb92f2e6ef79b45ac84db507f52fbe3ec4497"}, + {file = "cffi-1.15.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:198caafb44239b60e252492445da556afafc7d1e3ab7a1fb3f0584ef6d742375"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5ef34d190326c3b1f822a5b7a45f6c4535e2f47ed06fec77d3d799c450b2651e"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8102eaf27e1e448db915d08afa8b41d6c7ca7a04b7d73af6514df10a3e74bd82"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5df2768244d19ab7f60546d0c7c63ce1581f7af8b5de3eb3004b9b6fc8a9f84b"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8c4917bd7ad33e8eb21e9a5bbba979b49d9a97acb3a803092cbc1133e20343c"}, + {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e2642fe3142e4cc4af0799748233ad6da94c62a8bec3a6648bf8ee68b1c7426"}, + {file = "cffi-1.15.1-cp37-cp37m-win32.whl", hash = "sha256:e229a521186c75c8ad9490854fd8bbdd9a0c9aa3a524326b55be83b54d4e0ad9"}, + {file = "cffi-1.15.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a0b71b1b8fbf2b96e41c4d990244165e2c9be83d54962a9a1d118fd8657d2045"}, + {file = "cffi-1.15.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:320dab6e7cb2eacdf0e658569d2575c4dad258c0fcc794f46215e1e39f90f2c3"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e74c6b51a9ed6589199c787bf5f9875612ca4a8a0785fb2d4a84429badaf22a"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5c84c68147988265e60416b57fc83425a78058853509c1b0629c180094904a5"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3b926aa83d1edb5aa5b427b4053dc420ec295a08e40911296b9eb1b6170f6cca"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:87c450779d0914f2861b8526e035c5e6da0a3199d8f1add1a665e1cbc6fc6d02"}, + {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4f2c9f67e9821cad2e5f480bc8d83b8742896f1242dba247911072d4fa94c192"}, + {file = "cffi-1.15.1-cp38-cp38-win32.whl", hash = "sha256:8b7ee99e510d7b66cdb6c593f21c043c248537a32e0bedf02e01e9553a172314"}, + {file = "cffi-1.15.1-cp38-cp38-win_amd64.whl", hash = "sha256:00a9ed42e88df81ffae7a8ab6d9356b371399b91dbdf0c3cb1e84c03a13aceb5"}, + {file = "cffi-1.15.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:54a2db7b78338edd780e7ef7f9f6c442500fb0d41a5a4ea24fff1c929d5af585"}, + {file = "cffi-1.15.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:fcd131dd944808b5bdb38e6f5b53013c5aa4f334c5cad0c72742f6eba4b73db0"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7473e861101c9e72452f9bf8acb984947aa1661a7704553a9f6e4baa5ba64415"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c9a799e985904922a4d207a94eae35c78ebae90e128f0c4e521ce339396be9d"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3bcde07039e586f91b45c88f8583ea7cf7a0770df3a1649627bf598332cb6984"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33ab79603146aace82c2427da5ca6e58f2b3f2fb5da893ceac0c42218a40be35"}, + {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d598b938678ebf3c67377cdd45e09d431369c3b1a5b331058c338e201f12b27"}, + {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:db0fbb9c62743ce59a9ff687eb5f4afbe77e5e8403d6697f7446e5f609976f76"}, + {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:98d85c6a2bef81588d9227dde12db8a7f47f639f4a17c9ae08e773aa9c697bf3"}, + {file = "cffi-1.15.1-cp39-cp39-win32.whl", hash = "sha256:40f4774f5a9d4f5e344f31a32b5096977b5d48560c5592e2f3d2c4374bd543ee"}, + {file = "cffi-1.15.1-cp39-cp39-win_amd64.whl", hash = "sha256:70df4e3b545a17496c9b3f41f5115e69a4f2e77e94e1d2a8e1070bc0c38c8a3c"}, + {file = "cffi-1.15.1.tar.gz", hash = "sha256:d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9"}, +] + +[package.dependencies] +pycparser = "*" + +[[package]] +name = "numpy" +version = "1.24.2" +description = "Fundamental package for array computing in Python" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "numpy-1.24.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:eef70b4fc1e872ebddc38cddacc87c19a3709c0e3e5d20bf3954c147b1dd941d"}, + {file = "numpy-1.24.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8d2859428712785e8a8b7d2b3ef0a1d1565892367b32f915c4a4df44d0e64f5"}, + {file = "numpy-1.24.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6524630f71631be2dabe0c541e7675db82651eb998496bbe16bc4f77f0772253"}, + {file = "numpy-1.24.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a51725a815a6188c662fb66fb32077709a9ca38053f0274640293a14fdd22978"}, + {file = "numpy-1.24.2-cp310-cp310-win32.whl", hash = "sha256:2620e8592136e073bd12ee4536149380695fbe9ebeae845b81237f986479ffc9"}, + {file = "numpy-1.24.2-cp310-cp310-win_amd64.whl", hash = "sha256:97cf27e51fa078078c649a51d7ade3c92d9e709ba2bfb97493007103c741f1d0"}, + {file = "numpy-1.24.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7de8fdde0003f4294655aa5d5f0a89c26b9f22c0a58790c38fae1ed392d44a5a"}, + {file = "numpy-1.24.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4173bde9fa2a005c2c6e2ea8ac1618e2ed2c1c6ec8a7657237854d42094123a0"}, + {file = "numpy-1.24.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4cecaed30dc14123020f77b03601559fff3e6cd0c048f8b5289f4eeabb0eb281"}, + {file = "numpy-1.24.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a23f8440561a633204a67fb44617ce2a299beecf3295f0d13c495518908e910"}, + {file = "numpy-1.24.2-cp311-cp311-win32.whl", hash = "sha256:e428c4fbfa085f947b536706a2fc349245d7baa8334f0c5723c56a10595f9b95"}, + {file = "numpy-1.24.2-cp311-cp311-win_amd64.whl", hash = "sha256:557d42778a6869c2162deb40ad82612645e21d79e11c1dc62c6e82a2220ffb04"}, + {file = "numpy-1.24.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d0a2db9d20117bf523dde15858398e7c0858aadca7c0f088ac0d6edd360e9ad2"}, + {file = "numpy-1.24.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c72a6b2f4af1adfe193f7beb91ddf708ff867a3f977ef2ec53c0ffb8283ab9f5"}, + {file = "numpy-1.24.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c29e6bd0ec49a44d7690ecb623a8eac5ab8a923bce0bea6293953992edf3a76a"}, + {file = "numpy-1.24.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2eabd64ddb96a1239791da78fa5f4e1693ae2dadc82a76bc76a14cbb2b966e96"}, + {file = "numpy-1.24.2-cp38-cp38-win32.whl", hash = "sha256:e3ab5d32784e843fc0dd3ab6dcafc67ef806e6b6828dc6af2f689be0eb4d781d"}, + {file = "numpy-1.24.2-cp38-cp38-win_amd64.whl", hash = "sha256:76807b4063f0002c8532cfeac47a3068a69561e9c8715efdad3c642eb27c0756"}, + {file = "numpy-1.24.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4199e7cfc307a778f72d293372736223e39ec9ac096ff0a2e64853b866a8e18a"}, + {file = "numpy-1.24.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:adbdce121896fd3a17a77ab0b0b5eedf05a9834a18699db6829a64e1dfccca7f"}, + {file = "numpy-1.24.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:889b2cc88b837d86eda1b17008ebeb679d82875022200c6e8e4ce6cf549b7acb"}, + {file = "numpy-1.24.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f64bb98ac59b3ea3bf74b02f13836eb2e24e48e0ab0145bbda646295769bd780"}, + {file = "numpy-1.24.2-cp39-cp39-win32.whl", hash = "sha256:63e45511ee4d9d976637d11e6c9864eae50e12dc9598f531c035265991910468"}, + {file = "numpy-1.24.2-cp39-cp39-win_amd64.whl", hash = "sha256:a77d3e1163a7770164404607b7ba3967fb49b24782a6ef85d9b5f54126cc39e5"}, + {file = "numpy-1.24.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:92011118955724465fb6853def593cf397b4a1367495e0b59a7e69d40c4eb71d"}, + {file = "numpy-1.24.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f9006288bcf4895917d02583cf3411f98631275bc67cce355a7f39f8c14338fa"}, + {file = "numpy-1.24.2-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:150947adbdfeceec4e5926d956a06865c1c690f2fd902efede4ca6fe2e657c3f"}, + {file = "numpy-1.24.2.tar.gz", hash = "sha256:003a9f530e880cb2cd177cba1af7220b9aa42def9c4afc2a2fc3ee6be7eb2b22"}, +] + +[[package]] +name = "pandas" +version = "1.5.3" +description = "Powerful data structures for data analysis, time series, and statistics" +category = "main" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3749077d86e3a2f0ed51367f30bf5b82e131cc0f14260c4d3e499186fccc4406"}, + {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:972d8a45395f2a2d26733eb8d0f629b2f90bebe8e8eddbb8829b180c09639572"}, + {file = "pandas-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50869a35cbb0f2e0cd5ec04b191e7b12ed688874bd05dd777c19b28cbea90996"}, + {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3ac844a0fe00bfaeb2c9b51ab1424e5c8744f89860b138434a363b1f620f354"}, + {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a0a56cef15fd1586726dace5616db75ebcfec9179a3a55e78f72c5639fa2a23"}, + {file = "pandas-1.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:478ff646ca42b20376e4ed3fa2e8d7341e8a63105586efe54fa2508ee087f328"}, + {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6973549c01ca91ec96199e940495219c887ea815b2083722821f1d7abfa2b4dc"}, + {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c39a8da13cede5adcd3be1182883aea1c925476f4e84b2807a46e2775306305d"}, + {file = "pandas-1.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f76d097d12c82a535fda9dfe5e8dd4127952b45fea9b0276cb30cca5ea313fbc"}, + {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e474390e60ed609cec869b0da796ad94f420bb057d86784191eefc62b65819ae"}, + {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f2b952406a1588ad4cad5b3f55f520e82e902388a6d5a4a91baa8d38d23c7f6"}, + {file = "pandas-1.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:bc4c368f42b551bf72fac35c5128963a171b40dce866fb066540eeaf46faa003"}, + {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:14e45300521902689a81f3f41386dc86f19b8ba8dd5ac5a3c7010ef8d2932813"}, + {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9842b6f4b8479e41968eced654487258ed81df7d1c9b7b870ceea24ed9459b31"}, + {file = "pandas-1.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:26d9c71772c7afb9d5046e6e9cf42d83dd147b5cf5bcb9d97252077118543792"}, + {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5fbcb19d6fceb9e946b3e23258757c7b225ba450990d9ed63ccceeb8cae609f7"}, + {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:565fa34a5434d38e9d250af3c12ff931abaf88050551d9fbcdfafca50d62babf"}, + {file = "pandas-1.5.3-cp38-cp38-win32.whl", hash = "sha256:87bd9c03da1ac870a6d2c8902a0e1fd4267ca00f13bc494c9e5a9020920e1d51"}, + {file = "pandas-1.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:41179ce559943d83a9b4bbacb736b04c928b095b5f25dd2b7389eda08f46f373"}, + {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c74a62747864ed568f5a82a49a23a8d7fe171d0c69038b38cedf0976831296fa"}, + {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c4c00e0b0597c8e4f59e8d461f797e5d70b4d025880516a8261b2817c47759ee"}, + {file = "pandas-1.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a50d9a4336a9621cab7b8eb3fb11adb82de58f9b91d84c2cd526576b881a0c5a"}, + {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd05f7783b3274aa206a1af06f0ceed3f9b412cf665b7247eacd83be41cf7bf0"}, + {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f69c4029613de47816b1bb30ff5ac778686688751a5e9c99ad8c7031f6508e5"}, + {file = "pandas-1.5.3-cp39-cp39-win32.whl", hash = "sha256:7cec0bee9f294e5de5bbfc14d0573f65526071029d036b753ee6507d2a21480a"}, + {file = "pandas-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:dfd681c5dc216037e0b0a2c821f5ed99ba9f03ebcf119c7dac0e9a7b960b9ec9"}, + {file = "pandas-1.5.3.tar.gz", hash = "sha256:74a3fd7e5a7ec052f183273dc7b0acd3a863edf7520f5d3a1765c04ffdb3b0b1"}, +] + +[package.dependencies] +numpy = [ + {version = ">=1.20.3", markers = "python_version < \"3.10\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, + {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, +] +python-dateutil = ">=2.8.1" +pytz = ">=2020.1" + +[package.extras] +test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] + +[[package]] +name = "pycparser" +version = "2.21" +description = "C parser in Python" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, + {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, +] + +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "pytz" +version = "2022.7.1" +description = "World timezone definitions, modern and historical" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "pytz-2022.7.1-py2.py3-none-any.whl", hash = "sha256:78f4f37d8198e0627c5f1143240bb0206b8691d8d7ac6d78fee88b78733f8c4a"}, + {file = "pytz-2022.7.1.tar.gz", hash = "sha256:01a0681c4b9684a28304615eba55d1ab31ae00bf68ec157ec3708a8182dbbcd0"}, +] + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.9" +content-hash = "58dbe3e50badcea66493581dddef36d868fc84d26001b2bf5866e979943802e0" diff --git a/testing/python-poetry/poetry.nix b/testing/python-poetry/poetry.nix new file mode 100644 index 000000000..feec68c55 --- /dev/null +++ b/testing/python-poetry/poetry.nix @@ -0,0 +1,21 @@ +let + nixpkgs = import {}; + inherit (nixpkgs) lib poetry2nix python3 runCommand; + + args = { + python = python3; + pyproject = ./pyproject.toml; + poetrylock = ./poetry.lock; + preferWheels = true; + }; + env = poetry2nix.mkPoetryEnv args; + packages = poetry2nix.mkPoetryPackages args; + isWheelCffi = env.python.pkgs.cffi.src.isWheel; + isWheelPandas = env.python.pkgs.pandas.src.isWheel; +in + assert isWheelCffi; assert isWheelPandas; + { + inherit packages env; + python = packages.python; + pkgs = packages.poetryPackages; + } diff --git a/testing/python-poetry/pyproject.toml b/testing/python-poetry/pyproject.toml new file mode 100644 index 000000000..d48114a3c --- /dev/null +++ b/testing/python-poetry/pyproject.toml @@ -0,0 +1,14 @@ +[tool.poetry] +name = "cffi-pandas-wheel" +version = "0.1.0" +description = "Test of cffi-pandas wheel" +authors = ["Your Name "] + +[tool.poetry.dependencies] +python = "^3.9" +cffi = "^1.15.1" +pandas = "^1.5.2" + +[build-system] +requires = ["poetry-core>=1"] +build-backend = "poetry.core.masonry.api" diff --git a/testing/python-poetry/tests/BUILD.bazel b/testing/python-poetry/tests/BUILD.bazel new file mode 100644 index 000000000..76f3ae89f --- /dev/null +++ b/testing/python-poetry/tests/BUILD.bazel @@ -0,0 +1,18 @@ +load("@nixpkgs_python_toolchain//:defs.bzl", "interpreter") +load("@nix_pip//:requirements.bzl", "requirement") + +package(default_testonly = 1) + +py_test( + name = "import-poetry-packages", + main = "imports_test.py", + srcs = ["imports_test.py"], + deps = [ + requirement("cffi"), + requirement("pandas"), + ], + srcs_version = "PY3", + python_version = "PY3", + size = "small", + visibility = ["//visibility:public"], +) diff --git a/testing/python-poetry/tests/imports_test.py b/testing/python-poetry/tests/imports_test.py new file mode 100644 index 000000000..f9b3838ba --- /dev/null +++ b/testing/python-poetry/tests/imports_test.py @@ -0,0 +1,5 @@ +import cffi +print("cffi version = ", cffi.__version__) + +import pandas +print("pandas version = ", pandas.__version__) diff --git a/testing/python-poetry/tests/nixpkgs_repositories.bzl b/testing/python-poetry/tests/nixpkgs_repositories.bzl new file mode 100644 index 000000000..cc5b84933 --- /dev/null +++ b/testing/python-poetry/tests/nixpkgs_repositories.bzl @@ -0,0 +1,53 @@ +load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_local_repository") +load("@rules_nixpkgs_cc//:cc.bzl", "nixpkgs_cc_configure") +load("@rules_nixpkgs_java//:java.bzl", "nixpkgs_java_configure") +load("@rules_nixpkgs_python//:python.bzl", "nixpkgs_python_configure", "nixpkgs_python_repository") +load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_package") + +def nixpkgs_repositories(*, bzlmod): + nixpkgs_local_repository( + name = "nixpkgs", + nix_file = "//:nixpkgs.nix", + nix_file_deps = ["//:flake.lock"], + ) + + # Tests implicitly depend on Java + nixpkgs_java_configure( + name = "nixpkgs_java_runtime", + attribute_path = "jdk11.home", + repository = "@nixpkgs", + toolchain = True, + register = not bzlmod, + toolchain_name = "nixpkgs_java", + toolchain_version = "11", + ) + + # Python depends on a CC toolchain being available + nixpkgs_cc_configure( + name = "nixpkgs_config_cc", + repository = "@nixpkgs", + register = not bzlmod, + ) + + nixpkgs_package( + name = "nixpkgs_python_configure_test", + nix_file = "//tests:python-test.nix", + repository = "@nixpkgs", + ) + + nixpkgs_python_configure( + python2_attribute_path = "python2", + repository = "@nixpkgs", + register = not bzlmod, + ) + + nixpkgs_python_repository( + name = "nix_pip", + repository = "@nixpkgs", + nix_file = "//:poetry.nix", + nix_file_deps = [ + "//:pyproject.toml", + "//:poetry.lock", + ], + ) + diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl index 1f0466fb9..4f15c4d1c 100644 --- a/toolchains/python/python.bzl +++ b/toolchains/python/python.bzl @@ -200,3 +200,184 @@ def nixpkgs_python_configure( if register: native.register_toolchains("@{}//:toolchain".format(name)) + + +def _nixpkgs_python_repository_impl(repository_ctx): + # 2. read generated json + python_modules = repository_ctx.read(repository_ctx.path(repository_ctx.attr.json_deps)) + + content = 'load("//:python_module.bzl", "python_module");' + for pkg_info in json.decode(python_modules): + pkg_name = pkg_info["name"] + pkg_store_path = pkg_info["store_path"] + deps = pkg_info["deps"] + pkg_link_path = "{}-link".format(pkg_name) + repository_ctx.symlink(pkg_store_path, pkg_link_path) + + # Bazel chokes on files containing whitespaces, so we exclude them from + # the glob, hoping they are not important + content += """ +python_module( + name = "{name}", + store_path = "{link}", + files = glob(["{link}/**"], exclude=["{link}/**/* *"]), + deps = {deps}, + visibility = ["//visibility:public"], +) + """.format(name=pkg_name, link=pkg_link_path, deps=deps) + + repository_ctx.file("BUILD.bazel", content) + + # 3. generate BUILD.bazel file, + # ... _and_ the symlinks + # 4. Generate dummy WORKSPACE + # repository_ctx.file("WORKSPACE", "") + + repository_ctx.file("python_module.bzl", """ +def _python_module_impl(ctx): + import_depsets = [] + store = ctx.file.store_path + runfiles = ctx.runfiles(files = [store]) + + for dep in ctx.attr.deps: + runfiles = runfiles.merge(dep[DefaultInfo].data_runfiles) + import_depsets.append(dep[PyInfo].imports) + + # HACK(danny): for some unforunate reason, short_path returns ../ when operating in external + # repositories. I don't know why. It breaks rules_python's assumptions though. + fixed_path = store.short_path[3:] + import_path = "/".join([ctx.workspace_name, store.short_path]) + + return [ + DefaultInfo( + files = depset(ctx.files.files), + default_runfiles = ctx.runfiles(ctx.files.files, collect_default = True), + ), + PyInfo( + imports = depset(direct = [import_path], transitive = import_depsets), + transitive_sources = depset(transitive = [ + dep[PyInfo].transitive_sources + for dep in ctx.attr.deps + ]), + ), + ] + +python_module = rule( + implementation = _python_module_impl, + attrs = { + "store_path": attr.label( + allow_single_file = True, + doc = "nix store path of python package", + ), + "files": attr.label_list( + allow_files = True, + ), + "deps": attr.label_list( + providers = [PyInfo], + ), + }, + executable = False, + test = False, +) +""", + ) + + # 5. generate //:requirements.bzl for later import. + repository_ctx.file("requirements.bzl", """ +def requirement(package_name): + return "@{}//:{{}}".format(package_name) +""".format(repository_ctx.name), + ) + + # TODO: make it lazy in the packages themselves ? + + +_nixpkgs_python_repository = repository_rule( + _nixpkgs_python_repository_impl, + attrs = { + "json_deps": attr.label(), + }, +) + + +def nixpkgs_python_repository( + name, + repository = None, + repositories = {}, + nix_file = None, + nix_file_deps = [], + quiet = False, + ): + """Define a collection of python modules. + + Args: + name: The name for the created module set. + repository: See [`nixpkgs_package`](#nixpkgs_package-repository). + repositories: See [`nixpkgs_package`](#nixpkgs_package-repositories). + nix_file: See [`nixpkgs_package`](#nixpkgs_package-nix_file). + nix_file_deps: See [`nixpkgs_package`](#nixpkgs_package-nix_file_deps). + """ + + generated_deps_name = "_generated_{}_deps".format(name) + + nixpkgs_package( + name = generated_deps_name, + nix_file_content = """ +{ nix_file }: +let + nixpkgs = import {}; + pythonExpr = import nix_file; + inherit (pythonExpr) python pkgs; + + isPythonModule = drv: drv ? pythonModule && drv ? pythonPath; + filterPythonModules = builtins.filter isPythonModule; + + # Ensure the dependency list is unique, otherwise bazel complains about + # duplicate names in the generated python_module() rule + unique = list: builtins.attrNames (builtins.listToAttrs (builtins.map (x: { + name = x; + value = null; + }) list)); + + # Build the list of python modules from the initial set in `pkgs`. + # Each key is the package name, and the value is the derivation itself. + toClosureFormat = builtins.map (drv: { + key = drv.pname; + value = drv // { _pythonModules = filterPythonModules drv.propagatedBuildInputs; }; + }); + startSet = toClosureFormat pkgs; + closure = builtins.genericClosure { + inherit startSet; + operator = item: toClosureFormat (filterPythonModules item.value.propagatedBuildInputs); + }; + + # Using the information generated above, map the package information into + # a list, described in the Output description at the top of this file. + packages = builtins.map ({key, value}: { + name = key; + store_path = "${value}/${python.sitePackages}"; + deps = unique (builtins.map (dep: dep.pname) value._pythonModules); + }) closure; +in + (nixpkgs.writeTextFile { + name = "python-requirements"; + destination = "/requirements.json"; + text = builtins.toJSON packages; + }) // { + inherit python pkgs; + } + """, + repository = repository, + repositories = repositories, + nix_file_deps = nix_file_deps + [ nix_file ], + nixopts = [ "--arg", "nix_file", "$(location {})".format(nix_file) ], + quiet = quiet, + ) + + _nixpkgs_python_repository( + name = name, + json_deps = "@{}//:requirements.json".format(generated_deps_name), + ) + + + From 96f62d579b72d213ff9310d5690de7993a7e8f58 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 15:54:16 +0100 Subject: [PATCH 02/24] Merge python-poetry tests into python tests --- testing/python-poetry/.bazelrc | 3 -- testing/python-poetry/BUILD.bazel | 0 testing/python-poetry/MODULE.bazel | 52 ------------------ testing/python-poetry/WORKSPACE | 45 ---------------- testing/python-poetry/WORKSPACE.bzlmod | 0 testing/python-poetry/flake.lock | 1 - testing/python-poetry/nixpkgs.nix | 1 - testing/python-poetry/non_module_deps.bzl | 11 ---- testing/python-poetry/tests/BUILD.bazel | 18 ------- .../tests/nixpkgs_repositories.bzl | 53 ------------------- testing/{python-poetry => python}/poetry.lock | 0 testing/{python-poetry => python}/poetry.nix | 0 .../{python-poetry => python}/pyproject.toml | 0 testing/python/tests/BUILD.bazel | 15 ++++++ .../tests/import_packages_test.py} | 0 testing/python/tests/nixpkgs_repositories.bzl | 12 ++++- 16 files changed, 26 insertions(+), 185 deletions(-) delete mode 100644 testing/python-poetry/.bazelrc delete mode 100644 testing/python-poetry/BUILD.bazel delete mode 100644 testing/python-poetry/MODULE.bazel delete mode 100644 testing/python-poetry/WORKSPACE delete mode 100644 testing/python-poetry/WORKSPACE.bzlmod delete mode 120000 testing/python-poetry/flake.lock delete mode 120000 testing/python-poetry/nixpkgs.nix delete mode 100644 testing/python-poetry/non_module_deps.bzl delete mode 100644 testing/python-poetry/tests/BUILD.bazel delete mode 100644 testing/python-poetry/tests/nixpkgs_repositories.bzl rename testing/{python-poetry => python}/poetry.lock (100%) rename testing/{python-poetry => python}/poetry.nix (100%) rename testing/{python-poetry => python}/pyproject.toml (100%) rename testing/{python-poetry/tests/imports_test.py => python/tests/import_packages_test.py} (100%) diff --git a/testing/python-poetry/.bazelrc b/testing/python-poetry/.bazelrc deleted file mode 100644 index ae8f32bd8..000000000 --- a/testing/python-poetry/.bazelrc +++ /dev/null @@ -1,3 +0,0 @@ -import %workspace%/../../.bazelrc.common -import %workspace%/../../.bazelrc.cc -import %workspace%/../../.bazelrc.java diff --git a/testing/python-poetry/BUILD.bazel b/testing/python-poetry/BUILD.bazel deleted file mode 100644 index e69de29bb..000000000 diff --git a/testing/python-poetry/MODULE.bazel b/testing/python-poetry/MODULE.bazel deleted file mode 100644 index 1e32df581..000000000 --- a/testing/python-poetry/MODULE.bazel +++ /dev/null @@ -1,52 +0,0 @@ -module(name = "rules_nixpkgs_python_testing") - -bazel_dep(name = "rules_nixpkgs_python") -local_path_override( - module_name = "rules_nixpkgs_python", - path = "../../toolchains/python", -) - -bazel_dep(name = "rules_nixpkgs_core") -local_path_override( - module_name = "rules_nixpkgs_core", - path = "../../core", -) - -bazel_dep(name = "rules_nixpkgs_java") -local_path_override( - module_name = "rules_nixpkgs_java", - path = "../../toolchains/java", -) - -bazel_dep(name = "rules_nixpkgs_cc") -local_path_override( - module_name = "rules_nixpkgs_cc", - path = "../../toolchains/cc", -) - -bazel_dep(name = "bazel_skylib", version = "1.0.3") -bazel_dep(name = "rules_cc", version = "0.0.4") - -# TODO[AH] Remove these transitive dependencies once nixpkgs_java_configure has -# become a module extension in rules_nixpkgs_java. -bazel_dep(name = "platforms", version = "0.0.4") -bazel_dep(name = "rules_java", version = "4.0.0") -java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") -use_repo(java_toolchains, "remote_java_tools") - -non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps") - -use_repo(non_module_deps, "nixpkgs_java_runtime") -use_repo(non_module_deps, "nixpkgs_java_runtime_toolchain") -register_toolchains("@nixpkgs_java_runtime_toolchain//:all") - -use_repo(non_module_deps, "nixpkgs_config_cc") -use_repo(non_module_deps, "nixpkgs_config_cc_info") -use_repo(non_module_deps, "nixpkgs_config_cc_toolchains") -register_toolchains("@nixpkgs_config_cc_toolchains//:all") - -use_repo(non_module_deps, "nixpkgs") -use_repo(non_module_deps, "nixpkgs_python_toolchain") -use_repo(non_module_deps, "nixpkgs_python_configure_test") -use_repo(non_module_deps, "nixpkgs_python_toolchain_python3") -register_toolchains("@nixpkgs_python_toolchain//:all") diff --git a/testing/python-poetry/WORKSPACE b/testing/python-poetry/WORKSPACE deleted file mode 100644 index 84476c4fb..000000000 --- a/testing/python-poetry/WORKSPACE +++ /dev/null @@ -1,45 +0,0 @@ -workspace(name = "rules_nixpkgs_python_testing") - -local_repository( - name = "rules_nixpkgs_python", - path = "../../toolchains/python", -) - -local_repository( - name = "rules_nixpkgs_core", - path = "../../core", -) - -local_repository( - name = "rules_nixpkgs_java", - path = "../../toolchains/java", -) - -local_repository( - name = "rules_nixpkgs_cc", - path = "../../toolchains/cc", -) - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "bazel_skylib", - sha256 = "f24ab666394232f834f74d19e2ff142b0af17466ea0c69a3f4c276ee75f6efce", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-1.4.0.tar.gz", - ], -) - -load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") - -bazel_skylib_workspace() - -load( - "//tests:nixpkgs_repositories.bzl", - "nixpkgs_repositories", -) - -nixpkgs_repositories(bzlmod = False) - - diff --git a/testing/python-poetry/WORKSPACE.bzlmod b/testing/python-poetry/WORKSPACE.bzlmod deleted file mode 100644 index e69de29bb..000000000 diff --git a/testing/python-poetry/flake.lock b/testing/python-poetry/flake.lock deleted file mode 120000 index 23b0a9b50..000000000 --- a/testing/python-poetry/flake.lock +++ /dev/null @@ -1 +0,0 @@ -../../flake.lock \ No newline at end of file diff --git a/testing/python-poetry/nixpkgs.nix b/testing/python-poetry/nixpkgs.nix deleted file mode 120000 index ead0b0058..000000000 --- a/testing/python-poetry/nixpkgs.nix +++ /dev/null @@ -1 +0,0 @@ -../../docs/nixpkgs.nix \ No newline at end of file diff --git a/testing/python-poetry/non_module_deps.bzl b/testing/python-poetry/non_module_deps.bzl deleted file mode 100644 index 1e758095b..000000000 --- a/testing/python-poetry/non_module_deps.bzl +++ /dev/null @@ -1,11 +0,0 @@ -load( - "//tests:nixpkgs_repositories.bzl", - "nixpkgs_repositories", -) - -def _non_module_deps_impl(ctx): - nixpkgs_repositories(bzlmod = True) - -non_module_deps = module_extension( - implementation = _non_module_deps_impl, -) diff --git a/testing/python-poetry/tests/BUILD.bazel b/testing/python-poetry/tests/BUILD.bazel deleted file mode 100644 index 76f3ae89f..000000000 --- a/testing/python-poetry/tests/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -load("@nixpkgs_python_toolchain//:defs.bzl", "interpreter") -load("@nix_pip//:requirements.bzl", "requirement") - -package(default_testonly = 1) - -py_test( - name = "import-poetry-packages", - main = "imports_test.py", - srcs = ["imports_test.py"], - deps = [ - requirement("cffi"), - requirement("pandas"), - ], - srcs_version = "PY3", - python_version = "PY3", - size = "small", - visibility = ["//visibility:public"], -) diff --git a/testing/python-poetry/tests/nixpkgs_repositories.bzl b/testing/python-poetry/tests/nixpkgs_repositories.bzl deleted file mode 100644 index cc5b84933..000000000 --- a/testing/python-poetry/tests/nixpkgs_repositories.bzl +++ /dev/null @@ -1,53 +0,0 @@ -load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_local_repository") -load("@rules_nixpkgs_cc//:cc.bzl", "nixpkgs_cc_configure") -load("@rules_nixpkgs_java//:java.bzl", "nixpkgs_java_configure") -load("@rules_nixpkgs_python//:python.bzl", "nixpkgs_python_configure", "nixpkgs_python_repository") -load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_package") - -def nixpkgs_repositories(*, bzlmod): - nixpkgs_local_repository( - name = "nixpkgs", - nix_file = "//:nixpkgs.nix", - nix_file_deps = ["//:flake.lock"], - ) - - # Tests implicitly depend on Java - nixpkgs_java_configure( - name = "nixpkgs_java_runtime", - attribute_path = "jdk11.home", - repository = "@nixpkgs", - toolchain = True, - register = not bzlmod, - toolchain_name = "nixpkgs_java", - toolchain_version = "11", - ) - - # Python depends on a CC toolchain being available - nixpkgs_cc_configure( - name = "nixpkgs_config_cc", - repository = "@nixpkgs", - register = not bzlmod, - ) - - nixpkgs_package( - name = "nixpkgs_python_configure_test", - nix_file = "//tests:python-test.nix", - repository = "@nixpkgs", - ) - - nixpkgs_python_configure( - python2_attribute_path = "python2", - repository = "@nixpkgs", - register = not bzlmod, - ) - - nixpkgs_python_repository( - name = "nix_pip", - repository = "@nixpkgs", - nix_file = "//:poetry.nix", - nix_file_deps = [ - "//:pyproject.toml", - "//:poetry.lock", - ], - ) - diff --git a/testing/python-poetry/poetry.lock b/testing/python/poetry.lock similarity index 100% rename from testing/python-poetry/poetry.lock rename to testing/python/poetry.lock diff --git a/testing/python-poetry/poetry.nix b/testing/python/poetry.nix similarity index 100% rename from testing/python-poetry/poetry.nix rename to testing/python/poetry.nix diff --git a/testing/python-poetry/pyproject.toml b/testing/python/pyproject.toml similarity index 100% rename from testing/python-poetry/pyproject.toml rename to testing/python/pyproject.toml diff --git a/testing/python/tests/BUILD.bazel b/testing/python/tests/BUILD.bazel index 9a2e5a47d..837ffa5c7 100644 --- a/testing/python/tests/BUILD.bazel +++ b/testing/python/tests/BUILD.bazel @@ -1,4 +1,5 @@ load("@nixpkgs_python_toolchain//:defs.bzl", "interpreter") +load("@poetry_packages//:requirements.bzl", poetry_requirement = "requirement") package(default_testonly = 1) # Test nixpkgs_python_configure() by running some Python code. @@ -20,3 +21,17 @@ py_test( python_version = "PY3", visibility = ["//visibility:public"], ) + +py_test( + name = "import-poetry-packages", + main = "import_packages_test.py", + srcs = ["import_packages_test.py"], + deps = [ + poetry_requirement("cffi"), + poetry_requirement("pandas"), + ], + srcs_version = "PY3", + python_version = "PY3", + size = "small", + visibility = ["//visibility:public"], +) diff --git a/testing/python-poetry/tests/imports_test.py b/testing/python/tests/import_packages_test.py similarity index 100% rename from testing/python-poetry/tests/imports_test.py rename to testing/python/tests/import_packages_test.py diff --git a/testing/python/tests/nixpkgs_repositories.bzl b/testing/python/tests/nixpkgs_repositories.bzl index 2e2f914b6..4177e320b 100644 --- a/testing/python/tests/nixpkgs_repositories.bzl +++ b/testing/python/tests/nixpkgs_repositories.bzl @@ -1,7 +1,7 @@ load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_local_repository") load("@rules_nixpkgs_cc//:cc.bzl", "nixpkgs_cc_configure") load("@rules_nixpkgs_java//:java.bzl", "nixpkgs_java_configure") -load("@rules_nixpkgs_python//:python.bzl", "nixpkgs_python_configure") +load("@rules_nixpkgs_python//:python.bzl", "nixpkgs_python_configure", "nixpkgs_python_repository") load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_package") def nixpkgs_repositories(*, bzlmod): @@ -40,3 +40,13 @@ def nixpkgs_repositories(*, bzlmod): repository = "@nixpkgs", register = not bzlmod, ) + + nixpkgs_python_repository( + name = "poetry_packages", + repository = "@nixpkgs", + nix_file = "//:poetry.nix", + nix_file_deps = [ + "//:pyproject.toml", + "//:poetry.lock", + ], + ) From ec25c601025dacae3ceb5e12d0e096e2ab9bc826 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 16:25:22 +0100 Subject: [PATCH 03/24] Improve nixpkgs_python_repository documentation --- toolchains/python/python.bzl | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl index 4f15c4d1c..9949485b9 100644 --- a/toolchains/python/python.bzl +++ b/toolchains/python/python.bzl @@ -308,7 +308,40 @@ def nixpkgs_python_repository( nix_file_deps = [], quiet = False, ): - """Define a collection of python modules. + """Define a collection of python modules based on a nix file. + + The only entry point is a [`nix_file`](#nixpkgs_python_repository-nix_file) + which should expose a `pkgs` and a `python` attributes. `python` is the + python interpreter, and `pkgs` a set of python packages that will be made + available to bazel. + + :warning: All the packages in `pkgs` are built by this rule. It is + therefore not a good idea to expose something as big as `pkgs.python3` as + provided by nixpkgs. + + This rule is instead intended to expose an ad-hoc set of packages for your + project, as can be built by poetry2nix, mach-nix, dream2nix or by manually + picking the python packages you need from nixpkgs. + + The format is generic to support the many ways to generate such packages + sets with nixpkgs. See our python [`tests`](/testing/toolchains/python) and + [examples](`/examples/toolchains/python`) to get started. + + This rule is intended to mimic as closely as possible the [rules_python + API](https://github.com/bazelbuild/rules_python#using-the-package-installation-rules). + `nixpkgs_python_repository` should be a drop-in replacement of `pip_parse`. + As such, it also provides a `requirement` function to perform the name + mangling. Using the `requirement` fucntion inherits the same advantages and + limitations as the one in rules_python. All the function does is create a + label of the form `@{nixpkgs_python_repository_name}//:{package_name}`. + While depending on such a label directly will work, the layout may change + in the future. To be on the safe side, define and import your own + `requirement` function if you need to play with these labels. + + :warning: packages names exposed by this rule are determined by the `pname` + attribute of the nix packages. These may vary slightly from names used by + rules_python. Should this be a problem, you can provide you own + `requirement` function. Args: name: The name for the created module set. @@ -316,6 +349,7 @@ def nixpkgs_python_repository( repositories: See [`nixpkgs_package`](#nixpkgs_package-repositories). nix_file: See [`nixpkgs_package`](#nixpkgs_package-nix_file). nix_file_deps: See [`nixpkgs_package`](#nixpkgs_package-nix_file_deps). + quiet: See [`nixpkgs_package`](#nixpkgs_package-quiet). """ generated_deps_name = "_generated_{}_deps".format(name) From 5e5ee289ba6275f232bb06979af2262ac168edc8 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 16:48:03 +0100 Subject: [PATCH 04/24] Move large chunks of text to their own file. --- toolchains/python/package_set_to_json.nix | 49 +++++++++ toolchains/python/python.bzl | 128 +++------------------- toolchains/python/python_package.bzl | 46 ++++++++ 3 files changed, 111 insertions(+), 112 deletions(-) create mode 100644 toolchains/python/package_set_to_json.nix create mode 100644 toolchains/python/python_package.bzl diff --git a/toolchains/python/package_set_to_json.nix b/toolchains/python/package_set_to_json.nix new file mode 100644 index 000000000..821d8b506 --- /dev/null +++ b/toolchains/python/package_set_to_json.nix @@ -0,0 +1,49 @@ +{ + # A file to be later `import`ed, and providing two attributes: + # - `python`: used to obtain the valie of `sitePackages` + # - `pkgs`: a set of python packages whose closure will be exposed in the + # generated json file, and consumed by `nixpkgs_python_repository` rule. + nix_file +}: +let + nixpkgs = import {}; + pythonExpr = import nix_file; + inherit (pythonExpr) python pkgs; + + isPythonModule = drv: drv ? pythonModule && drv ? pythonPath; + filterPythonModules = builtins.filter isPythonModule; + + # Ensure the dependency list is unique, otherwise bazel complains about + # duplicate names in the generated python_module() rule + unique = list: builtins.attrNames (builtins.listToAttrs (builtins.map (x: { + name = x; + value = null; + }) list)); + + # Build the list of python modules from the initial set in `pkgs`. + # Each key is the package name, and the value is the derivation itself. + toClosureFormat = builtins.map (drv: { + key = drv.pname; + value = drv // { _pythonModules = filterPythonModules drv.propagatedBuildInputs; }; + }); + startSet = toClosureFormat pkgs; + closure = builtins.genericClosure { + inherit startSet; + operator = item: toClosureFormat (filterPythonModules item.value.propagatedBuildInputs); + }; + + # Using the information generated above, map the package information into + # a list, described in the Output description at the top of this file. + packages = builtins.map ({key, value}: { + name = key; + store_path = "${value}/${python.sitePackages}"; + deps = unique (builtins.map (dep: dep.pname) value._pythonModules); + }) closure; +in + (nixpkgs.writeTextFile { + name = "python-requirements"; + destination = "/requirements.json"; + text = builtins.toJSON packages; + }) // { + inherit python pkgs; + } diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl index 9949485b9..bda6c4fb0 100644 --- a/toolchains/python/python.bzl +++ b/toolchains/python/python.bzl @@ -203,11 +203,12 @@ def nixpkgs_python_configure( def _nixpkgs_python_repository_impl(repository_ctx): - # 2. read generated json - python_modules = repository_ctx.read(repository_ctx.path(repository_ctx.attr.json_deps)) + # Read generated json + python_packages = repository_ctx.read(repository_ctx.path(repository_ctx.attr.json_deps)) - content = 'load("//:python_module.bzl", "python_module");' - for pkg_info in json.decode(python_modules): + # Generate BUILD.bazel content from the json data + content = 'load("@rules_nixpkgs_python//:python_package.bzl", "python_package");' + for pkg_info in json.decode(python_packages): pkg_name = pkg_info["name"] pkg_store_path = pkg_info["store_path"] deps = pkg_info["deps"] @@ -217,7 +218,7 @@ def _nixpkgs_python_repository_impl(repository_ctx): # Bazel chokes on files containing whitespaces, so we exclude them from # the glob, hoping they are not important content += """ -python_module( +python_package( name = "{name}", store_path = "{link}", files = glob(["{link}/**"], exclude=["{link}/**/* *"]), @@ -226,63 +227,10 @@ python_module( ) """.format(name=pkg_name, link=pkg_link_path, deps=deps) + # Write the content to the file repository_ctx.file("BUILD.bazel", content) - # 3. generate BUILD.bazel file, - # ... _and_ the symlinks - # 4. Generate dummy WORKSPACE - # repository_ctx.file("WORKSPACE", "") - - repository_ctx.file("python_module.bzl", """ -def _python_module_impl(ctx): - import_depsets = [] - store = ctx.file.store_path - runfiles = ctx.runfiles(files = [store]) - - for dep in ctx.attr.deps: - runfiles = runfiles.merge(dep[DefaultInfo].data_runfiles) - import_depsets.append(dep[PyInfo].imports) - - # HACK(danny): for some unforunate reason, short_path returns ../ when operating in external - # repositories. I don't know why. It breaks rules_python's assumptions though. - fixed_path = store.short_path[3:] - import_path = "/".join([ctx.workspace_name, store.short_path]) - - return [ - DefaultInfo( - files = depset(ctx.files.files), - default_runfiles = ctx.runfiles(ctx.files.files, collect_default = True), - ), - PyInfo( - imports = depset(direct = [import_path], transitive = import_depsets), - transitive_sources = depset(transitive = [ - dep[PyInfo].transitive_sources - for dep in ctx.attr.deps - ]), - ), - ] - -python_module = rule( - implementation = _python_module_impl, - attrs = { - "store_path": attr.label( - allow_single_file = True, - doc = "nix store path of python package", - ), - "files": attr.label_list( - allow_files = True, - ), - "deps": attr.label_list( - providers = [PyInfo], - ), - }, - executable = False, - test = False, -) -""", - ) - - # 5. generate //:requirements.bzl for later import. + # Generate //:requirements.bzl to provide `requirement` like rules_python repository_ctx.file("requirements.bzl", """ def requirement(package_name): return "@{}//:{{}}".format(package_name) @@ -308,7 +256,7 @@ def nixpkgs_python_repository( nix_file_deps = [], quiet = False, ): - """Define a collection of python modules based on a nix file. + """Define a collection of python packages based on a nix file. The only entry point is a [`nix_file`](#nixpkgs_python_repository-nix_file) which should expose a `pkgs` and a `python` attributes. `python` is the @@ -344,7 +292,7 @@ def nixpkgs_python_repository( `requirement` function. Args: - name: The name for the created module set. + name: The name for the created package set. repository: See [`nixpkgs_package`](#nixpkgs_package-repository). repositories: See [`nixpkgs_package`](#nixpkgs_package-repositories). nix_file: See [`nixpkgs_package`](#nixpkgs_package-nix_file). @@ -356,56 +304,12 @@ def nixpkgs_python_repository( nixpkgs_package( name = generated_deps_name, - nix_file_content = """ -{ nix_file }: -let - nixpkgs = import {}; - pythonExpr = import nix_file; - inherit (pythonExpr) python pkgs; - - isPythonModule = drv: drv ? pythonModule && drv ? pythonPath; - filterPythonModules = builtins.filter isPythonModule; - - # Ensure the dependency list is unique, otherwise bazel complains about - # duplicate names in the generated python_module() rule - unique = list: builtins.attrNames (builtins.listToAttrs (builtins.map (x: { - name = x; - value = null; - }) list)); - - # Build the list of python modules from the initial set in `pkgs`. - # Each key is the package name, and the value is the derivation itself. - toClosureFormat = builtins.map (drv: { - key = drv.pname; - value = drv // { _pythonModules = filterPythonModules drv.propagatedBuildInputs; }; - }); - startSet = toClosureFormat pkgs; - closure = builtins.genericClosure { - inherit startSet; - operator = item: toClosureFormat (filterPythonModules item.value.propagatedBuildInputs); - }; - - # Using the information generated above, map the package information into - # a list, described in the Output description at the top of this file. - packages = builtins.map ({key, value}: { - name = key; - store_path = "${value}/${python.sitePackages}"; - deps = unique (builtins.map (dep: dep.pname) value._pythonModules); - }) closure; -in - (nixpkgs.writeTextFile { - name = "python-requirements"; - destination = "/requirements.json"; - text = builtins.toJSON packages; - }) // { - inherit python pkgs; - } - """, - repository = repository, - repositories = repositories, - nix_file_deps = nix_file_deps + [ nix_file ], - nixopts = [ "--arg", "nix_file", "$(location {})".format(nix_file) ], - quiet = quiet, + nix_file = "@rules_nixpkgs_python//:package_set_to_json.nix", + repository = repository, + repositories = repositories, + nix_file_deps = nix_file_deps + [ nix_file ], + nixopts = [ "--arg", "nix_file", "$(location {})".format(nix_file) ], + quiet = quiet, ) _nixpkgs_python_repository( diff --git a/toolchains/python/python_package.bzl b/toolchains/python/python_package.bzl new file mode 100644 index 000000000..6be00c6b9 --- /dev/null +++ b/toolchains/python/python_package.bzl @@ -0,0 +1,46 @@ +def _python_package_impl(ctx): + import_depsets = [] + store = ctx.file.store_path + runfiles = ctx.runfiles(files = [store]) + + for dep in ctx.attr.deps: + runfiles = runfiles.merge(dep[DefaultInfo].data_runfiles) + import_depsets.append(dep[PyInfo].imports) + + # HACK(danny): for some unforunate reason, short_path returns ../ when operating in external + # repositories. I don't know why. It breaks rules_python's assumptions though. + # See https://github.com/bazelbuild/bazel-skylib/issues/303 for some discussion. + fixed_path = store.short_path[3:] + import_path = "/".join([ctx.workspace_name, store.short_path]) + + return [ + DefaultInfo( + files = depset(ctx.files.files), + default_runfiles = ctx.runfiles(ctx.files.files, collect_default = True), + ), + PyInfo( + imports = depset(direct = [import_path], transitive = import_depsets), + transitive_sources = depset(transitive = [ + dep[PyInfo].transitive_sources + for dep in ctx.attr.deps + ]), + ), + ] + +python_package = rule( + implementation = _python_package_impl, + attrs = { + "store_path": attr.label( + allow_single_file = True, + doc = "nix store path of python package", + ), + "files": attr.label_list( + allow_files = True, + ), + "deps": attr.label_list( + providers = [PyInfo], + ), + }, + executable = False, + test = False, +) From 5324f760843735a88c8d45153717ecc622cbd8c8 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 17:04:53 +0100 Subject: [PATCH 05/24] Explain and improve package_set_to_json.nix --- toolchains/python/package_set_to_json.nix | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/toolchains/python/package_set_to_json.nix b/toolchains/python/package_set_to_json.nix index 821d8b506..b452d4927 100644 --- a/toolchains/python/package_set_to_json.nix +++ b/toolchains/python/package_set_to_json.nix @@ -8,13 +8,13 @@ let nixpkgs = import {}; pythonExpr = import nix_file; - inherit (pythonExpr) python pkgs; isPythonModule = drv: drv ? pythonModule && drv ? pythonPath; filterPythonModules = builtins.filter isPythonModule; # Ensure the dependency list is unique, otherwise bazel complains about # duplicate names in the generated python_module() rule + # Should be faster than nixpkgs lib.lists.unique as it uses an attr set. unique = list: builtins.attrNames (builtins.listToAttrs (builtins.map (x: { name = x; value = null; @@ -26,24 +26,23 @@ let key = drv.pname; value = drv // { _pythonModules = filterPythonModules drv.propagatedBuildInputs; }; }); - startSet = toClosureFormat pkgs; + startSet = toClosureFormat pythonExpr.pkgs; closure = builtins.genericClosure { inherit startSet; operator = item: toClosureFormat (filterPythonModules item.value.propagatedBuildInputs); }; # Using the information generated above, map the package information into - # a list, described in the Output description at the top of this file. + # a list of entries containing the name, the output path, and the name of + # python runtime dependencies, to later generate a valid BUILD file. packages = builtins.map ({key, value}: { name = key; - store_path = "${value}/${python.sitePackages}"; + store_path = "${value}/${pythonExpr.python.sitePackages}"; deps = unique (builtins.map (dep: dep.pname) value._pythonModules); }) closure; in - (nixpkgs.writeTextFile { - name = "python-requirements"; - destination = "/requirements.json"; - text = builtins.toJSON packages; - }) // { - inherit python pkgs; - } +nixpkgs.writeTextFile { + name = "python-requirements"; + destination = "/requirements.json"; + text = builtins.toJSON packages; +} From bc18feb0a8de78082ae59226671f920a017c756c Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 20:52:08 +0100 Subject: [PATCH 06/24] Document and update python_package.bzl --- toolchains/python/python_package.bzl | 37 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/toolchains/python/python_package.bzl b/toolchains/python/python_package.bzl index 6be00c6b9..b6e187513 100644 --- a/toolchains/python/python_package.bzl +++ b/toolchains/python/python_package.bzl @@ -1,29 +1,34 @@ def _python_package_impl(ctx): - import_depsets = [] - store = ctx.file.store_path - runfiles = ctx.runfiles(files = [store]) - - for dep in ctx.attr.deps: - runfiles = runfiles.merge(dep[DefaultInfo].data_runfiles) - import_depsets.append(dep[PyInfo].imports) + transitive_imports = [] + transitive_runfiles = [] + transitive_sources = [] # HACK(danny): for some unforunate reason, short_path returns ../ when operating in external # repositories. I don't know why. It breaks rules_python's assumptions though. # See https://github.com/bazelbuild/bazel-skylib/issues/303 for some discussion. + store = ctx.file.store_path fixed_path = store.short_path[3:] import_path = "/".join([ctx.workspace_name, store.short_path]) + for dep in ctx.attr.deps: + transitive_runfiles.append(dep[DefaultInfo].default_runfiles) + transitive_imports.append(dep[PyInfo].imports) + transitive_sources.append(dep[PyInfo].transitive_sources) + return [ DefaultInfo( + # Files that are built when this target is built directly. files = depset(ctx.files.files), - default_runfiles = ctx.runfiles(ctx.files.files, collect_default = True), + # Files that must be present when this target is executed. + runfiles = ctx.runfiles(files = ctx.files.files).merge_all(transitive_runfiles), ), PyInfo( - imports = depset(direct = [import_path], transitive = import_depsets), - transitive_sources = depset(transitive = [ - dep[PyInfo].transitive_sources - for dep in ctx.attr.deps - ]), + # Paths that should compose the python path for packages and modules lookup + imports = depset(direct = [import_path], transitive = transitive_imports), + # Unclear semantics, so just forward. We decide to look at nix + # python packages as binary results that contain no "sources". Can + # be changed if needed. + transitive_sources = depset(transitive = transitive_sources), ), ] @@ -32,13 +37,17 @@ python_package = rule( attrs = { "store_path": attr.label( allow_single_file = True, - doc = "nix store path of python package", + doc = "Nix store path of python package", ), "files": attr.label_list( allow_files = True, + doc = """All the files that compose this package. You probably want + to use `glob(["**"], exclude=["**/* *"])` to collect them without + including the strange ones that contain a space in their name.""", ), "deps": attr.label_list( providers = [PyInfo], + doc = "`python_package`s that are runtime dependencies of this package.", ), }, executable = False, From c46ac5f166d1b6595ce4c895a39fc09d9063d6cc Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 22:51:31 +0100 Subject: [PATCH 07/24] Generate documentation for nixpkgs_python_repository --- README.md | 140 ++++++++++++++++++++++++++++ docs/BUILD.bazel | 1 + nixpkgs/nixpkgs.bzl | 3 + toolchains/python/README.md | 142 ++++++++++++++++++++++++++++- toolchains/python/docs/BUILD.bazel | 5 +- toolchains/python/python.bzl | 3 +- 6 files changed, 291 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 990957106..2d0c1c769 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ See [examples](/examples/toolchains) for how to use `rules_nixpkgs` with differe * [nixpkgs_cc_configure_deprecated](#nixpkgs_cc_configure_deprecated) * [nixpkgs_java_configure](#nixpkgs_java_configure) * [nixpkgs_python_configure](#nixpkgs_python_configure) +* [nixpkgs_python_repository](#nixpkgs_python_repository) * [nixpkgs_go_configure](toolchains/go/README.md#nixpkgs_go_configure) * [nixpkgs_rust_configure](#nixpkgs_rust_configure) * [nixpkgs_sh_posix_configure](#nixpkgs_sh_posix_configure) @@ -1836,6 +1837,145 @@ default is True + + +### nixpkgs_python_repository + +
+nixpkgs_python_repository(name, repository, repositories, nix_file, nix_file_deps, quiet)
+
+ +Define a collection of python packages based on a nix file. + +The only entry point is a [`nix_file`](#nixpkgs_python_repository-nix_file) +which should expose a `pkgs` and a `python` attributes. `python` is the +python interpreter, and `pkgs` a set of python packages that will be made +available to bazel. + +:warning: All the packages in `pkgs` are built by this rule. It is +therefore not a good idea to expose something as big as `pkgs.python3` as +provided by nixpkgs. + +This rule is instead intended to expose an ad-hoc set of packages for your +project, as can be built by poetry2nix, mach-nix, dream2nix or by manually +picking the python packages you need from nixpkgs. + +The format is generic to support the many ways to generate such packages +sets with nixpkgs. See our python [`tests`](/testing/toolchains/python) and +[examples](`/examples/toolchains/python`) to get started. + +This rule is intended to mimic as closely as possible the [rules_python +API](https://github.com/bazelbuild/rules_python#using-the-package-installation-rules). +`nixpkgs_python_repository` should be a drop-in replacement of `pip_parse`. +As such, it also provides a `requirement` function to perform the name +mangling. Using the `requirement` fucntion inherits the same advantages and +limitations as the one in rules_python. All the function does is create a +label of the form `@{nixpkgs_python_repository_name}//:{package_name}`. +While depending on such a label directly will work, the layout may change +in the future. To be on the safe side, define and import your own +`requirement` function if you need to play with these labels. + +:warning: packages names exposed by this rule are determined by the `pname` +attribute of the nix packages. These may vary slightly from names used by +rules_python. Should this be a problem, you can provide you own +`requirement` function. + + +#### Parameters + + ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
name + +required. + +

+ +The name for the created package set. + +

+
repository + +optional. +default is None + +

+ +See [`nixpkgs_package`](#nixpkgs_package-repository). + +

+
repositories + +optional. +default is {} + +

+ +See [`nixpkgs_package`](#nixpkgs_package-repositories). + +

+
nix_file + +optional. +default is None + +

+ +See [`nixpkgs_package`](#nixpkgs_package-nix_file). + +

+
nix_file_deps + +optional. +default is [] + +

+ +See [`nixpkgs_package`](#nixpkgs_package-nix_file_deps). + +

+
quiet + +optional. +default is False + +

+ +See [`nixpkgs_package`](#nixpkgs_package-quiet). + +

+
+ + ### nixpkgs_rust_configure diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 5dfa9d021..fa2d6118e 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -18,6 +18,7 @@ generate_documentation( "nixpkgs_go_configure", "nixpkgs_java_configure", "nixpkgs_python_configure", + "nixpkgs_python_repository", "nixpkgs_rust_configure", "nixpkgs_sh_posix_configure", "nixpkgs_nodejs_configure", diff --git a/nixpkgs/nixpkgs.bzl b/nixpkgs/nixpkgs.bzl index 067fe7ce5..794e14091 100644 --- a/nixpkgs/nixpkgs.bzl +++ b/nixpkgs/nixpkgs.bzl @@ -32,6 +32,7 @@ See [examples](/examples/toolchains) for how to use `rules_nixpkgs` with differe * [nixpkgs_cc_configure_deprecated](#nixpkgs_cc_configure_deprecated) * [nixpkgs_java_configure](#nixpkgs_java_configure) * [nixpkgs_python_configure](#nixpkgs_python_configure) +* [nixpkgs_python_repository](#nixpkgs_python_repository) * [nixpkgs_go_configure](toolchains/go/README.md#nixpkgs_go_configure) * [nixpkgs_rust_configure](#nixpkgs_rust_configure) * [nixpkgs_sh_posix_configure](#nixpkgs_sh_posix_configure) @@ -130,6 +131,7 @@ load( load( "@rules_nixpkgs_python//:python.bzl", _nixpkgs_python_configure = "nixpkgs_python_configure", + _nixpkgs_python_repository = "nixpkgs_python_repository", ) load( "@rules_nixpkgs_java//:java.bzl", @@ -158,6 +160,7 @@ nixpkgs_git_repository = _nixpkgs_git_repository nixpkgs_local_repository = _nixpkgs_local_repository nixpkgs_package = _nixpkgs_package nixpkgs_python_configure = _nixpkgs_python_configure +nixpkgs_python_repository = _nixpkgs_python_repository nixpkgs_java_configure = _nixpkgs_java_configure nixpkgs_cc_configure = _nixpkgs_cc_configure nixpkgs_rust_configure = _nixpkgs_rust_configure diff --git a/toolchains/python/README.md b/toolchains/python/README.md index f9917e7ea..cc0053eff 100644 --- a/toolchains/python/README.md +++ b/toolchains/python/README.md @@ -2,11 +2,12 @@ -Rules for importing a Python toolchain from Nixpkgs. +Rules to import Python toolchains and packages from Nixpkgs. # Rules * [nixpkgs_python_configure](#nixpkgs_python_configure) +* [nixpkgs_python_repository](#nixpkgs_python_repository) # Reference documentation @@ -235,3 +236,142 @@ default is True + + +### nixpkgs_python_repository + +
+nixpkgs_python_repository(name, repository, repositories, nix_file, nix_file_deps, quiet)
+
+ +Define a collection of python packages based on a nix file. + +The only entry point is a [`nix_file`](#nixpkgs_python_repository-nix_file) +which should expose a `pkgs` and a `python` attributes. `python` is the +python interpreter, and `pkgs` a set of python packages that will be made +available to bazel. + +:warning: All the packages in `pkgs` are built by this rule. It is +therefore not a good idea to expose something as big as `pkgs.python3` as +provided by nixpkgs. + +This rule is instead intended to expose an ad-hoc set of packages for your +project, as can be built by poetry2nix, mach-nix, dream2nix or by manually +picking the python packages you need from nixpkgs. + +The format is generic to support the many ways to generate such packages +sets with nixpkgs. See our python [`tests`](/testing/toolchains/python) and +[examples](`/examples/toolchains/python`) to get started. + +This rule is intended to mimic as closely as possible the [rules_python +API](https://github.com/bazelbuild/rules_python#using-the-package-installation-rules). +`nixpkgs_python_repository` should be a drop-in replacement of `pip_parse`. +As such, it also provides a `requirement` function to perform the name +mangling. Using the `requirement` fucntion inherits the same advantages and +limitations as the one in rules_python. All the function does is create a +label of the form `@{nixpkgs_python_repository_name}//:{package_name}`. +While depending on such a label directly will work, the layout may change +in the future. To be on the safe side, define and import your own +`requirement` function if you need to play with these labels. + +:warning: packages names exposed by this rule are determined by the `pname` +attribute of the nix packages. These may vary slightly from names used by +rules_python. Should this be a problem, you can provide you own +`requirement` function. + + +#### Parameters + + ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + +
name + +required. + +

+ +The name for the created package set. + +

+
repository + +optional. +default is None + +

+ +See [`nixpkgs_package`](#nixpkgs_package-repository). + +

+
repositories + +optional. +default is {} + +

+ +See [`nixpkgs_package`](#nixpkgs_package-repositories). + +

+
nix_file + +optional. +default is None + +

+ +See [`nixpkgs_package`](#nixpkgs_package-nix_file). + +

+
nix_file_deps + +optional. +default is [] + +

+ +See [`nixpkgs_package`](#nixpkgs_package-nix_file_deps). + +

+
quiet + +optional. +default is False + +

+ +See [`nixpkgs_package`](#nixpkgs_package-quiet). + +

+
+ + diff --git a/toolchains/python/docs/BUILD.bazel b/toolchains/python/docs/BUILD.bazel index 98fae4f7a..8dff78adc 100644 --- a/toolchains/python/docs/BUILD.bazel +++ b/toolchains/python/docs/BUILD.bazel @@ -3,6 +3,9 @@ load("@rules_nixpkgs_docs//:stardoc.bzl", "generate_documentation") generate_documentation( name = "README.md", input = "//:python.bzl", - symbol_names = ["nixpkgs_python_configure"], + symbol_names = [ + "nixpkgs_python_configure", + "nixpkgs_python_repository", + ], deps = ["//:python"], ) diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl index bda6c4fb0..3f0181b5c 100644 --- a/toolchains/python/python.bzl +++ b/toolchains/python/python.bzl @@ -1,10 +1,11 @@ """ -Rules for importing a Python toolchain from Nixpkgs. +Rules to import Python toolchains and packages from Nixpkgs. # Rules * [nixpkgs_python_configure](#nixpkgs_python_configure) +* [nixpkgs_python_repository](#nixpkgs_python_repository) """ load( From 5a2cbf6f5702d8b20b1a1bc9e58d16b1c1906efd Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 23:09:01 +0100 Subject: [PATCH 08/24] Fixes for bzlmod --- testing/python/MODULE.bazel | 3 +++ toolchains/python/python.bzl | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/testing/python/MODULE.bazel b/testing/python/MODULE.bazel index 1e32df581..03a77532f 100644 --- a/testing/python/MODULE.bazel +++ b/testing/python/MODULE.bazel @@ -50,3 +50,6 @@ use_repo(non_module_deps, "nixpkgs_python_toolchain") use_repo(non_module_deps, "nixpkgs_python_configure_test") use_repo(non_module_deps, "nixpkgs_python_toolchain_python3") register_toolchains("@nixpkgs_python_toolchain//:all") + +use_repo(non_module_deps, "generated_poetry_packages_deps") +use_repo(non_module_deps, "poetry_packages") diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl index 3f0181b5c..6d319f933 100644 --- a/toolchains/python/python.bzl +++ b/toolchains/python/python.bzl @@ -235,7 +235,7 @@ python_package( repository_ctx.file("requirements.bzl", """ def requirement(package_name): return "@{}//:{{}}".format(package_name) -""".format(repository_ctx.name), +""".format(repository_ctx.attr.unmangled_name), ) # TODO: make it lazy in the packages themselves ? @@ -245,6 +245,7 @@ _nixpkgs_python_repository = repository_rule( _nixpkgs_python_repository_impl, attrs = { "json_deps": attr.label(), + "unmangled_name": attr.string(), }, ) @@ -301,7 +302,7 @@ def nixpkgs_python_repository( quiet: See [`nixpkgs_package`](#nixpkgs_package-quiet). """ - generated_deps_name = "_generated_{}_deps".format(name) + generated_deps_name = "generated_{}_deps".format(name) nixpkgs_package( name = generated_deps_name, @@ -315,6 +316,7 @@ def nixpkgs_python_repository( _nixpkgs_python_repository( name = name, + unmangled_name = name, json_deps = "@{}//:requirements.json".format(generated_deps_name), ) From 1956554572ff4e6f997cdd455f27288d6fee52e5 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Fri, 10 Mar 2023 23:32:16 +0100 Subject: [PATCH 09/24] Use an older numpy for macos --- testing/python/poetry.lock | 122 ++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/testing/python/poetry.lock b/testing/python/poetry.lock index 42f40d9e4..548e1bf04 100644 --- a/testing/python/poetry.lock +++ b/testing/python/poetry.lock @@ -79,77 +79,77 @@ pycparser = "*" [[package]] name = "numpy" -version = "1.24.2" -description = "Fundamental package for array computing in Python" +version = "1.23.5" +description = "NumPy is the fundamental package for array computing with Python." category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "numpy-1.24.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:eef70b4fc1e872ebddc38cddacc87c19a3709c0e3e5d20bf3954c147b1dd941d"}, - {file = "numpy-1.24.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8d2859428712785e8a8b7d2b3ef0a1d1565892367b32f915c4a4df44d0e64f5"}, - {file = "numpy-1.24.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6524630f71631be2dabe0c541e7675db82651eb998496bbe16bc4f77f0772253"}, - {file = "numpy-1.24.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a51725a815a6188c662fb66fb32077709a9ca38053f0274640293a14fdd22978"}, - {file = "numpy-1.24.2-cp310-cp310-win32.whl", hash = "sha256:2620e8592136e073bd12ee4536149380695fbe9ebeae845b81237f986479ffc9"}, - {file = "numpy-1.24.2-cp310-cp310-win_amd64.whl", hash = "sha256:97cf27e51fa078078c649a51d7ade3c92d9e709ba2bfb97493007103c741f1d0"}, - {file = "numpy-1.24.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7de8fdde0003f4294655aa5d5f0a89c26b9f22c0a58790c38fae1ed392d44a5a"}, - {file = "numpy-1.24.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4173bde9fa2a005c2c6e2ea8ac1618e2ed2c1c6ec8a7657237854d42094123a0"}, - {file = "numpy-1.24.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4cecaed30dc14123020f77b03601559fff3e6cd0c048f8b5289f4eeabb0eb281"}, - {file = "numpy-1.24.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a23f8440561a633204a67fb44617ce2a299beecf3295f0d13c495518908e910"}, - {file = "numpy-1.24.2-cp311-cp311-win32.whl", hash = "sha256:e428c4fbfa085f947b536706a2fc349245d7baa8334f0c5723c56a10595f9b95"}, - {file = "numpy-1.24.2-cp311-cp311-win_amd64.whl", hash = "sha256:557d42778a6869c2162deb40ad82612645e21d79e11c1dc62c6e82a2220ffb04"}, - {file = "numpy-1.24.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d0a2db9d20117bf523dde15858398e7c0858aadca7c0f088ac0d6edd360e9ad2"}, - {file = "numpy-1.24.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c72a6b2f4af1adfe193f7beb91ddf708ff867a3f977ef2ec53c0ffb8283ab9f5"}, - {file = "numpy-1.24.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c29e6bd0ec49a44d7690ecb623a8eac5ab8a923bce0bea6293953992edf3a76a"}, - {file = "numpy-1.24.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2eabd64ddb96a1239791da78fa5f4e1693ae2dadc82a76bc76a14cbb2b966e96"}, - {file = "numpy-1.24.2-cp38-cp38-win32.whl", hash = "sha256:e3ab5d32784e843fc0dd3ab6dcafc67ef806e6b6828dc6af2f689be0eb4d781d"}, - {file = "numpy-1.24.2-cp38-cp38-win_amd64.whl", hash = "sha256:76807b4063f0002c8532cfeac47a3068a69561e9c8715efdad3c642eb27c0756"}, - {file = "numpy-1.24.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4199e7cfc307a778f72d293372736223e39ec9ac096ff0a2e64853b866a8e18a"}, - {file = "numpy-1.24.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:adbdce121896fd3a17a77ab0b0b5eedf05a9834a18699db6829a64e1dfccca7f"}, - {file = "numpy-1.24.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:889b2cc88b837d86eda1b17008ebeb679d82875022200c6e8e4ce6cf549b7acb"}, - {file = "numpy-1.24.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f64bb98ac59b3ea3bf74b02f13836eb2e24e48e0ab0145bbda646295769bd780"}, - {file = "numpy-1.24.2-cp39-cp39-win32.whl", hash = "sha256:63e45511ee4d9d976637d11e6c9864eae50e12dc9598f531c035265991910468"}, - {file = "numpy-1.24.2-cp39-cp39-win_amd64.whl", hash = "sha256:a77d3e1163a7770164404607b7ba3967fb49b24782a6ef85d9b5f54126cc39e5"}, - {file = "numpy-1.24.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:92011118955724465fb6853def593cf397b4a1367495e0b59a7e69d40c4eb71d"}, - {file = "numpy-1.24.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f9006288bcf4895917d02583cf3411f98631275bc67cce355a7f39f8c14338fa"}, - {file = "numpy-1.24.2-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:150947adbdfeceec4e5926d956a06865c1c690f2fd902efede4ca6fe2e657c3f"}, - {file = "numpy-1.24.2.tar.gz", hash = "sha256:003a9f530e880cb2cd177cba1af7220b9aa42def9c4afc2a2fc3ee6be7eb2b22"}, + {file = "numpy-1.23.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9c88793f78fca17da0145455f0d7826bcb9f37da4764af27ac945488116efe63"}, + {file = "numpy-1.23.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e9f4c4e51567b616be64e05d517c79a8a22f3606499941d97bb76f2ca59f982d"}, + {file = "numpy-1.23.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7903ba8ab592b82014713c491f6c5d3a1cde5b4a3bf116404e08f5b52f6daf43"}, + {file = "numpy-1.23.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e05b1c973a9f858c74367553e236f287e749465f773328c8ef31abe18f691e1"}, + {file = "numpy-1.23.5-cp310-cp310-win32.whl", hash = "sha256:522e26bbf6377e4d76403826ed689c295b0b238f46c28a7251ab94716da0b280"}, + {file = "numpy-1.23.5-cp310-cp310-win_amd64.whl", hash = "sha256:dbee87b469018961d1ad79b1a5d50c0ae850000b639bcb1b694e9981083243b6"}, + {file = "numpy-1.23.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ce571367b6dfe60af04e04a1834ca2dc5f46004ac1cc756fb95319f64c095a96"}, + {file = "numpy-1.23.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:56e454c7833e94ec9769fa0f86e6ff8e42ee38ce0ce1fa4cbb747ea7e06d56aa"}, + {file = "numpy-1.23.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5039f55555e1eab31124a5768898c9e22c25a65c1e0037f4d7c495a45778c9f2"}, + {file = "numpy-1.23.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58f545efd1108e647604a1b5aa809591ccd2540f468a880bedb97247e72db387"}, + {file = "numpy-1.23.5-cp311-cp311-win32.whl", hash = "sha256:b2a9ab7c279c91974f756c84c365a669a887efa287365a8e2c418f8b3ba73fb0"}, + {file = "numpy-1.23.5-cp311-cp311-win_amd64.whl", hash = "sha256:0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d"}, + {file = "numpy-1.23.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f063b69b090c9d918f9df0a12116029e274daf0181df392839661c4c7ec9018a"}, + {file = "numpy-1.23.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0aaee12d8883552fadfc41e96b4c82ee7d794949e2a7c3b3a7201e968c7ecab9"}, + {file = "numpy-1.23.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:92c8c1e89a1f5028a4c6d9e3ccbe311b6ba53694811269b992c0b224269e2398"}, + {file = "numpy-1.23.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d208a0f8729f3fb790ed18a003f3a57895b989b40ea4dce4717e9cf4af62c6bb"}, + {file = "numpy-1.23.5-cp38-cp38-win32.whl", hash = "sha256:06005a2ef6014e9956c09ba07654f9837d9e26696a0470e42beedadb78c11b07"}, + {file = "numpy-1.23.5-cp38-cp38-win_amd64.whl", hash = "sha256:ca51fcfcc5f9354c45f400059e88bc09215fb71a48d3768fb80e357f3b457e1e"}, + {file = "numpy-1.23.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8969bfd28e85c81f3f94eb4a66bc2cf1dbdc5c18efc320af34bffc54d6b1e38f"}, + {file = "numpy-1.23.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a7ac231a08bb37f852849bbb387a20a57574a97cfc7b6cabb488a4fc8be176de"}, + {file = "numpy-1.23.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf837dc63ba5c06dc8797c398db1e223a466c7ece27a1f7b5232ba3466aafe3d"}, + {file = "numpy-1.23.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:33161613d2269025873025b33e879825ec7b1d831317e68f4f2f0f84ed14c719"}, + {file = "numpy-1.23.5-cp39-cp39-win32.whl", hash = "sha256:af1da88f6bc3d2338ebbf0e22fe487821ea4d8e89053e25fa59d1d79786e7481"}, + {file = "numpy-1.23.5-cp39-cp39-win_amd64.whl", hash = "sha256:09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df"}, + {file = "numpy-1.23.5-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:abdde9f795cf292fb9651ed48185503a2ff29be87770c3b8e2a14b0cd7aa16f8"}, + {file = "numpy-1.23.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f9a909a8bae284d46bbfdefbdd4a262ba19d3bc9921b1e76126b1d21c3c34135"}, + {file = "numpy-1.23.5-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d"}, + {file = "numpy-1.23.5.tar.gz", hash = "sha256:1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a"}, ] [[package]] name = "pandas" -version = "1.5.3" +version = "1.5.2" description = "Powerful data structures for data analysis, time series, and statistics" category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3749077d86e3a2f0ed51367f30bf5b82e131cc0f14260c4d3e499186fccc4406"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:972d8a45395f2a2d26733eb8d0f629b2f90bebe8e8eddbb8829b180c09639572"}, - {file = "pandas-1.5.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:50869a35cbb0f2e0cd5ec04b191e7b12ed688874bd05dd777c19b28cbea90996"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3ac844a0fe00bfaeb2c9b51ab1424e5c8744f89860b138434a363b1f620f354"}, - {file = "pandas-1.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7a0a56cef15fd1586726dace5616db75ebcfec9179a3a55e78f72c5639fa2a23"}, - {file = "pandas-1.5.3-cp310-cp310-win_amd64.whl", hash = "sha256:478ff646ca42b20376e4ed3fa2e8d7341e8a63105586efe54fa2508ee087f328"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6973549c01ca91ec96199e940495219c887ea815b2083722821f1d7abfa2b4dc"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c39a8da13cede5adcd3be1182883aea1c925476f4e84b2807a46e2775306305d"}, - {file = "pandas-1.5.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f76d097d12c82a535fda9dfe5e8dd4127952b45fea9b0276cb30cca5ea313fbc"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e474390e60ed609cec869b0da796ad94f420bb057d86784191eefc62b65819ae"}, - {file = "pandas-1.5.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f2b952406a1588ad4cad5b3f55f520e82e902388a6d5a4a91baa8d38d23c7f6"}, - {file = "pandas-1.5.3-cp311-cp311-win_amd64.whl", hash = "sha256:bc4c368f42b551bf72fac35c5128963a171b40dce866fb066540eeaf46faa003"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:14e45300521902689a81f3f41386dc86f19b8ba8dd5ac5a3c7010ef8d2932813"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9842b6f4b8479e41968eced654487258ed81df7d1c9b7b870ceea24ed9459b31"}, - {file = "pandas-1.5.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:26d9c71772c7afb9d5046e6e9cf42d83dd147b5cf5bcb9d97252077118543792"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5fbcb19d6fceb9e946b3e23258757c7b225ba450990d9ed63ccceeb8cae609f7"}, - {file = "pandas-1.5.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:565fa34a5434d38e9d250af3c12ff931abaf88050551d9fbcdfafca50d62babf"}, - {file = "pandas-1.5.3-cp38-cp38-win32.whl", hash = "sha256:87bd9c03da1ac870a6d2c8902a0e1fd4267ca00f13bc494c9e5a9020920e1d51"}, - {file = "pandas-1.5.3-cp38-cp38-win_amd64.whl", hash = "sha256:41179ce559943d83a9b4bbacb736b04c928b095b5f25dd2b7389eda08f46f373"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c74a62747864ed568f5a82a49a23a8d7fe171d0c69038b38cedf0976831296fa"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c4c00e0b0597c8e4f59e8d461f797e5d70b4d025880516a8261b2817c47759ee"}, - {file = "pandas-1.5.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a50d9a4336a9621cab7b8eb3fb11adb82de58f9b91d84c2cd526576b881a0c5a"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd05f7783b3274aa206a1af06f0ceed3f9b412cf665b7247eacd83be41cf7bf0"}, - {file = "pandas-1.5.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f69c4029613de47816b1bb30ff5ac778686688751a5e9c99ad8c7031f6508e5"}, - {file = "pandas-1.5.3-cp39-cp39-win32.whl", hash = "sha256:7cec0bee9f294e5de5bbfc14d0573f65526071029d036b753ee6507d2a21480a"}, - {file = "pandas-1.5.3-cp39-cp39-win_amd64.whl", hash = "sha256:dfd681c5dc216037e0b0a2c821f5ed99ba9f03ebcf119c7dac0e9a7b960b9ec9"}, - {file = "pandas-1.5.3.tar.gz", hash = "sha256:74a3fd7e5a7ec052f183273dc7b0acd3a863edf7520f5d3a1765c04ffdb3b0b1"}, + {file = "pandas-1.5.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e9dbacd22555c2d47f262ef96bb4e30880e5956169741400af8b306bbb24a273"}, + {file = "pandas-1.5.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e2b83abd292194f350bb04e188f9379d36b8dfac24dd445d5c87575f3beaf789"}, + {file = "pandas-1.5.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2552bffc808641c6eb471e55aa6899fa002ac94e4eebfa9ec058649122db5824"}, + {file = "pandas-1.5.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fc87eac0541a7d24648a001d553406f4256e744d92df1df8ebe41829a915028"}, + {file = "pandas-1.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d0d8fd58df5d17ddb8c72a5075d87cd80d71b542571b5f78178fb067fa4e9c72"}, + {file = "pandas-1.5.2-cp310-cp310-win_amd64.whl", hash = "sha256:4aed257c7484d01c9a194d9a94758b37d3d751849c05a0050c087a358c41ad1f"}, + {file = "pandas-1.5.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:375262829c8c700c3e7cbb336810b94367b9c4889818bbd910d0ecb4e45dc261"}, + {file = "pandas-1.5.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cc3cd122bea268998b79adebbb8343b735a5511ec14efb70a39e7acbc11ccbdc"}, + {file = "pandas-1.5.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b4f5a82afa4f1ff482ab8ded2ae8a453a2cdfde2001567b3ca24a4c5c5ca0db3"}, + {file = "pandas-1.5.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8092a368d3eb7116e270525329a3e5c15ae796ccdf7ccb17839a73b4f5084a39"}, + {file = "pandas-1.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6257b314fc14958f8122779e5a1557517b0f8e500cfb2bd53fa1f75a8ad0af2"}, + {file = "pandas-1.5.2-cp311-cp311-win_amd64.whl", hash = "sha256:82ae615826da838a8e5d4d630eb70c993ab8636f0eff13cb28aafc4291b632b5"}, + {file = "pandas-1.5.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:457d8c3d42314ff47cc2d6c54f8fc0d23954b47977b2caed09cd9635cb75388b"}, + {file = "pandas-1.5.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c009a92e81ce836212ce7aa98b219db7961a8b95999b97af566b8dc8c33e9519"}, + {file = "pandas-1.5.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:71f510b0efe1629bf2f7c0eadb1ff0b9cf611e87b73cd017e6b7d6adb40e2b3a"}, + {file = "pandas-1.5.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a40dd1e9f22e01e66ed534d6a965eb99546b41d4d52dbdb66565608fde48203f"}, + {file = "pandas-1.5.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ae7e989f12628f41e804847a8cc2943d362440132919a69429d4dea1f164da0"}, + {file = "pandas-1.5.2-cp38-cp38-win32.whl", hash = "sha256:530948945e7b6c95e6fa7aa4be2be25764af53fba93fe76d912e35d1c9ee46f5"}, + {file = "pandas-1.5.2-cp38-cp38-win_amd64.whl", hash = "sha256:73f219fdc1777cf3c45fde7f0708732ec6950dfc598afc50588d0d285fddaefc"}, + {file = "pandas-1.5.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:9608000a5a45f663be6af5c70c3cbe634fa19243e720eb380c0d378666bc7702"}, + {file = "pandas-1.5.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:315e19a3e5c2ab47a67467fc0362cb36c7c60a93b6457f675d7d9615edad2ebe"}, + {file = "pandas-1.5.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e18bc3764cbb5e118be139b3b611bc3fbc5d3be42a7e827d1096f46087b395eb"}, + {file = "pandas-1.5.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0183cb04a057cc38fde5244909fca9826d5d57c4a5b7390c0cc3fa7acd9fa883"}, + {file = "pandas-1.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:344021ed3e639e017b452aa8f5f6bf38a8806f5852e217a7594417fb9bbfa00e"}, + {file = "pandas-1.5.2-cp39-cp39-win32.whl", hash = "sha256:e7469271497960b6a781eaa930cba8af400dd59b62ec9ca2f4d31a19f2f91090"}, + {file = "pandas-1.5.2-cp39-cp39-win_amd64.whl", hash = "sha256:c218796d59d5abd8780170c937b812c9637e84c32f8271bbf9845970f8c1351f"}, + {file = "pandas-1.5.2.tar.gz", hash = "sha256:220b98d15cee0b2cd839a6358bd1f273d0356bf964c1a1aeb32d47db0215488b"}, ] [package.dependencies] @@ -193,14 +193,14 @@ six = ">=1.5" [[package]] name = "pytz" -version = "2022.7.1" +version = "2022.7" description = "World timezone definitions, modern and historical" category = "main" optional = false python-versions = "*" files = [ - {file = "pytz-2022.7.1-py2.py3-none-any.whl", hash = "sha256:78f4f37d8198e0627c5f1143240bb0206b8691d8d7ac6d78fee88b78733f8c4a"}, - {file = "pytz-2022.7.1.tar.gz", hash = "sha256:01a0681c4b9684a28304615eba55d1ab31ae00bf68ec157ec3708a8182dbbcd0"}, + {file = "pytz-2022.7-py2.py3-none-any.whl", hash = "sha256:93007def75ae22f7cd991c84e02d434876818661f8df9ad5df9e950ff4e52cfd"}, + {file = "pytz-2022.7.tar.gz", hash = "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a"}, ] [[package]] From 317359f1438179add84b739a5b135b12650ec7fa Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Sun, 12 Mar 2023 12:39:07 +0100 Subject: [PATCH 10/24] Fix poetry macos tests --- testing/python/poetry.nix | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/testing/python/poetry.nix b/testing/python/poetry.nix index feec68c55..640a278a3 100644 --- a/testing/python/poetry.nix +++ b/testing/python/poetry.nix @@ -6,16 +6,11 @@ let python = python3; pyproject = ./pyproject.toml; poetrylock = ./poetry.lock; - preferWheels = true; }; env = poetry2nix.mkPoetryEnv args; packages = poetry2nix.mkPoetryPackages args; - isWheelCffi = env.python.pkgs.cffi.src.isWheel; - isWheelPandas = env.python.pkgs.pandas.src.isWheel; -in - assert isWheelCffi; assert isWheelPandas; - { - inherit packages env; - python = packages.python; - pkgs = packages.poetryPackages; - } +in { + inherit packages env; + python = packages.python; + pkgs = packages.poetryPackages; +} From 4f23a38594d3c136a224bd80838e18da1d7b6a0e Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Sun, 12 Mar 2023 21:59:04 +0100 Subject: [PATCH 11/24] Add a test for python dependencies --- testing/python/tests/import_packages_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testing/python/tests/import_packages_test.py b/testing/python/tests/import_packages_test.py index f9b3838ba..2643bca91 100644 --- a/testing/python/tests/import_packages_test.py +++ b/testing/python/tests/import_packages_test.py @@ -3,3 +3,8 @@ import pandas print("pandas version = ", pandas.__version__) + +# Also test that numpy is available. +# nixpkgs_python_repository should provide the dependencies closure. +import numpy +print("numpy version = ", numpy.__version__) From 323341ab8f6e205b0b4148c65583698d7f3a4acc Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Sun, 12 Mar 2023 23:15:21 +0100 Subject: [PATCH 12/24] Add mach-nix example for python repository --- .bazelrc.common | 2 ++ README.md | 18 +++++++++---- testing/python/MODULE.bazel | 2 ++ testing/python/mach-nix.nix | 26 +++++++++++++++++++ testing/python/requirements.txt | 2 ++ testing/python/tests/BUILD.bazel | 15 +++++++++++ testing/python/tests/import_packages_test.py | 4 +++ testing/python/tests/nixpkgs_repositories.bzl | 9 +++++++ toolchains/python/README.md | 18 +++++++++---- toolchains/python/python.bzl | 18 +++++++++---- 10 files changed, 99 insertions(+), 15 deletions(-) create mode 100644 testing/python/mach-nix.nix create mode 100644 testing/python/requirements.txt diff --git a/.bazelrc.common b/.bazelrc.common index 83357d84e..640704b50 100644 --- a/.bazelrc.common +++ b/.bazelrc.common @@ -3,6 +3,8 @@ build --host_platform=@rules_nixpkgs_core//platforms:host build:bzlmod --enable_bzlmod build:bzlmod --registry=https://bcr.bazel.build +test --test_output=errors + # User Configuration # ------------------ try-import %workspace%/.bazelrc.local diff --git a/README.md b/README.md index 2d0c1c769..562fb9e47 100644 --- a/README.md +++ b/README.md @@ -1867,18 +1867,26 @@ sets with nixpkgs. See our python [`tests`](/testing/toolchains/python) and This rule is intended to mimic as closely as possible the [rules_python API](https://github.com/bazelbuild/rules_python#using-the-package-installation-rules). `nixpkgs_python_repository` should be a drop-in replacement of `pip_parse`. -As such, it also provides a `requirement` function to perform the name -mangling. Using the `requirement` fucntion inherits the same advantages and +As such, it also provides a `requirement` function. + +:warning: Using the `requirement` fucntion inherits the same advantages and limitations as the one in rules_python. All the function does is create a label of the form `@{nixpkgs_python_repository_name}//:{package_name}`. While depending on such a label directly will work, the layout may change in the future. To be on the safe side, define and import your own `requirement` function if you need to play with these labels. +:warning: Just as with rules_python, nothing is done to enforce consistency +between the version of python used to generate this repository and the one +configured in your toolchain, even if you use nixpkgs_python_toolchain. You +should ensure they both use the same python from the same nixpkgs version. +While nixpkgs_python_repository could also register the toolchain used to +generate the package set, this is not implemented yet. + :warning: packages names exposed by this rule are determined by the `pname` -attribute of the nix packages. These may vary slightly from names used by -rules_python. Should this be a problem, you can provide you own -`requirement` function. +attribute of the corresponding nix package. These may vary slightly from +names used by rules_python. Should this be a problem, you can provide you +own `requirement` function, for example one that lowercases its argument. #### Parameters diff --git a/testing/python/MODULE.bazel b/testing/python/MODULE.bazel index 03a77532f..4d12cc9dc 100644 --- a/testing/python/MODULE.bazel +++ b/testing/python/MODULE.bazel @@ -53,3 +53,5 @@ register_toolchains("@nixpkgs_python_toolchain//:all") use_repo(non_module_deps, "generated_poetry_packages_deps") use_repo(non_module_deps, "poetry_packages") +use_repo(non_module_deps, "generated_mach_nix_packages_deps") +use_repo(non_module_deps, "mach_nix_packages") diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix new file mode 100644 index 000000000..73bd37cd2 --- /dev/null +++ b/testing/python/mach-nix.nix @@ -0,0 +1,26 @@ +let + mach-nix = import (builtins.fetchGit { + url = "https://github.com/DavHau/mach-nix"; + ref = "f60b9833469adb18e57b4c9e8fc4804fce82e3da"; + }) { + # ** Extremely important! ** + # You want to use the same python version as your main nixpkgs. + # Bazel does not enforce this, and it will fail for binary packages. + pkgs = import {}; + }; + pythonWithPackages = mach-nix.mkPython { + requirements = builtins.readFile ./requirements.txt; + providers._default = "nixpkgs"; + }; + python = pythonWithPackages; #.python; + # Beloved hacks ! + # Extract the subset of packages that have been requested by mach-nix. + # By default, python.pkgs contains all the packages known by nixpkgs, + # plus the onse configured by mach-nix. + # This retrives the `extraLibs` attribute that mach-nix configured. + pkgs = (pythonWithPackages.override (old: { + ignoreCollisions = old.extraLibs; + })).ignoreCollisions; +in { + inherit python pkgs; +} diff --git a/testing/python/requirements.txt b/testing/python/requirements.txt new file mode 100644 index 000000000..2ec030ce5 --- /dev/null +++ b/testing/python/requirements.txt @@ -0,0 +1,2 @@ +cffi +pandas diff --git a/testing/python/tests/BUILD.bazel b/testing/python/tests/BUILD.bazel index 837ffa5c7..d515bf367 100644 --- a/testing/python/tests/BUILD.bazel +++ b/testing/python/tests/BUILD.bazel @@ -1,5 +1,6 @@ load("@nixpkgs_python_toolchain//:defs.bzl", "interpreter") load("@poetry_packages//:requirements.bzl", poetry_requirement = "requirement") +load("@mach_nix_packages//:requirements.bzl", mach_nix_requirement = "requirement") package(default_testonly = 1) # Test nixpkgs_python_configure() by running some Python code. @@ -35,3 +36,17 @@ py_test( size = "small", visibility = ["//visibility:public"], ) + +py_test( + name = "import-mach-nix-packages", + main = "import_packages_test.py", + srcs = ["import_packages_test.py"], + deps = [ + mach_nix_requirement("cffi"), + mach_nix_requirement("pandas"), + ], + srcs_version = "PY3", + python_version = "PY3", + size = "small", + visibility = ["//visibility:public"], +) diff --git a/testing/python/tests/import_packages_test.py b/testing/python/tests/import_packages_test.py index 2643bca91..64f4bb6d9 100644 --- a/testing/python/tests/import_packages_test.py +++ b/testing/python/tests/import_packages_test.py @@ -1,3 +1,7 @@ +import sys, pprint +print("python path = ", end="") +pprint.pprint(sys.path) + import cffi print("cffi version = ", cffi.__version__) diff --git a/testing/python/tests/nixpkgs_repositories.bzl b/testing/python/tests/nixpkgs_repositories.bzl index 4177e320b..ef933e271 100644 --- a/testing/python/tests/nixpkgs_repositories.bzl +++ b/testing/python/tests/nixpkgs_repositories.bzl @@ -50,3 +50,12 @@ def nixpkgs_repositories(*, bzlmod): "//:poetry.lock", ], ) + + nixpkgs_python_repository( + name = "mach_nix_packages", + repository = "@nixpkgs", + nix_file = "//:mach-nix.nix", + nix_file_deps = [ + "//:requirements.txt", + ], + ) diff --git a/toolchains/python/README.md b/toolchains/python/README.md index cc0053eff..9fd26c312 100644 --- a/toolchains/python/README.md +++ b/toolchains/python/README.md @@ -266,18 +266,26 @@ sets with nixpkgs. See our python [`tests`](/testing/toolchains/python) and This rule is intended to mimic as closely as possible the [rules_python API](https://github.com/bazelbuild/rules_python#using-the-package-installation-rules). `nixpkgs_python_repository` should be a drop-in replacement of `pip_parse`. -As such, it also provides a `requirement` function to perform the name -mangling. Using the `requirement` fucntion inherits the same advantages and +As such, it also provides a `requirement` function. + +:warning: Using the `requirement` fucntion inherits the same advantages and limitations as the one in rules_python. All the function does is create a label of the form `@{nixpkgs_python_repository_name}//:{package_name}`. While depending on such a label directly will work, the layout may change in the future. To be on the safe side, define and import your own `requirement` function if you need to play with these labels. +:warning: Just as with rules_python, nothing is done to enforce consistency +between the version of python used to generate this repository and the one +configured in your toolchain, even if you use nixpkgs_python_toolchain. You +should ensure they both use the same python from the same nixpkgs version. +While nixpkgs_python_repository could also register the toolchain used to +generate the package set, this is not implemented yet. + :warning: packages names exposed by this rule are determined by the `pname` -attribute of the nix packages. These may vary slightly from names used by -rules_python. Should this be a problem, you can provide you own -`requirement` function. +attribute of the corresponding nix package. These may vary slightly from +names used by rules_python. Should this be a problem, you can provide you +own `requirement` function, for example one that lowercases its argument. #### Parameters diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl index 6d319f933..235b2058e 100644 --- a/toolchains/python/python.bzl +++ b/toolchains/python/python.bzl @@ -280,18 +280,26 @@ def nixpkgs_python_repository( This rule is intended to mimic as closely as possible the [rules_python API](https://github.com/bazelbuild/rules_python#using-the-package-installation-rules). `nixpkgs_python_repository` should be a drop-in replacement of `pip_parse`. - As such, it also provides a `requirement` function to perform the name - mangling. Using the `requirement` fucntion inherits the same advantages and + As such, it also provides a `requirement` function. + + :warning: Using the `requirement` fucntion inherits the same advantages and limitations as the one in rules_python. All the function does is create a label of the form `@{nixpkgs_python_repository_name}//:{package_name}`. While depending on such a label directly will work, the layout may change in the future. To be on the safe side, define and import your own `requirement` function if you need to play with these labels. + :warning: Just as with rules_python, nothing is done to enforce consistency + between the version of python used to generate this repository and the one + configured in your toolchain, even if you use nixpkgs_python_toolchain. You + should ensure they both use the same python from the same nixpkgs version. + While nixpkgs_python_repository could also register the toolchain used to + generate the package set, this is not implemented yet. + :warning: packages names exposed by this rule are determined by the `pname` - attribute of the nix packages. These may vary slightly from names used by - rules_python. Should this be a problem, you can provide you own - `requirement` function. + attribute of the corresponding nix package. These may vary slightly from + names used by rules_python. Should this be a problem, you can provide you + own `requirement` function, for example one that lowercases its argument. Args: name: The name for the created package set. From 1fbe84da9f67ebfe35c0346c50b7230df2397b53 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Sun, 12 Mar 2023 23:34:41 +0100 Subject: [PATCH 13/24] Fix mach-nix repository fetching and improve usage --- testing/python/mach-nix.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix index 73bd37cd2..25f8d11c2 100644 --- a/testing/python/mach-nix.nix +++ b/testing/python/mach-nix.nix @@ -1,7 +1,9 @@ let mach-nix = import (builtins.fetchGit { url = "https://github.com/DavHau/mach-nix"; - ref = "f60b9833469adb18e57b4c9e8fc4804fce82e3da"; + ref = "master"; + rev = "f60b9833469adb18e57b4c9e8fc4804fce82e3da"; + narHash = "sha256-LGFLMTf9gEPYzLuny3idKQOGiZFVhmjR2VGvio4chMI="; }) { # ** Extremely important! ** # You want to use the same python version as your main nixpkgs. @@ -12,7 +14,7 @@ let requirements = builtins.readFile ./requirements.txt; providers._default = "nixpkgs"; }; - python = pythonWithPackages; #.python; + python = pythonWithPackages.python; # Beloved hacks ! # Extract the subset of packages that have been requested by mach-nix. # By default, python.pkgs contains all the packages known by nixpkgs, From cd837fbc276027cbef38e1cee55a579fbbbb8f47 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Sun, 12 Mar 2023 23:48:07 +0100 Subject: [PATCH 14/24] Work around some builtins.fetchGit bug --- testing/python/mach-nix.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix index 25f8d11c2..ba5ace99c 100644 --- a/testing/python/mach-nix.nix +++ b/testing/python/mach-nix.nix @@ -1,14 +1,15 @@ let - mach-nix = import (builtins.fetchGit { - url = "https://github.com/DavHau/mach-nix"; - ref = "master"; + nixpkgs = import {}; + mach-nix = import (nixpkgs.fetchFromGitHub { + owner = "DavHau"; + repo = "mach-nix"; rev = "f60b9833469adb18e57b4c9e8fc4804fce82e3da"; - narHash = "sha256-LGFLMTf9gEPYzLuny3idKQOGiZFVhmjR2VGvio4chMI="; + hash = "sha256-LGFLMTf9gEPYzLuny3idKQOGiZFVhmjR2VGvio4chMI="; }) { # ** Extremely important! ** # You want to use the same python version as your main nixpkgs. # Bazel does not enforce this, and it will fail for binary packages. - pkgs = import {}; + pkgs = nixpkgs; }; pythonWithPackages = mach-nix.mkPython { requirements = builtins.readFile ./requirements.txt; From 08d3678f04b7e7c669d960c772ce160f67267b09 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 00:34:48 +0100 Subject: [PATCH 15/24] Try to make mach-nix work on ci --- testing/python/.bazelrc | 2 ++ testing/python/mach-nix.nix | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/testing/python/.bazelrc b/testing/python/.bazelrc index ae8f32bd8..1b3164f1a 100644 --- a/testing/python/.bazelrc +++ b/testing/python/.bazelrc @@ -1,3 +1,5 @@ import %workspace%/../../.bazelrc.common import %workspace%/../../.bazelrc.cc import %workspace%/../../.bazelrc.java + +common --repo_env=TMDIR=/tmp diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix index ba5ace99c..fd9f876e8 100644 --- a/testing/python/mach-nix.nix +++ b/testing/python/mach-nix.nix @@ -3,17 +3,13 @@ let mach-nix = import (nixpkgs.fetchFromGitHub { owner = "DavHau"; repo = "mach-nix"; - rev = "f60b9833469adb18e57b4c9e8fc4804fce82e3da"; - hash = "sha256-LGFLMTf9gEPYzLuny3idKQOGiZFVhmjR2VGvio4chMI="; - }) { - # ** Extremely important! ** - # You want to use the same python version as your main nixpkgs. - # Bazel does not enforce this, and it will fail for binary packages. - pkgs = nixpkgs; - }; + rev = "68a85753555ed67ff53f0d0320e5ac3c725c7400"; + hash = "sha256-YIcQtXNQSofFSRDO8Y/uCtXAMguc8HqpY83TstgkH+k="; + }) { }; pythonWithPackages = mach-nix.mkPython { requirements = builtins.readFile ./requirements.txt; - providers._default = "nixpkgs"; + # Keep this aligned with whatever nixpkgs.python is in flake.nix. + python = "python310"; }; python = pythonWithPackages.python; # Beloved hacks ! From f659bf68cb3d11fc72a63eaf0459b9b5bb4dfbec Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 16:01:39 +0100 Subject: [PATCH 16/24] Use a simpler python package for import tests --- testing/python/poetry.lock | 309 +++++++++---------- testing/python/pyproject.toml | 7 +- testing/python/requirements.txt | 3 +- testing/python/tests/BUILD.bazel | 6 +- testing/python/tests/import_packages_test.py | 11 +- 5 files changed, 154 insertions(+), 182 deletions(-) diff --git a/testing/python/poetry.lock b/testing/python/poetry.lock index 548e1bf04..66a6c4d77 100644 --- a/testing/python/poetry.lock +++ b/testing/python/poetry.lock @@ -1,221 +1,200 @@ # This file is automatically @generated by Poetry and should not be changed by hand. [[package]] -name = "cffi" -version = "1.15.1" -description = "Foreign Function Interface for Python calling C code." +name = "click" +version = "8.1.3" +description = "Composable command line interface toolkit" category = "main" optional = false -python-versions = "*" +python-versions = ">=3.7" files = [ - {file = "cffi-1.15.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a66d3508133af6e8548451b25058d5812812ec3798c886bf38ed24a98216fab2"}, - {file = "cffi-1.15.1-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:470c103ae716238bbe698d67ad020e1db9d9dba34fa5a899b5e21577e6d52ed2"}, - {file = "cffi-1.15.1-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:9ad5db27f9cabae298d151c85cf2bad1d359a1b9c686a275df03385758e2f914"}, - {file = "cffi-1.15.1-cp27-cp27m-win32.whl", hash = "sha256:b3bbeb01c2b273cca1e1e0c5df57f12dce9a4dd331b4fa1635b8bec26350bde3"}, - {file = "cffi-1.15.1-cp27-cp27m-win_amd64.whl", hash = "sha256:e00b098126fd45523dd056d2efba6c5a63b71ffe9f2bbe1a4fe1716e1d0c331e"}, - {file = "cffi-1.15.1-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:d61f4695e6c866a23a21acab0509af1cdfd2c013cf256bbf5b6b5e2695827162"}, - {file = "cffi-1.15.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:ed9cb427ba5504c1dc15ede7d516b84757c3e3d7868ccc85121d9310d27eed0b"}, - {file = "cffi-1.15.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:39d39875251ca8f612b6f33e6b1195af86d1b3e60086068be9cc053aa4376e21"}, - {file = "cffi-1.15.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:285d29981935eb726a4399badae8f0ffdff4f5050eaa6d0cfc3f64b857b77185"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3eb6971dcff08619f8d91607cfc726518b6fa2a9eba42856be181c6d0d9515fd"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:21157295583fe8943475029ed5abdcf71eb3911894724e360acff1d61c1d54bc"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5635bd9cb9731e6d4a1132a498dd34f764034a8ce60cef4f5319c0541159392f"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2012c72d854c2d03e45d06ae57f40d78e5770d252f195b93f581acf3ba44496e"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd86c085fae2efd48ac91dd7ccffcfc0571387fe1193d33b6394db7ef31fe2a4"}, - {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:fa6693661a4c91757f4412306191b6dc88c1703f780c8234035eac011922bc01"}, - {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:59c0b02d0a6c384d453fece7566d1c7e6b7bae4fc5874ef2ef46d56776d61c9e"}, - {file = "cffi-1.15.1-cp310-cp310-win32.whl", hash = "sha256:cba9d6b9a7d64d4bd46167096fc9d2f835e25d7e4c121fb2ddfc6528fb0413b2"}, - {file = "cffi-1.15.1-cp310-cp310-win_amd64.whl", hash = "sha256:ce4bcc037df4fc5e3d184794f27bdaab018943698f4ca31630bc7f84a7b69c6d"}, - {file = "cffi-1.15.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3d08afd128ddaa624a48cf2b859afef385b720bb4b43df214f85616922e6a5ac"}, - {file = "cffi-1.15.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3799aecf2e17cf585d977b780ce79ff0dc9b78d799fc694221ce814c2c19db83"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a591fe9e525846e4d154205572a029f653ada1a78b93697f3b5a8f1f2bc055b9"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3548db281cd7d2561c9ad9984681c95f7b0e38881201e157833a2342c30d5e8c"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:91fc98adde3d7881af9b59ed0294046f3806221863722ba7d8d120c575314325"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94411f22c3985acaec6f83c6df553f2dbe17b698cc7f8ae751ff2237d96b9e3c"}, - {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:03425bdae262c76aad70202debd780501fabeaca237cdfddc008987c0e0f59ef"}, - {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cc4d65aeeaa04136a12677d3dd0b1c0c94dc43abac5860ab33cceb42b801c1e8"}, - {file = "cffi-1.15.1-cp311-cp311-win32.whl", hash = "sha256:a0f100c8912c114ff53e1202d0078b425bee3649ae34d7b070e9697f93c5d52d"}, - {file = "cffi-1.15.1-cp311-cp311-win_amd64.whl", hash = "sha256:04ed324bda3cda42b9b695d51bb7d54b680b9719cfab04227cdd1e04e5de3104"}, - {file = "cffi-1.15.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50a74364d85fd319352182ef59c5c790484a336f6db772c1a9231f1c3ed0cbd7"}, - {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e263d77ee3dd201c3a142934a086a4450861778baaeeb45db4591ef65550b0a6"}, - {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cec7d9412a9102bdc577382c3929b337320c4c4c4849f2c5cdd14d7368c5562d"}, - {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4289fc34b2f5316fbb762d75362931e351941fa95fa18789191b33fc4cf9504a"}, - {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:173379135477dc8cac4bc58f45db08ab45d228b3363adb7af79436135d028405"}, - {file = "cffi-1.15.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:6975a3fac6bc83c4a65c9f9fcab9e47019a11d3d2cf7f3c0d03431bf145a941e"}, - {file = "cffi-1.15.1-cp36-cp36m-win32.whl", hash = "sha256:2470043b93ff09bf8fb1d46d1cb756ce6132c54826661a32d4e4d132e1977adf"}, - {file = "cffi-1.15.1-cp36-cp36m-win_amd64.whl", hash = "sha256:30d78fbc8ebf9c92c9b7823ee18eb92f2e6ef79b45ac84db507f52fbe3ec4497"}, - {file = "cffi-1.15.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:198caafb44239b60e252492445da556afafc7d1e3ab7a1fb3f0584ef6d742375"}, - {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5ef34d190326c3b1f822a5b7a45f6c4535e2f47ed06fec77d3d799c450b2651e"}, - {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8102eaf27e1e448db915d08afa8b41d6c7ca7a04b7d73af6514df10a3e74bd82"}, - {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5df2768244d19ab7f60546d0c7c63ce1581f7af8b5de3eb3004b9b6fc8a9f84b"}, - {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8c4917bd7ad33e8eb21e9a5bbba979b49d9a97acb3a803092cbc1133e20343c"}, - {file = "cffi-1.15.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e2642fe3142e4cc4af0799748233ad6da94c62a8bec3a6648bf8ee68b1c7426"}, - {file = "cffi-1.15.1-cp37-cp37m-win32.whl", hash = "sha256:e229a521186c75c8ad9490854fd8bbdd9a0c9aa3a524326b55be83b54d4e0ad9"}, - {file = "cffi-1.15.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a0b71b1b8fbf2b96e41c4d990244165e2c9be83d54962a9a1d118fd8657d2045"}, - {file = "cffi-1.15.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:320dab6e7cb2eacdf0e658569d2575c4dad258c0fcc794f46215e1e39f90f2c3"}, - {file = "cffi-1.15.1-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e74c6b51a9ed6589199c787bf5f9875612ca4a8a0785fb2d4a84429badaf22a"}, - {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5c84c68147988265e60416b57fc83425a78058853509c1b0629c180094904a5"}, - {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3b926aa83d1edb5aa5b427b4053dc420ec295a08e40911296b9eb1b6170f6cca"}, - {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:87c450779d0914f2861b8526e035c5e6da0a3199d8f1add1a665e1cbc6fc6d02"}, - {file = "cffi-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4f2c9f67e9821cad2e5f480bc8d83b8742896f1242dba247911072d4fa94c192"}, - {file = "cffi-1.15.1-cp38-cp38-win32.whl", hash = "sha256:8b7ee99e510d7b66cdb6c593f21c043c248537a32e0bedf02e01e9553a172314"}, - {file = "cffi-1.15.1-cp38-cp38-win_amd64.whl", hash = "sha256:00a9ed42e88df81ffae7a8ab6d9356b371399b91dbdf0c3cb1e84c03a13aceb5"}, - {file = "cffi-1.15.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:54a2db7b78338edd780e7ef7f9f6c442500fb0d41a5a4ea24fff1c929d5af585"}, - {file = "cffi-1.15.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:fcd131dd944808b5bdb38e6f5b53013c5aa4f334c5cad0c72742f6eba4b73db0"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7473e861101c9e72452f9bf8acb984947aa1661a7704553a9f6e4baa5ba64415"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c9a799e985904922a4d207a94eae35c78ebae90e128f0c4e521ce339396be9d"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3bcde07039e586f91b45c88f8583ea7cf7a0770df3a1649627bf598332cb6984"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33ab79603146aace82c2427da5ca6e58f2b3f2fb5da893ceac0c42218a40be35"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d598b938678ebf3c67377cdd45e09d431369c3b1a5b331058c338e201f12b27"}, - {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:db0fbb9c62743ce59a9ff687eb5f4afbe77e5e8403d6697f7446e5f609976f76"}, - {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:98d85c6a2bef81588d9227dde12db8a7f47f639f4a17c9ae08e773aa9c697bf3"}, - {file = "cffi-1.15.1-cp39-cp39-win32.whl", hash = "sha256:40f4774f5a9d4f5e344f31a32b5096977b5d48560c5592e2f3d2c4374bd543ee"}, - {file = "cffi-1.15.1-cp39-cp39-win_amd64.whl", hash = "sha256:70df4e3b545a17496c9b3f41f5115e69a4f2e77e94e1d2a8e1070bc0c38c8a3c"}, - {file = "cffi-1.15.1.tar.gz", hash = "sha256:d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9"}, + {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, + {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, ] [package.dependencies] -pycparser = "*" +colorama = {version = "*", markers = "platform_system == \"Windows\""} [[package]] -name = "numpy" -version = "1.23.5" -description = "NumPy is the fundamental package for array computing with Python." +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." category = "main" optional = false -python-versions = ">=3.8" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ - {file = "numpy-1.23.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9c88793f78fca17da0145455f0d7826bcb9f37da4764af27ac945488116efe63"}, - {file = "numpy-1.23.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e9f4c4e51567b616be64e05d517c79a8a22f3606499941d97bb76f2ca59f982d"}, - {file = "numpy-1.23.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7903ba8ab592b82014713c491f6c5d3a1cde5b4a3bf116404e08f5b52f6daf43"}, - {file = "numpy-1.23.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e05b1c973a9f858c74367553e236f287e749465f773328c8ef31abe18f691e1"}, - {file = "numpy-1.23.5-cp310-cp310-win32.whl", hash = "sha256:522e26bbf6377e4d76403826ed689c295b0b238f46c28a7251ab94716da0b280"}, - {file = "numpy-1.23.5-cp310-cp310-win_amd64.whl", hash = "sha256:dbee87b469018961d1ad79b1a5d50c0ae850000b639bcb1b694e9981083243b6"}, - {file = "numpy-1.23.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ce571367b6dfe60af04e04a1834ca2dc5f46004ac1cc756fb95319f64c095a96"}, - {file = "numpy-1.23.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:56e454c7833e94ec9769fa0f86e6ff8e42ee38ce0ce1fa4cbb747ea7e06d56aa"}, - {file = "numpy-1.23.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5039f55555e1eab31124a5768898c9e22c25a65c1e0037f4d7c495a45778c9f2"}, - {file = "numpy-1.23.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58f545efd1108e647604a1b5aa809591ccd2540f468a880bedb97247e72db387"}, - {file = "numpy-1.23.5-cp311-cp311-win32.whl", hash = "sha256:b2a9ab7c279c91974f756c84c365a669a887efa287365a8e2c418f8b3ba73fb0"}, - {file = "numpy-1.23.5-cp311-cp311-win_amd64.whl", hash = "sha256:0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d"}, - {file = "numpy-1.23.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f063b69b090c9d918f9df0a12116029e274daf0181df392839661c4c7ec9018a"}, - {file = "numpy-1.23.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0aaee12d8883552fadfc41e96b4c82ee7d794949e2a7c3b3a7201e968c7ecab9"}, - {file = "numpy-1.23.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:92c8c1e89a1f5028a4c6d9e3ccbe311b6ba53694811269b992c0b224269e2398"}, - {file = "numpy-1.23.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d208a0f8729f3fb790ed18a003f3a57895b989b40ea4dce4717e9cf4af62c6bb"}, - {file = "numpy-1.23.5-cp38-cp38-win32.whl", hash = "sha256:06005a2ef6014e9956c09ba07654f9837d9e26696a0470e42beedadb78c11b07"}, - {file = "numpy-1.23.5-cp38-cp38-win_amd64.whl", hash = "sha256:ca51fcfcc5f9354c45f400059e88bc09215fb71a48d3768fb80e357f3b457e1e"}, - {file = "numpy-1.23.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8969bfd28e85c81f3f94eb4a66bc2cf1dbdc5c18efc320af34bffc54d6b1e38f"}, - {file = "numpy-1.23.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a7ac231a08bb37f852849bbb387a20a57574a97cfc7b6cabb488a4fc8be176de"}, - {file = "numpy-1.23.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf837dc63ba5c06dc8797c398db1e223a466c7ece27a1f7b5232ba3466aafe3d"}, - {file = "numpy-1.23.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:33161613d2269025873025b33e879825ec7b1d831317e68f4f2f0f84ed14c719"}, - {file = "numpy-1.23.5-cp39-cp39-win32.whl", hash = "sha256:af1da88f6bc3d2338ebbf0e22fe487821ea4d8e89053e25fa59d1d79786e7481"}, - {file = "numpy-1.23.5-cp39-cp39-win_amd64.whl", hash = "sha256:09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df"}, - {file = "numpy-1.23.5-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:abdde9f795cf292fb9651ed48185503a2ff29be87770c3b8e2a14b0cd7aa16f8"}, - {file = "numpy-1.23.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f9a909a8bae284d46bbfdefbdd4a262ba19d3bc9921b1e76126b1d21c3c34135"}, - {file = "numpy-1.23.5-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d"}, - {file = "numpy-1.23.5.tar.gz", hash = "sha256:1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a"}, + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] [[package]] -name = "pandas" -version = "1.5.2" -description = "Powerful data structures for data analysis, time series, and statistics" +name = "flask" +version = "2.2.3" +description = "A simple framework for building complex web applications." category = "main" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "pandas-1.5.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e9dbacd22555c2d47f262ef96bb4e30880e5956169741400af8b306bbb24a273"}, - {file = "pandas-1.5.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e2b83abd292194f350bb04e188f9379d36b8dfac24dd445d5c87575f3beaf789"}, - {file = "pandas-1.5.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2552bffc808641c6eb471e55aa6899fa002ac94e4eebfa9ec058649122db5824"}, - {file = "pandas-1.5.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fc87eac0541a7d24648a001d553406f4256e744d92df1df8ebe41829a915028"}, - {file = "pandas-1.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d0d8fd58df5d17ddb8c72a5075d87cd80d71b542571b5f78178fb067fa4e9c72"}, - {file = "pandas-1.5.2-cp310-cp310-win_amd64.whl", hash = "sha256:4aed257c7484d01c9a194d9a94758b37d3d751849c05a0050c087a358c41ad1f"}, - {file = "pandas-1.5.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:375262829c8c700c3e7cbb336810b94367b9c4889818bbd910d0ecb4e45dc261"}, - {file = "pandas-1.5.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cc3cd122bea268998b79adebbb8343b735a5511ec14efb70a39e7acbc11ccbdc"}, - {file = "pandas-1.5.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b4f5a82afa4f1ff482ab8ded2ae8a453a2cdfde2001567b3ca24a4c5c5ca0db3"}, - {file = "pandas-1.5.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8092a368d3eb7116e270525329a3e5c15ae796ccdf7ccb17839a73b4f5084a39"}, - {file = "pandas-1.5.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6257b314fc14958f8122779e5a1557517b0f8e500cfb2bd53fa1f75a8ad0af2"}, - {file = "pandas-1.5.2-cp311-cp311-win_amd64.whl", hash = "sha256:82ae615826da838a8e5d4d630eb70c993ab8636f0eff13cb28aafc4291b632b5"}, - {file = "pandas-1.5.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:457d8c3d42314ff47cc2d6c54f8fc0d23954b47977b2caed09cd9635cb75388b"}, - {file = "pandas-1.5.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c009a92e81ce836212ce7aa98b219db7961a8b95999b97af566b8dc8c33e9519"}, - {file = "pandas-1.5.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:71f510b0efe1629bf2f7c0eadb1ff0b9cf611e87b73cd017e6b7d6adb40e2b3a"}, - {file = "pandas-1.5.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a40dd1e9f22e01e66ed534d6a965eb99546b41d4d52dbdb66565608fde48203f"}, - {file = "pandas-1.5.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ae7e989f12628f41e804847a8cc2943d362440132919a69429d4dea1f164da0"}, - {file = "pandas-1.5.2-cp38-cp38-win32.whl", hash = "sha256:530948945e7b6c95e6fa7aa4be2be25764af53fba93fe76d912e35d1c9ee46f5"}, - {file = "pandas-1.5.2-cp38-cp38-win_amd64.whl", hash = "sha256:73f219fdc1777cf3c45fde7f0708732ec6950dfc598afc50588d0d285fddaefc"}, - {file = "pandas-1.5.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:9608000a5a45f663be6af5c70c3cbe634fa19243e720eb380c0d378666bc7702"}, - {file = "pandas-1.5.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:315e19a3e5c2ab47a67467fc0362cb36c7c60a93b6457f675d7d9615edad2ebe"}, - {file = "pandas-1.5.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e18bc3764cbb5e118be139b3b611bc3fbc5d3be42a7e827d1096f46087b395eb"}, - {file = "pandas-1.5.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0183cb04a057cc38fde5244909fca9826d5d57c4a5b7390c0cc3fa7acd9fa883"}, - {file = "pandas-1.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:344021ed3e639e017b452aa8f5f6bf38a8806f5852e217a7594417fb9bbfa00e"}, - {file = "pandas-1.5.2-cp39-cp39-win32.whl", hash = "sha256:e7469271497960b6a781eaa930cba8af400dd59b62ec9ca2f4d31a19f2f91090"}, - {file = "pandas-1.5.2-cp39-cp39-win_amd64.whl", hash = "sha256:c218796d59d5abd8780170c937b812c9637e84c32f8271bbf9845970f8c1351f"}, - {file = "pandas-1.5.2.tar.gz", hash = "sha256:220b98d15cee0b2cd839a6358bd1f273d0356bf964c1a1aeb32d47db0215488b"}, + {file = "Flask-2.2.3-py3-none-any.whl", hash = "sha256:c0bec9477df1cb867e5a67c9e1ab758de9cb4a3e52dd70681f59fa40a62b3f2d"}, + {file = "Flask-2.2.3.tar.gz", hash = "sha256:7eb373984bf1c770023fce9db164ed0c3353cd0b53f130f4693da0ca756a2e6d"}, ] [package.dependencies] -numpy = [ - {version = ">=1.20.3", markers = "python_version < \"3.10\""}, - {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, - {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, +click = ">=8.0" +importlib-metadata = {version = ">=3.6.0", markers = "python_version < \"3.10\""} +itsdangerous = ">=2.0" +Jinja2 = ">=3.0" +Werkzeug = ">=2.2.2" + +[package.extras] +async = ["asgiref (>=3.2)"] +dotenv = ["python-dotenv"] + +[[package]] +name = "importlib-metadata" +version = "6.0.0" +description = "Read metadata from Python packages" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "importlib_metadata-6.0.0-py3-none-any.whl", hash = "sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad"}, + {file = "importlib_metadata-6.0.0.tar.gz", hash = "sha256:e354bedeb60efa6affdcc8ae121b73544a7aa74156d047311948f6d711cd378d"}, ] -python-dateutil = ">=2.8.1" -pytz = ">=2020.1" + +[package.dependencies] +zipp = ">=0.5" [package.extras] -test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"] [[package]] -name = "pycparser" -version = "2.21" -description = "C parser in Python" +name = "itsdangerous" +version = "2.1.2" +description = "Safely pass data to untrusted environments and back." category = "main" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +python-versions = ">=3.7" files = [ - {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, - {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, + {file = "itsdangerous-2.1.2-py3-none-any.whl", hash = "sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44"}, + {file = "itsdangerous-2.1.2.tar.gz", hash = "sha256:5dbbc68b317e5e42f327f9021763545dc3fc3bfe22e6deb96aaf1fc38874156a"}, ] [[package]] -name = "python-dateutil" -version = "2.8.2" -description = "Extensions to the standard Python datetime module" +name = "jinja2" +version = "3.1.2" +description = "A very fast and expressive template engine." category = "main" optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +python-versions = ">=3.7" files = [ - {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, - {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, + {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, + {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, ] [package.dependencies] -six = ">=1.5" +MarkupSafe = ">=2.0" + +[package.extras] +i18n = ["Babel (>=2.7)"] [[package]] -name = "pytz" -version = "2022.7" -description = "World timezone definitions, modern and historical" +name = "markupsafe" +version = "2.1.2" +description = "Safely add untrusted strings to HTML/XML markup." category = "main" optional = false -python-versions = "*" +python-versions = ">=3.7" files = [ - {file = "pytz-2022.7-py2.py3-none-any.whl", hash = "sha256:93007def75ae22f7cd991c84e02d434876818661f8df9ad5df9e950ff4e52cfd"}, - {file = "pytz-2022.7.tar.gz", hash = "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:665a36ae6f8f20a4676b53224e33d456a6f5a72657d9c83c2aa00765072f31f7"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:340bea174e9761308703ae988e982005aedf427de816d1afe98147668cc03036"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22152d00bf4a9c7c83960521fc558f55a1adbc0631fbb00a9471e097b19d72e1"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28057e985dace2f478e042eaa15606c7efccb700797660629da387eb289b9323"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca244fa73f50a800cf8c3ebf7fd93149ec37f5cb9596aa8873ae2c1d23498601"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d9d971ec1e79906046aa3ca266de79eac42f1dbf3612a05dc9368125952bd1a1"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:7e007132af78ea9df29495dbf7b5824cb71648d7133cf7848a2a5dd00d36f9ff"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7313ce6a199651c4ed9d7e4cfb4aa56fe923b1adf9af3b420ee14e6d9a73df65"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-win32.whl", hash = "sha256:c4a549890a45f57f1ebf99c067a4ad0cb423a05544accaf2b065246827ed9603"}, + {file = "MarkupSafe-2.1.2-cp310-cp310-win_amd64.whl", hash = "sha256:835fb5e38fd89328e9c81067fd642b3593c33e1e17e2fdbf77f5676abb14a156"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:2ec4f2d48ae59bbb9d1f9d7efb9236ab81429a764dedca114f5fdabbc3788013"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:608e7073dfa9e38a85d38474c082d4281f4ce276ac0010224eaba11e929dd53a"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:65608c35bfb8a76763f37036547f7adfd09270fbdbf96608be2bead319728fcd"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2bfb563d0211ce16b63c7cb9395d2c682a23187f54c3d79bfec33e6705473c6"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:da25303d91526aac3672ee6d49a2f3db2d9502a4a60b55519feb1a4c7714e07d"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:9cad97ab29dfc3f0249b483412c85c8ef4766d96cdf9dcf5a1e3caa3f3661cf1"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:085fd3201e7b12809f9e6e9bc1e5c96a368c8523fad5afb02afe3c051ae4afcc"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1bea30e9bf331f3fef67e0a3877b2288593c98a21ccb2cf29b74c581a4eb3af0"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-win32.whl", hash = "sha256:7df70907e00c970c60b9ef2938d894a9381f38e6b9db73c5be35e59d92e06625"}, + {file = "MarkupSafe-2.1.2-cp311-cp311-win_amd64.whl", hash = "sha256:e55e40ff0cc8cc5c07996915ad367fa47da6b3fc091fdadca7f5403239c5fec3"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a6e40afa7f45939ca356f348c8e23048e02cb109ced1eb8420961b2f40fb373a"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cf877ab4ed6e302ec1d04952ca358b381a882fbd9d1b07cccbfd61783561f98a"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63ba06c9941e46fa389d389644e2d8225e0e3e5ebcc4ff1ea8506dce646f8c8a"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f1cd098434e83e656abf198f103a8207a8187c0fc110306691a2e94a78d0abb2"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:55f44b440d491028addb3b88f72207d71eeebfb7b5dbf0643f7c023ae1fba619"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:a6f2fcca746e8d5910e18782f976489939d54a91f9411c32051b4aab2bd7c513"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:0b462104ba25f1ac006fdab8b6a01ebbfbce9ed37fd37fd4acd70c67c973e460"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-win32.whl", hash = "sha256:7668b52e102d0ed87cb082380a7e2e1e78737ddecdde129acadb0eccc5423859"}, + {file = "MarkupSafe-2.1.2-cp37-cp37m-win_amd64.whl", hash = "sha256:6d6607f98fcf17e534162f0709aaad3ab7a96032723d8ac8750ffe17ae5a0666"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:a806db027852538d2ad7555b203300173dd1b77ba116de92da9afbc3a3be3eed"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a4abaec6ca3ad8660690236d11bfe28dfd707778e2442b45addd2f086d6ef094"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f03a532d7dee1bed20bc4884194a16160a2de9ffc6354b3878ec9682bb623c54"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4cf06cdc1dda95223e9d2d3c58d3b178aa5dacb35ee7e3bbac10e4e1faacb419"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:22731d79ed2eb25059ae3df1dfc9cb1546691cc41f4e3130fe6bfbc3ecbbecfa"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:f8ffb705ffcf5ddd0e80b65ddf7bed7ee4f5a441ea7d3419e861a12eaf41af58"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:8db032bf0ce9022a8e41a22598eefc802314e81b879ae093f36ce9ddf39ab1ba"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:2298c859cfc5463f1b64bd55cb3e602528db6fa0f3cfd568d3605c50678f8f03"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-win32.whl", hash = "sha256:50c42830a633fa0cf9e7d27664637532791bfc31c731a87b202d2d8ac40c3ea2"}, + {file = "MarkupSafe-2.1.2-cp38-cp38-win_amd64.whl", hash = "sha256:bb06feb762bade6bf3c8b844462274db0c76acc95c52abe8dbed28ae3d44a147"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:99625a92da8229df6d44335e6fcc558a5037dd0a760e11d84be2260e6f37002f"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8bca7e26c1dd751236cfb0c6c72d4ad61d986e9a41bbf76cb445f69488b2a2bd"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40627dcf047dadb22cd25ea7ecfe9cbf3bbbad0482ee5920b582f3809c97654f"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40dfd3fefbef579ee058f139733ac336312663c6706d1163b82b3003fb1925c4"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:090376d812fb6ac5f171e5938e82e7f2d7adc2b629101cec0db8b267815c85e2"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:2e7821bffe00aa6bd07a23913b7f4e01328c3d5cc0b40b36c0bd81d362faeb65"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:c0a33bc9f02c2b17c3ea382f91b4db0e6cde90b63b296422a939886a7a80de1c"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b8526c6d437855442cdd3d87eede9c425c4445ea011ca38d937db299382e6fa3"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-win32.whl", hash = "sha256:137678c63c977754abe9086a3ec011e8fd985ab90631145dfb9294ad09c102a7"}, + {file = "MarkupSafe-2.1.2-cp39-cp39-win_amd64.whl", hash = "sha256:0576fe974b40a400449768941d5d0858cc624e3249dfd1e0c33674e5c7ca7aed"}, + {file = "MarkupSafe-2.1.2.tar.gz", hash = "sha256:abcabc8c2b26036d62d4c746381a6f7cf60aafcc653198ad678306986b09450d"}, ] [[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" +name = "werkzeug" +version = "2.2.3" +description = "The comprehensive WSGI web application library." category = "main" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +python-versions = ">=3.7" files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, + {file = "Werkzeug-2.2.3-py3-none-any.whl", hash = "sha256:56433961bc1f12533306c624f3be5e744389ac61d722175d543e1751285da612"}, + {file = "Werkzeug-2.2.3.tar.gz", hash = "sha256:2e1ccc9417d4da358b9de6f174e3ac094391ea1d4fbef2d667865d819dfd0afe"}, ] +[package.dependencies] +MarkupSafe = ">=2.1.1" + +[package.extras] +watchdog = ["watchdog"] + +[[package]] +name = "zipp" +version = "3.15.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, + {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "58dbe3e50badcea66493581dddef36d868fc84d26001b2bf5866e979943802e0" +content-hash = "7216cb19934d1ac8bbfdc617643fa327d8aa5dbda9676528772020337dc05e8d" diff --git a/testing/python/pyproject.toml b/testing/python/pyproject.toml index d48114a3c..4a7c650ad 100644 --- a/testing/python/pyproject.toml +++ b/testing/python/pyproject.toml @@ -1,13 +1,12 @@ [tool.poetry] -name = "cffi-pandas-wheel" +name = "import_packages_test" version = "0.1.0" -description = "Test of cffi-pandas wheel" +description = "Test of python packages imports in Bazel" authors = ["Your Name "] [tool.poetry.dependencies] python = "^3.9" -cffi = "^1.15.1" -pandas = "^1.5.2" +flask = "^2.2.0" [build-system] requires = ["poetry-core>=1"] diff --git a/testing/python/requirements.txt b/testing/python/requirements.txt index 2ec030ce5..a538d083c 100644 --- a/testing/python/requirements.txt +++ b/testing/python/requirements.txt @@ -1,2 +1 @@ -cffi -pandas +flask >= 2.2.0 diff --git a/testing/python/tests/BUILD.bazel b/testing/python/tests/BUILD.bazel index d515bf367..a64fda254 100644 --- a/testing/python/tests/BUILD.bazel +++ b/testing/python/tests/BUILD.bazel @@ -28,8 +28,7 @@ py_test( main = "import_packages_test.py", srcs = ["import_packages_test.py"], deps = [ - poetry_requirement("cffi"), - poetry_requirement("pandas"), + poetry_requirement("flask"), ], srcs_version = "PY3", python_version = "PY3", @@ -42,8 +41,7 @@ py_test( main = "import_packages_test.py", srcs = ["import_packages_test.py"], deps = [ - mach_nix_requirement("cffi"), - mach_nix_requirement("pandas"), + mach_nix_requirement("flask"), ], srcs_version = "PY3", python_version = "PY3", diff --git a/testing/python/tests/import_packages_test.py b/testing/python/tests/import_packages_test.py index 64f4bb6d9..99a7e85b1 100644 --- a/testing/python/tests/import_packages_test.py +++ b/testing/python/tests/import_packages_test.py @@ -2,13 +2,10 @@ print("python path = ", end="") pprint.pprint(sys.path) -import cffi -print("cffi version = ", cffi.__version__) - -import pandas -print("pandas version = ", pandas.__version__) +import flask +print("flask version = ", flask.__version__) # Also test that numpy is available. # nixpkgs_python_repository should provide the dependencies closure. -import numpy -print("numpy version = ", numpy.__version__) +import click +print("click version = ", click.__version__) From b82342f79812f5076710f4f0ad04acb73a2e31f1 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 16:03:01 +0100 Subject: [PATCH 17/24] Revert "Try to make mach-nix work on ci" This reverts commit 08d3678f04b7e7c669d960c772ce160f67267b09. --- testing/python/.bazelrc | 2 -- testing/python/mach-nix.nix | 14 +++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/testing/python/.bazelrc b/testing/python/.bazelrc index 1b3164f1a..ae8f32bd8 100644 --- a/testing/python/.bazelrc +++ b/testing/python/.bazelrc @@ -1,5 +1,3 @@ import %workspace%/../../.bazelrc.common import %workspace%/../../.bazelrc.cc import %workspace%/../../.bazelrc.java - -common --repo_env=TMDIR=/tmp diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix index fd9f876e8..ba5ace99c 100644 --- a/testing/python/mach-nix.nix +++ b/testing/python/mach-nix.nix @@ -3,13 +3,17 @@ let mach-nix = import (nixpkgs.fetchFromGitHub { owner = "DavHau"; repo = "mach-nix"; - rev = "68a85753555ed67ff53f0d0320e5ac3c725c7400"; - hash = "sha256-YIcQtXNQSofFSRDO8Y/uCtXAMguc8HqpY83TstgkH+k="; - }) { }; + rev = "f60b9833469adb18e57b4c9e8fc4804fce82e3da"; + hash = "sha256-LGFLMTf9gEPYzLuny3idKQOGiZFVhmjR2VGvio4chMI="; + }) { + # ** Extremely important! ** + # You want to use the same python version as your main nixpkgs. + # Bazel does not enforce this, and it will fail for binary packages. + pkgs = nixpkgs; + }; pythonWithPackages = mach-nix.mkPython { requirements = builtins.readFile ./requirements.txt; - # Keep this aligned with whatever nixpkgs.python is in flake.nix. - python = "python310"; + providers._default = "nixpkgs"; }; python = pythonWithPackages.python; # Beloved hacks ! From f2af8430c23241c0b7b282caa3ed66e5aded5788 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 17:02:22 +0100 Subject: [PATCH 18/24] Another attempt at mach-nix --- testing/python/mach-nix.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix index ba5ace99c..fdd49c70c 100644 --- a/testing/python/mach-nix.nix +++ b/testing/python/mach-nix.nix @@ -9,11 +9,13 @@ let # ** Extremely important! ** # You want to use the same python version as your main nixpkgs. # Bazel does not enforce this, and it will fail for binary packages. - pkgs = nixpkgs; + #pkgs = nixpkgs; # broken with this version of mach-nix + python = "python310"; + pypiDataRev = "cc1357c73b483fdec3091ea782aafc86a6a79fe1"; + pypiDataSha256 = "042gn8m6iw7kcwn5qzdqxvhw5q1k6y3h1jww0r746mfmi0qn5i80"; }; pythonWithPackages = mach-nix.mkPython { requirements = builtins.readFile ./requirements.txt; - providers._default = "nixpkgs"; }; python = pythonWithPackages.python; # Beloved hacks ! From a29651b327bd52d08e0b9e1bea56cb04ab1ac546 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 20:10:02 +0100 Subject: [PATCH 19/24] WIP: mach-nix-debug --- .github/workflows/workflow.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index be26a1c7a..fb0d25579 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -53,6 +53,7 @@ jobs: env: BZLMOD_ENABLED: ${{ matrix.bzlmodEnabled }} run: | + nix-build -A pkgs testing/python/mach-nix.nix -v nix-shell --pure \ --keep GITHUB_REPOSITORY \ --keep BZLMOD_ENABLED \ From 562695afcd9e4ba9b4cc9c177d18818f9b8b8871 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 20:29:13 +0100 Subject: [PATCH 20/24] WIP: hopefully fix mach-nix for macos --- testing/python/mach-nix.nix | 2 ++ testing/python/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix index fdd49c70c..2c87d3794 100644 --- a/testing/python/mach-nix.nix +++ b/testing/python/mach-nix.nix @@ -16,6 +16,7 @@ let }; pythonWithPackages = mach-nix.mkPython { requirements = builtins.readFile ./requirements.txt; + providers._default = "nixpkgs,wheel"; }; python = pythonWithPackages.python; # Beloved hacks ! @@ -24,6 +25,7 @@ let # plus the onse configured by mach-nix. # This retrives the `extraLibs` attribute that mach-nix configured. pkgs = (pythonWithPackages.override (old: { + # ignoreCollisions happens to tolerate this abuse ignoreCollisions = old.extraLibs; })).ignoreCollisions; in { diff --git a/testing/python/requirements.txt b/testing/python/requirements.txt index a538d083c..30dccd683 100644 --- a/testing/python/requirements.txt +++ b/testing/python/requirements.txt @@ -1 +1 @@ -flask >= 2.2.0 +flask >= 2.0.0 From 5ebc68d50a4048725bea024be4e560ea1e8a48d3 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 20:53:15 +0100 Subject: [PATCH 21/24] Add vanilla nixpkgs python package set --- testing/python/MODULE.bazel | 2 ++ testing/python/tests/BUILD.bazel | 14 ++++++++++++++ testing/python/tests/nixpkgs_repositories.bzl | 6 ++++++ testing/python/vanilla.nix | 8 ++++++++ 4 files changed, 30 insertions(+) create mode 100644 testing/python/vanilla.nix diff --git a/testing/python/MODULE.bazel b/testing/python/MODULE.bazel index 4d12cc9dc..073787fd8 100644 --- a/testing/python/MODULE.bazel +++ b/testing/python/MODULE.bazel @@ -55,3 +55,5 @@ use_repo(non_module_deps, "generated_poetry_packages_deps") use_repo(non_module_deps, "poetry_packages") use_repo(non_module_deps, "generated_mach_nix_packages_deps") use_repo(non_module_deps, "mach_nix_packages") +use_repo(non_module_deps, "generated_vanilla_packages_deps") +use_repo(non_module_deps, "vanilla_packages") diff --git a/testing/python/tests/BUILD.bazel b/testing/python/tests/BUILD.bazel index a64fda254..98fe945d0 100644 --- a/testing/python/tests/BUILD.bazel +++ b/testing/python/tests/BUILD.bazel @@ -1,6 +1,7 @@ load("@nixpkgs_python_toolchain//:defs.bzl", "interpreter") load("@poetry_packages//:requirements.bzl", poetry_requirement = "requirement") load("@mach_nix_packages//:requirements.bzl", mach_nix_requirement = "requirement") +load("@vanilla_packages//:requirements.bzl", vanilla_requirement = "requirement") package(default_testonly = 1) # Test nixpkgs_python_configure() by running some Python code. @@ -48,3 +49,16 @@ py_test( size = "small", visibility = ["//visibility:public"], ) + +py_test( + name = "import-vanilla-packages", + main = "import_packages_test.py", + srcs = ["import_packages_test.py"], + deps = [ + vanilla_requirement("flask"), + ], + srcs_version = "PY3", + python_version = "PY3", + size = "small", + visibility = ["//visibility:public"], +) diff --git a/testing/python/tests/nixpkgs_repositories.bzl b/testing/python/tests/nixpkgs_repositories.bzl index ef933e271..93b734f52 100644 --- a/testing/python/tests/nixpkgs_repositories.bzl +++ b/testing/python/tests/nixpkgs_repositories.bzl @@ -59,3 +59,9 @@ def nixpkgs_repositories(*, bzlmod): "//:requirements.txt", ], ) + + nixpkgs_python_repository( + name = "vanilla_packages", + repository = "@nixpkgs", + nix_file = "//:vanilla.nix", + ) diff --git a/testing/python/vanilla.nix b/testing/python/vanilla.nix new file mode 100644 index 000000000..a433f2ce4 --- /dev/null +++ b/testing/python/vanilla.nix @@ -0,0 +1,8 @@ +let + nixpkgs = import {}; + filterFun = ps: [ ps.flask ]; + pythonWithPkgs = nixpkgs.python310.withPackages filterFun; +in { + python = pythonWithPkgs.python; + pkgs = filterFun pythonWithPkgs.pkgs; +} From 8609a4d392e614952b2f652157b9554ea709dfd8 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 20:54:26 +0100 Subject: [PATCH 22/24] Remove broken mach-nix example --- testing/python/MODULE.bazel | 2 -- testing/python/mach-nix.nix | 33 ------------------- testing/python/requirements.txt | 1 - testing/python/tests/BUILD.bazel | 14 -------- testing/python/tests/nixpkgs_repositories.bzl | 9 ----- 5 files changed, 59 deletions(-) delete mode 100644 testing/python/mach-nix.nix delete mode 100644 testing/python/requirements.txt diff --git a/testing/python/MODULE.bazel b/testing/python/MODULE.bazel index 073787fd8..6296bcba8 100644 --- a/testing/python/MODULE.bazel +++ b/testing/python/MODULE.bazel @@ -53,7 +53,5 @@ register_toolchains("@nixpkgs_python_toolchain//:all") use_repo(non_module_deps, "generated_poetry_packages_deps") use_repo(non_module_deps, "poetry_packages") -use_repo(non_module_deps, "generated_mach_nix_packages_deps") -use_repo(non_module_deps, "mach_nix_packages") use_repo(non_module_deps, "generated_vanilla_packages_deps") use_repo(non_module_deps, "vanilla_packages") diff --git a/testing/python/mach-nix.nix b/testing/python/mach-nix.nix deleted file mode 100644 index 2c87d3794..000000000 --- a/testing/python/mach-nix.nix +++ /dev/null @@ -1,33 +0,0 @@ -let - nixpkgs = import {}; - mach-nix = import (nixpkgs.fetchFromGitHub { - owner = "DavHau"; - repo = "mach-nix"; - rev = "f60b9833469adb18e57b4c9e8fc4804fce82e3da"; - hash = "sha256-LGFLMTf9gEPYzLuny3idKQOGiZFVhmjR2VGvio4chMI="; - }) { - # ** Extremely important! ** - # You want to use the same python version as your main nixpkgs. - # Bazel does not enforce this, and it will fail for binary packages. - #pkgs = nixpkgs; # broken with this version of mach-nix - python = "python310"; - pypiDataRev = "cc1357c73b483fdec3091ea782aafc86a6a79fe1"; - pypiDataSha256 = "042gn8m6iw7kcwn5qzdqxvhw5q1k6y3h1jww0r746mfmi0qn5i80"; - }; - pythonWithPackages = mach-nix.mkPython { - requirements = builtins.readFile ./requirements.txt; - providers._default = "nixpkgs,wheel"; - }; - python = pythonWithPackages.python; - # Beloved hacks ! - # Extract the subset of packages that have been requested by mach-nix. - # By default, python.pkgs contains all the packages known by nixpkgs, - # plus the onse configured by mach-nix. - # This retrives the `extraLibs` attribute that mach-nix configured. - pkgs = (pythonWithPackages.override (old: { - # ignoreCollisions happens to tolerate this abuse - ignoreCollisions = old.extraLibs; - })).ignoreCollisions; -in { - inherit python pkgs; -} diff --git a/testing/python/requirements.txt b/testing/python/requirements.txt deleted file mode 100644 index 30dccd683..000000000 --- a/testing/python/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -flask >= 2.0.0 diff --git a/testing/python/tests/BUILD.bazel b/testing/python/tests/BUILD.bazel index 98fe945d0..f0509210d 100644 --- a/testing/python/tests/BUILD.bazel +++ b/testing/python/tests/BUILD.bazel @@ -1,6 +1,5 @@ load("@nixpkgs_python_toolchain//:defs.bzl", "interpreter") load("@poetry_packages//:requirements.bzl", poetry_requirement = "requirement") -load("@mach_nix_packages//:requirements.bzl", mach_nix_requirement = "requirement") load("@vanilla_packages//:requirements.bzl", vanilla_requirement = "requirement") package(default_testonly = 1) @@ -37,19 +36,6 @@ py_test( visibility = ["//visibility:public"], ) -py_test( - name = "import-mach-nix-packages", - main = "import_packages_test.py", - srcs = ["import_packages_test.py"], - deps = [ - mach_nix_requirement("flask"), - ], - srcs_version = "PY3", - python_version = "PY3", - size = "small", - visibility = ["//visibility:public"], -) - py_test( name = "import-vanilla-packages", main = "import_packages_test.py", diff --git a/testing/python/tests/nixpkgs_repositories.bzl b/testing/python/tests/nixpkgs_repositories.bzl index 93b734f52..f1d8921e8 100644 --- a/testing/python/tests/nixpkgs_repositories.bzl +++ b/testing/python/tests/nixpkgs_repositories.bzl @@ -51,15 +51,6 @@ def nixpkgs_repositories(*, bzlmod): ], ) - nixpkgs_python_repository( - name = "mach_nix_packages", - repository = "@nixpkgs", - nix_file = "//:mach-nix.nix", - nix_file_deps = [ - "//:requirements.txt", - ], - ) - nixpkgs_python_repository( name = "vanilla_packages", repository = "@nixpkgs", From e816bfd537794b12647377bcc6968231d79a9945 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 13 Mar 2023 20:59:32 +0100 Subject: [PATCH 23/24] Remove leftover debug data --- .github/workflows/workflow.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index fb0d25579..be26a1c7a 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -53,7 +53,6 @@ jobs: env: BZLMOD_ENABLED: ${{ matrix.bzlmodEnabled }} run: | - nix-build -A pkgs testing/python/mach-nix.nix -v nix-shell --pure \ --keep GITHUB_REPOSITORY \ --keep BZLMOD_ENABLED \ From 6e10291ddede338ec5cac5db4ddacd88a50eb9a3 Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Tue, 14 Mar 2023 16:21:26 +0100 Subject: [PATCH 24/24] Improve docs as per review comments --- README.md | 2 -- testing/python/tests/import_packages_test.py | 5 +++-- toolchains/python/README.md | 2 -- toolchains/python/package_set_to_json.nix | 2 +- toolchains/python/python.bzl | 2 -- toolchains/python/python_package.bzl | 7 ++++--- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 562fb9e47..c5bc5baff 100644 --- a/README.md +++ b/README.md @@ -1880,8 +1880,6 @@ in the future. To be on the safe side, define and import your own between the version of python used to generate this repository and the one configured in your toolchain, even if you use nixpkgs_python_toolchain. You should ensure they both use the same python from the same nixpkgs version. -While nixpkgs_python_repository could also register the toolchain used to -generate the package set, this is not implemented yet. :warning: packages names exposed by this rule are determined by the `pname` attribute of the corresponding nix package. These may vary slightly from diff --git a/testing/python/tests/import_packages_test.py b/testing/python/tests/import_packages_test.py index 99a7e85b1..33d4e6684 100644 --- a/testing/python/tests/import_packages_test.py +++ b/testing/python/tests/import_packages_test.py @@ -5,7 +5,8 @@ import flask print("flask version = ", flask.__version__) -# Also test that numpy is available. -# nixpkgs_python_repository should provide the dependencies closure. +# Also test that click is available. +# nixpkgs_python_repository should provide all the dependencies of requested +# packages. Click is just a random dependency of flask. import click print("click version = ", click.__version__) diff --git a/toolchains/python/README.md b/toolchains/python/README.md index 9fd26c312..872b275a5 100644 --- a/toolchains/python/README.md +++ b/toolchains/python/README.md @@ -279,8 +279,6 @@ in the future. To be on the safe side, define and import your own between the version of python used to generate this repository and the one configured in your toolchain, even if you use nixpkgs_python_toolchain. You should ensure they both use the same python from the same nixpkgs version. -While nixpkgs_python_repository could also register the toolchain used to -generate the package set, this is not implemented yet. :warning: packages names exposed by this rule are determined by the `pname` attribute of the corresponding nix package. These may vary slightly from diff --git a/toolchains/python/package_set_to_json.nix b/toolchains/python/package_set_to_json.nix index b452d4927..71a8fb4de 100644 --- a/toolchains/python/package_set_to_json.nix +++ b/toolchains/python/package_set_to_json.nix @@ -1,6 +1,6 @@ { # A file to be later `import`ed, and providing two attributes: - # - `python`: used to obtain the valie of `sitePackages` + # - `python`: used to obtain the value of `sitePackages` # - `pkgs`: a set of python packages whose closure will be exposed in the # generated json file, and consumed by `nixpkgs_python_repository` rule. nix_file diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl index 235b2058e..0635bb2b2 100644 --- a/toolchains/python/python.bzl +++ b/toolchains/python/python.bzl @@ -293,8 +293,6 @@ def nixpkgs_python_repository( between the version of python used to generate this repository and the one configured in your toolchain, even if you use nixpkgs_python_toolchain. You should ensure they both use the same python from the same nixpkgs version. - While nixpkgs_python_repository could also register the toolchain used to - generate the package set, this is not implemented yet. :warning: packages names exposed by this rule are determined by the `pname` attribute of the corresponding nix package. These may vary slightly from diff --git a/toolchains/python/python_package.bzl b/toolchains/python/python_package.bzl index b6e187513..cc61fa24b 100644 --- a/toolchains/python/python_package.bzl +++ b/toolchains/python/python_package.bzl @@ -3,9 +3,10 @@ def _python_package_impl(ctx): transitive_runfiles = [] transitive_sources = [] - # HACK(danny): for some unforunate reason, short_path returns ../ when operating in external - # repositories. I don't know why. It breaks rules_python's assumptions though. - # See https://github.com/bazelbuild/bazel-skylib/issues/303 for some discussion. + # HACK: short_path returns ../ when operating in external + # repositories, but this breaks rules_python's assumptions. + # See https://github.com/bazelbuild/bazel-skylib/issues/303 + # for some discussion. store = ctx.file.store_path fixed_path = store.short_path[3:] import_path = "/".join([ctx.workspace_name, store.short_path])