Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions tests/integration/pip_parse/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,37 @@ local_path_override(
module_name = "rules_python",
path = "../../..",
)
bazel_dep(name = "platforms", version = "0.0.11")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
python_version = "3.9",
uv = use_extension(
"@rules_python//python/uv:uv.bzl",
"uv",
# Use `dev_dependency` so that the toolchains are not defined pulled when your
# module is used elsewhere.
dev_dependency = True,
)
uv.configure(version = "0.9.5")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.9", is_default=True)
python.toolchain(python_version = "3.10")
python.toolchain(python_version = "3.13")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip_empty",
python_version = "3.9",
requirements_lock = "//empty:requirements.txt",
)
use_repo(pip, "pip_empty")

pip.parse(
hub_name = "pip_torch",
python_version = "3.10",
requirements_lock = "//torch:requirements.txt",
)
pip.parse(
hub_name = "pip_torch",
python_version = "3.13",
requirements_lock = "//torch:requirements.txt",
)
use_repo(pip, "pip_empty", "pip_torch")
32 changes: 32 additions & 0 deletions tests/integration/pip_parse/torch/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
load("@pip_torch//:requirements.bzl", "all_data_requirements", "all_requirements", "all_whl_requirements")
load("@rules_python//python:py_test.bzl", "py_test")
load("@rules_python//python/uv:lock.bzl", "lock")

# Run bazel run //torch:requirements.update
lock(
name = "requirements",
srcs = ["requirements.in"],
out = "requirements.txt",
args = [
"--emit-index-url",
"--universal",
"--upgrade",
"--extra-index-url=https://download.pytorch.org/whl/cpu",
],
# NOTE @aignas 2025-08-17: here we select the lowest actively supported version so that the
# requirements file is generated to be compatible with Python version 3.9 or greater.
python_version = "3.10",
visibility = ["//:__subpackages__"],
)

py_test(
name = "test_empty",
srcs = ["test_empty.py"],
deps = ["@pip_torch//torch"],
python_version = "3.10", # Use a non-default toolchain version
env = {
"REQUIREMENTS": ",".join(all_requirements),
"REQUIREMENTS_DATA": ",".join(all_data_requirements),
"REQUIREMENTS_WHL": ",".join(all_whl_requirements),
},
)
1 change: 1 addition & 0 deletions tests/integration/pip_parse/torch/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
torch
70 changes: 70 additions & 0 deletions tests/integration/pip_parse/torch/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This file was autogenerated by uv via the following command:
# bazel run //torch:requirements.update
--index-url https://pypi.org/simple
--extra-index-url https://download.pytorch.org/whl/cpu

