Skip to content

Commit 2529468

Browse files
committed
test: attempt to add a torch example to debug
1 parent cf594f7 commit 2529468

File tree

5 files changed

+141
-4
lines changed

5 files changed

+141
-4
lines changed

tests/integration/pip_parse/MODULE.bazel

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,37 @@ local_path_override(
55
module_name = "rules_python",
66
path = "../../..",
77
)
8+
bazel_dep(name = "platforms", version = "0.0.11")
89

9-
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
10-
python.toolchain(
11-
python_version = "3.9",
10+
uv = use_extension(
11+
"@rules_python//python/uv:uv.bzl",
12+
"uv",
13+
# Use `dev_dependency` so that the toolchains are not defined pulled when your
14+
# module is used elsewhere.
15+
dev_dependency = True,
1216
)
17+
uv.configure(version = "0.9.5")
18+
19+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
20+
python.toolchain(python_version = "3.9", is_default=True)
21+
python.toolchain(python_version = "3.10")
22+
python.toolchain(python_version = "3.13")
1323

1424
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
1525
pip.parse(
1626
hub_name = "pip_empty",
1727
python_version = "3.9",
1828
requirements_lock = "//empty:requirements.txt",
1929
)
20-
use_repo(pip, "pip_empty")
30+
31+
pip.parse(
32+
hub_name = "pip_torch",
33+
python_version = "3.10",
34+
requirements_lock = "//torch:requirements.txt",
35+
)
36+
pip.parse(
37+
hub_name = "pip_torch",
38+
python_version = "3.13",
39+
requirements_lock = "//torch:requirements.txt",
40+
)
41+
use_repo(pip, "pip_empty", "pip_torch")
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
load("@pip_torch//:requirements.bzl", "all_data_requirements", "all_requirements", "all_whl_requirements")
2+
load("@rules_python//python:py_test.bzl", "py_test")
3+
load("@rules_python//python/uv:lock.bzl", "lock")
4+
5+
# Run bazel run //torch:requirements.update
6+
lock(
7+
name = "requirements",
8+
srcs = ["requirements.in"],
9+
out = "requirements.txt",
10+
args = [
11+
"--emit-index-url",
12+
"--universal",
13+
"--upgrade",
14+
"--extra-index-url=https://download.pytorch.org/whl/cpu",
15+
],
16+
# NOTE @aignas 2025-08-17: here we select the lowest actively supported version so that the
17+
# requirements file is generated to be compatible with Python version 3.9 or greater.
18+
python_version = "3.10",
19+
visibility = ["//:__subpackages__"],
20+
)
21+
22+
py_test(
23+
name = "test_empty",
24+
srcs = ["test_empty.py"],
25+
deps = ["@pip_torch//torch"],
26+
python_version = "3.10", # Use a non-default toolchain version
27+
env = {
28+
"REQUIREMENTS": ",".join(all_requirements),
29+
"REQUIREMENTS_DATA": ",".join(all_data_requirements),
30+
"REQUIREMENTS_WHL": ",".join(all_whl_requirements),
31+
},
32+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
torch
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# This file was autogenerated by uv via the following command:
2+
# bazel run //torch:requirements.update
3+
--index-url https://pypi.org/simple
4+
--extra-index-url https://download.pytorch.org/whl/cpu
5+
6+
filelock==3.19.1 \
7+
--hash=sha256:d38e30481def20772f5baf097c122c3babc4fcdb7e14e57049eb9d88c6dc017d
8+
# via torch
9+
fsspec==2025.9.0 \
10+
--hash=sha256:530dc2a2af60a414a832059574df4a6e10cce927f6f4a78209390fe38955cfb7
11+
# via torch
12+
jinja2==3.1.6 \
13+
--hash=sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67
14+
# via torch
15+
markupsafe==3.0.2 \
16+
--hash=sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396
17+
# via jinja2
18+
mpmath==1.3.0 \
19+
--hash=sha256:a0b2b9fe80bbcd81a6647ff13108738cfb482d481d826cc0e02f5b35e5c88d2c
20+
# via sympy
21+
networkx==3.3 ; python_full_version < '3.12' \
22+
--hash=sha256:28575580c6ebdaf4505b22c6256a2b9de86b316dc63ba9e93abde3d78dfdbcf2
23+
# via torch
24+
networkx==3.5 ; python_full_version >= '3.12' \
25+
--hash=sha256:0030d386a9a06dee3565298b4a734b68589749a544acbb6c412dc9e2489ec6ec
26+
# via torch
27+
setuptools==70.2.0 ; python_full_version >= '3.12' \
28+
--hash=sha256:b8b8060bb426838fbe942479c90296ce976249451118ef566a5a0b7d8b78fb05
29+
# via torch
30+
sympy==1.14.0 \
31+
--hash=sha256:e091cc3e99d2141a0ba2847328f5479b05d94a6635cb96148ccb3f34671bd8f5
32+
# via torch
33+
torch==2.9.0 ; sys_platform == 'darwin' \
34+
--hash=sha256:259548471194ab63d7ea273873053a6e3cc23530c1510f01e9d7ad259187bbd0 \
35+
--hash=sha256:4de0ed8cbc457a506dbca40376e206a29efee10756a00f1f3404bf67ad737d04 \
36+
--hash=sha256:59484193b01299bf669520505a72b29d59a0028ae4c6d95f492938f186592208 \
37+
--hash=sha256:a3e859039c985d8e3ea60d7a54ca7e97ea2ae15e31beced4f3260128a161bb01 \
38+
--hash=sha256:aa4483602586cc9a35d1cf33771a9977f05f642b9161518a289e36548a0b77c2 \
39+
--hash=sha256:d8e2ab7f86010330bdcc39c8b2c795590cc75e37df4823cdaee2c98d6e3ff4a3 \
40+
--hash=sha256:e24836d968b54ef4dfb05594001a61958711ac9224026291e4e3f92f83a6fd7f
41+
# via -r torch/requirements.in
42+
torch==2.9.0+cpu ; sys_platform != 'darwin' \
43+
--hash=sha256:28f6eb31b08180a5c5e98d5bc14eef6909c9f5a1dbff9632c3e02a8773449349 \
44+
--hash=sha256:2f49bb57a5fe0dc7f8e73ea9e5d36ebda2ea25b8a714a788f0fc2fc47d20a830 \
45+
--hash=sha256:389e1e0b8083fd355f7caf5ba82356b5e01c318998bd575dbf2285a0d8137089 \
46+
--hash=sha256:3a60d1ecf27a9cce839b3aa665b26f0af1b1007b9c9f1e7f597f6b7bdf107617 \
47+
--hash=sha256:3a651434ae1248b0568c12b5f9e3acc8942eb28378d9d04a79302938b68c6f24 \
48+
--hash=sha256:44aadb735774d4a99525d2ec29126b23016c44a07b02ce6c237dfa61a223dd52 \
49+
--hash=sha256:528fd338311f31c9fb18038cafd00e6eae0bf5ad5577521701acb62510753d18 \
50+
--hash=sha256:5ce3d01aef91dc078fbb121814e556d55bc886d303efaf42c4fe67e411f5f9ad \
51+
--hash=sha256:6c777160288b08555820781ae0f3a2c67a59bd24b065e88ca1ec20e2f9dc8ac7 \
52+
--hash=sha256:6c9b217584400963d5b4daddb3711ec7a3778eab211e18654fba076cce3b8682 \
53+
--hash=sha256:728372e3f58c5826445f677746e5311c1935c1a7c59599f73a49ded850e038e8 \
54+
--hash=sha256:95e56c26f919fbb98f16e7a0b87af494b893f9da9a65a020f17a01c13e520a81 \
55+
--hash=sha256:96f3f7aa4eb9e7fc5af8a722eaf1e5e32e3039dbafe817178d7b90a8566be32d \
56+
--hash=sha256:add3e93ecc1eeaa6853f6a973ce60ffb3cb14ed2e80f5055e139b09385dce0a7 \
57+
--hash=sha256:b224792ea567b52c7f1ce1d789567f6920e06fd3b339fa1e1b05948845f783ad \
58+
--hash=sha256:b355e07b7f0c369cb031adfcbff5c37a609abcea091b918a39886412afd2e07d \
59+
--hash=sha256:bd2a257e670ede9fc01c6d76dccdc473040913b8e9328169bf177dbdc38e2484 \
60+
--hash=sha256:be4438d8dad7f0d5a5e54f0feef8a893446894ec87f102bb1d82dcc4518542e4 \
61+
--hash=sha256:c2698999361d73c2d25d7cc8a787130188d49b183abb18b554228daa102e1594 \
62+
--hash=sha256:d572863990e7d2762b547735ef589f6350d9eb4e441d38753a1c33636698cf4c \
63+
--hash=sha256:da77341ccaba31762d9238b0942c165c4582a26818f3045b052b39cebdd7ad9d \
64+
--hash=sha256:e438061b87ec7dd6018fca9f975219889aa0a3f6cdc3ea10dd0ae2bc7f1c47ce \
65+
--hash=sha256:eb13ff1c34e338d722e76a4fd83b8d282782505bd1b99af4b3c32da66eba6eb4 \
66+
--hash=sha256:fa0d1373d04b30ff8f12d542135d292f1a1ddb7c0d852a3d487a320360e5dab9
67+
# via -r torch/requirements.in
68+
typing-extensions==4.15.0 \
69+
--hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548
70+
# via torch
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
import unittest
3+
4+
5+
class TestEmpty(unittest.TestCase):
6+
def test_lists(self):
7+
self.assertEqual("", os.environ["REQUIREMENTS"])
8+
self.assertEqual("", os.environ["REQUIREMENTS_WHL"])
9+
self.assertEqual("", os.environ["REQUIREMENTS_DATA"])
10+
11+
12+
if __name__ == "__main__":
13+
unittest.main()

0 commit comments

Comments
 (0)