filelock==3.19.1 \
--hash=sha256:d38e30481def20772f5baf097c122c3babc4fcdb7e14e57049eb9d88c6dc017d
# via torch
fsspec==2025.9.0 \
--hash=sha256:530dc2a2af60a414a832059574df4a6e10cce927f6f4a78209390fe38955cfb7
# via torch
jinja2==3.1.6 \
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
# via torch
markupsafe==3.0.2 \
--hash=sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396
# via jinja2
mpmath==1.3.0 \
--hash=sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c
# via sympy
networkx==3.3 ; python_full_version < '3.12' \
--hash=sha256:28575580c6ebdaf4505b22c6256a2b9de86b316dc63ba9e93abde3d78dfdbcf2
# via torch
networkx==3.5 ; python_full_version >= '3.12' \
--hash=sha256:0030d386a9a06dee3565298b4a734b68589749a544acbb6c412dc9e2489ec6ec
# via torch
setuptools==70.2.0 ; python_full_version >= '3.12' \
--hash=sha256:b8b8060bb426838fbe942479c90296ce976249451118ef566a5a0b7d8b78fb05
# via torch
sympy==1.14.0 \
--hash=sha256:e091cc3e99d2141a0ba2847328f5479b05d94a6635cb96148ccb3f34671bd8f5
# via torch
torch==2.9.0 ; sys_platform == 'darwin' \
--hash=sha256:259548471194ab63d7ea273873053a6e3cc23530c1510f01e9d7ad259187bbd0 \
--hash=sha256:4de0ed8cbc457a506dbca40376e206a29efee10756a00f1f3404bf67ad737d04 \
--hash=sha256:59484193b01299bf669520505a72b29d59a0028ae4c6d95f492938f186592208 \
--hash=sha256:a3e859039c985d8e3ea60d7a54ca7e97ea2ae15e31beced4f3260128a161bb01 \
--hash=sha256:aa4483602586cc9a35d1cf33771a9977f05f642b9161518a289e36548a0b77c2 \
--hash=sha256:d8e2ab7f86010330bdcc39c8b2c795590cc75e37df4823cdaee2c98d6e3ff4a3 \
--hash=sha256:e24836d968b54ef4dfb05594001a61958711ac9224026291e4e3f92f83a6fd7f
# via -r torch/requirements.in
torch==2.9.0+cpu ; sys_platform != 'darwin' \
--hash=sha256:28f6eb31b08180a5c5e98d5bc14eef6909c9f5a1dbff9632c3e02a8773449349 \
--hash=sha256:2f49bb57a5fe0dc7f8e73ea9e5d36ebda2ea25b8a714a788f0fc2fc47d20a830 \
--hash=sha256:389e1e0b8083fd355f7caf5ba82356b5e01c318998bd575dbf2285a0d8137089 \
--hash=sha256:3a60d1ecf27a9cce839b3aa665b26f0af1b1007b9c9f1e7f597f6b7bdf107617 \
--hash=sha256:3a651434ae1248b0568c12b5f9e3acc8942eb28378d9d04a79302938b68c6f24 \
--hash=sha256:44aadb735774d4a99525d2ec29126b23016c44a07b02ce6c237dfa61a223dd52 \
--hash=sha256:528fd338311f31c9fb18038cafd00e6eae0bf5ad5577521701acb62510753d18 \
--hash=sha256:5ce3d01aef91dc078fbb121814e556d55bc886d303efaf42c4fe67e411f5f9ad \
--hash=sha256:6c777160288b08555820781ae0f3a2c67a59bd24b065e88ca1ec20e2f9dc8ac7 \
--hash=sha256:6c9b217584400963d5b4daddb3711ec7a3778eab211e18654fba076cce3b8682 \
--hash=sha256:728372e3f58c5826445f677746e5311c1935c1a7c59599f73a49ded850e038e8 \
--hash=sha256:95e56c26f919fbb98f16e7a0b87af494b893f9da9a65a020f17a01c13e520a81 \
--hash=sha256:96f3f7aa4eb9e7fc5af8a722eaf1e5e32e3039dbafe817178d7b90a8566be32d \
--hash=sha256:add3e93ecc1eeaa6853f6a973ce60ffb3cb14ed2e80f5055e139b09385dce0a7 \
--hash=sha256:b224792ea567b52c7f1ce1d789567f6920e06fd3b339fa1e1b05948845f783ad \
--hash=sha256:b355e07b7f0c369cb031adfcbff5c37a609abcea091b918a39886412afd2e07d \
--hash=sha256:bd2a257e670ede9fc01c6d76dccdc473040913b8e9328169bf177dbdc38e2484 \
--hash=sha256:be4438d8dad7f0d5a5e54f0feef8a893446894ec87f102bb1d82dcc4518542e4 \
--hash=sha256:c2698999361d73c2d25d7cc8a787130188d49b183abb18b554228daa102e1594 \
--hash=sha256:d572863990e7d2762b547735ef589f6350d9eb4e441d38753a1c33636698cf4c \
--hash=sha256:da77341ccaba31762d9238b0942c165c4582a26818f3045b052b39cebdd7ad9d \
--hash=sha256:e438061b87ec7dd6018fca9f975219889aa0a3f6cdc3ea10dd0ae2bc7f1c47ce \
--hash=sha256:eb13ff1c34e338d722e76a4fd83b8d282782505bd1b99af4b3c32da66eba6eb4 \
--hash=sha256:fa0d1373d04b30ff8f12d542135d292f1a1ddb7c0d852a3d487a320360e5dab9
# via -r torch/requirements.in
typing-extensions==4.15.0 \
--hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548
# via torch
13 changes: 13 additions & 0 deletions tests/integration/pip_parse/torch/test_empty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os
import unittest


class TestEmpty(unittest.TestCase):
def test_lists(self):
self.assertEqual("", os.environ["REQUIREMENTS"])
self.assertEqual("", os.environ["REQUIREMENTS_WHL"])
self.assertEqual("", os.environ["REQUIREMENTS_DATA"])


if __name__ == "__main__":
unittest.main()