Skip to content

Commit 0d24008

Browse files
Move the bazel rules for the python wrapper to MODULE.bazel (#31)
For some reason using WORKSPACE makes it hard to link stim with the python wrapper -or maybe I'm just writing the wrong bazel rules- This PR moves the rules needed for the python wrapper to `MODULE.bazel` and adds the rules needed to depend on pypi libraries. note that bazel deprecated `WORKSPACE` and will drop support for it by the end of the year https://bazel.build/external/migration but they allow using both at the same time during migration. so this PR starts the migration from `WORKSPACE` to `bzlmod` part of #17
1 parent af02125 commit 0d24008

File tree

6 files changed

+131
-51
lines changed

6 files changed

+131
-51
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
common --noenable_bzlmod --enable_workspace
1+
common --enable_bzlmod --enable_workspace
22
build --cxxopt='-std=c++20'
33
# HIGHS requires this define or else it is about 1.5x slower
44
build --copt="-DNDEBUG=0"

MODULE.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module(name = "tesseract", version = "1.0")
2+
3+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
4+
bazel_dep(name = "platforms", version = "0.0.10")
5+
bazel_dep(name = "rules_python", version = "0.40.0")
6+
bazel_dep(name = "rules_cc", version = "0.0.17")
7+
bazel_dep(name = "pybind11_bazel", version = "2.13.6")
8+
9+
DEFAULT_PYTHON_VERSION = "3.11"
10+
11+
python_configure = use_extension("@pybind11_bazel//:python_configure.bzl", "extension")
12+
use_repo(python_configure, "local_config_python")
13+
14+
15+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
16+
17+
pip.parse(
18+
hub_name = "pypi",
19+
python_version = "3.11",
20+
requirements_lock = "//src/py:requirements_lock.txt",
21+
)
22+
23+
use_repo(pip, "pypi")

WORKSPACE

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -65,53 +65,3 @@ http_archive(
6565
urls = ["https://github.com/bazelbuild/platforms/archive/refs/tags/0.0.6.zip"],
6666
strip_prefix = "platforms-0.0.6",
6767
)
68-
69-
http_archive(
70-
name = "rules_python",
71-
sha256 = "62ddebb766b4d6ddf1712f753dac5740bea072646f630eb9982caa09ad8a7687",
72-
strip_prefix = "rules_python-0.39.0",
73-
url = "https://github.com/bazelbuild/rules_python/releases/download/0.39.0/rules_python-0.39.0.tar.gz",
74-
)
75-
76-
77-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
78-
79-
http_archive(
80-
name = "rules_proto",
81-
sha256 = "14a225870ab4e91869652cfd69ef2028277fc1dc4910d65d353b62d6e0ae21f4",
82-
strip_prefix = "rules_proto-7.1.0",
83-
url = "https://github.com/bazelbuild/rules_proto/releases/download/7.1.0/rules_proto-7.1.0.tar.gz",
84-
)
85-
86-
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
87-
rules_proto_dependencies()
88-
89-
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
90-
rules_proto_toolchains()
91-
92-
93-
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
94-
95-
py_repositories()
96-
97-
python_register_toolchains(
98-
name = "python",
99-
ignore_root_user_error = True,
100-
python_version = "3.12",
101-
)
102-
103-
104-
http_archive(
105-
name = "pybind11_bazel",
106-
strip_prefix = "pybind11_bazel-2.13.6",
107-
sha256 = "9df284330336958c837fb70dc34c0a6254dac52a5c983b3373a8c2bbb79ac35e",
108-
urls = ["https://github.com/pybind/pybind11_bazel/archive/v2.13.6.zip"],
109-
)
110-
# We still require the pybind library.
111-
http_archive(
112-
name = "pybind11",
113-
build_file = "@pybind11_bazel//:pybind11-BUILD.bazel",
114-
strip_prefix = "pybind11-2.13.6",
115-
sha256 = "d0a116e91f64a4a2d8fb7590c34242df92258a61ec644b79127951e821b47be6",
116-
urls = ["https://github.com/pybind/pybind11/archive/v2.13.6.zip"],
117-
)

src/py/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
2+
3+
compile_pip_requirements(
4+
name = "requirements",
5+
src = "requirements.in",
6+
requirements_txt = "requirements_lock.txt",
7+
)

src/py/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stim

src/py/requirements_lock.txt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# bazel run //src/py:requirements.update
6+
#
7+
numpy==2.2.6 \
8+
--hash=sha256:038613e9fb8c72b0a41f025a7e4c3f0b7a1b5d768ece4796b674c8f3fe13efff \
9+
--hash=sha256:0678000bb9ac1475cd454c6b8c799206af8107e310843532b04d49649c717a47 \
10+
--hash=sha256:0811bb762109d9708cca4d0b13c4f67146e3c3b7cf8d34018c722adb2d957c84 \
11+
--hash=sha256:0b605b275d7bd0c640cad4e5d30fa701a8d59302e127e5f79138ad62762c3e3d \
12+
--hash=sha256:0bca768cd85ae743b2affdc762d617eddf3bcf8724435498a1e80132d04879e6 \
13+
--hash=sha256:1bc23a79bfabc5d056d106f9befb8d50c31ced2fbc70eedb8155aec74a45798f \
14+
--hash=sha256:287cc3162b6f01463ccd86be154f284d0893d2b3ed7292439ea97eafa8170e0b \
15+
--hash=sha256:37c0ca431f82cd5fa716eca9506aefcabc247fb27ba69c5062a6d3ade8cf8f49 \
16+
--hash=sha256:37e990a01ae6ec7fe7fa1c26c55ecb672dd98b19c3d0e1d1f326fa13cb38d163 \
17+
--hash=sha256:389d771b1623ec92636b0786bc4ae56abafad4a4c513d36a55dce14bd9ce8571 \
18+
--hash=sha256:3d70692235e759f260c3d837193090014aebdf026dfd167834bcba43e30c2a42 \
19+
--hash=sha256:41c5a21f4a04fa86436124d388f6ed60a9343a6f767fced1a8a71c3fbca038ff \
20+
--hash=sha256:481b49095335f8eed42e39e8041327c05b0f6f4780488f61286ed3c01368d491 \
21+
--hash=sha256:4eeaae00d789f66c7a25ac5f34b71a7035bb474e679f410e5e1a94deb24cf2d4 \
22+
--hash=sha256:55a4d33fa519660d69614a9fad433be87e5252f4b03850642f88993f7b2ca566 \
23+
--hash=sha256:5a6429d4be8ca66d889b7cf70f536a397dc45ba6faeb5f8c5427935d9592e9cf \
24+
--hash=sha256:5bd4fc3ac8926b3819797a7c0e2631eb889b4118a9898c84f585a54d475b7e40 \
25+
--hash=sha256:5beb72339d9d4fa36522fc63802f469b13cdbe4fdab4a288f0c441b74272ebfd \
26+
--hash=sha256:6031dd6dfecc0cf9f668681a37648373bddd6421fff6c66ec1624eed0180ee06 \
27+
--hash=sha256:71594f7c51a18e728451bb50cc60a3ce4e6538822731b2933209a1f3614e9282 \
28+
--hash=sha256:74d4531beb257d2c3f4b261bfb0fc09e0f9ebb8842d82a7b4209415896adc680 \
29+
--hash=sha256:7befc596a7dc9da8a337f79802ee8adb30a552a94f792b9c9d18c840055907db \
30+
--hash=sha256:894b3a42502226a1cac872f840030665f33326fc3dac8e57c607905773cdcde3 \
31+
--hash=sha256:8e41fd67c52b86603a91c1a505ebaef50b3314de0213461c7a6e99c9a3beff90 \
32+
--hash=sha256:8e9ace4a37db23421249ed236fdcdd457d671e25146786dfc96835cd951aa7c1 \
33+
--hash=sha256:8fc377d995680230e83241d8a96def29f204b5782f371c532579b4f20607a289 \
34+
--hash=sha256:9551a499bf125c1d4f9e250377c1ee2eddd02e01eac6644c080162c0c51778ab \
35+
--hash=sha256:b0544343a702fa80c95ad5d3d608ea3599dd54d4632df855e4c8d24eb6ecfa1c \
36+
--hash=sha256:b093dd74e50a8cba3e873868d9e93a85b78e0daf2e98c6797566ad8044e8363d \
37+
--hash=sha256:b412caa66f72040e6d268491a59f2c43bf03eb6c96dd8f0307829feb7fa2b6fb \
38+
--hash=sha256:b4f13750ce79751586ae2eb824ba7e1e8dba64784086c98cdbbcc6a42112ce0d \
39+
--hash=sha256:b64d8d4d17135e00c8e346e0a738deb17e754230d7e0810ac5012750bbd85a5a \
40+
--hash=sha256:ba10f8411898fc418a521833e014a77d3ca01c15b0c6cdcce6a0d2897e6dbbdf \
41+
--hash=sha256:bd48227a919f1bafbdda0583705e547892342c26fb127219d60a5c36882609d1 \
42+
--hash=sha256:c1f9540be57940698ed329904db803cf7a402f3fc200bfe599334c9bd84a40b2 \
43+
--hash=sha256:c820a93b0255bc360f53eca31a0e676fd1101f673dda8da93454a12e23fc5f7a \
44+
--hash=sha256:ce47521a4754c8f4593837384bd3424880629f718d87c5d44f8ed763edd63543 \
45+
--hash=sha256:d042d24c90c41b54fd506da306759e06e568864df8ec17ccc17e9e884634fd00 \
46+
--hash=sha256:de749064336d37e340f640b05f24e9e3dd678c57318c7289d222a8a2f543e90c \
47+
--hash=sha256:e1dda9c7e08dc141e0247a5b8f49cf05984955246a327d4c48bda16821947b2f \
48+
--hash=sha256:e29554e2bef54a90aa5cc07da6ce955accb83f21ab5de01a62c8478897b264fd \
49+
--hash=sha256:e3143e4451880bed956e706a3220b4e5cf6172ef05fcc397f6f36a550b1dd868 \
50+
--hash=sha256:e8213002e427c69c45a52bbd94163084025f533a55a59d6f9c5b820774ef3303 \
51+
--hash=sha256:efd28d4e9cd7d7a8d39074a4d44c63eda73401580c5c76acda2ce969e0a38e83 \
52+
--hash=sha256:f0fd6321b839904e15c46e0d257fdd101dd7f530fe03fd6359c1ea63738703f3 \
53+
--hash=sha256:f1372f041402e37e5e633e586f62aa53de2eac8d98cbfb822806ce4bbefcb74d \
54+
--hash=sha256:f2618db89be1b4e05f7a1a847a9c1c0abd63e63a1607d892dd54668dd92faf87 \
55+
--hash=sha256:f447e6acb680fd307f40d3da4852208af94afdfab89cf850986c3ca00562f4fa \
56+
--hash=sha256:f92729c95468a2f4f15e9bb94c432a9229d0d50de67304399627a943201baa2f \
57+
--hash=sha256:f9f1adb22318e121c5c69a09142811a201ef17ab257a1e66ca3025065b7f53ae \
58+
--hash=sha256:fc0c5673685c508a142ca65209b4e79ed6740a4ed6b2267dbba90f34b0b3cfda \
59+
--hash=sha256:fc7b73d02efb0e18c000e9ad8b83480dfcd5dfd11065997ed4c6747470ae8915 \
60+
--hash=sha256:fd83c01228a688733f1ded5201c678f0c53ecc1006ffbc404db9f7a899ac6249 \
61+
--hash=sha256:fe27749d33bb772c80dcd84ae7e8df2adc920ae8297400dabec45f0dedb3f6de \
62+
--hash=sha256:fee4236c876c4e8369388054d02d0e9bb84821feb1a64dd59e137e6511a551f8
63+
# via stim
64+
stim==1.15.0 \
65+
--hash=sha256:0bb3757c69c9b16fd24ff7400b5cddb22017c4cae84fc4b7b73f84373cb03c00 \
66+
--hash=sha256:190c5a3c9cecdfae3302d02057d1ed6d9ce7910d2bcc2ff375807d8f8ec5494d \
67+
--hash=sha256:1f8ed62c8b257c1d6ae63f0611f49771b2aaa8986a276f94c2c607467bd5587e \
68+
--hash=sha256:2f64ab075e856040c3b4157a4f2caa329204d579cbd7c0c02c7247e5a78da5db \
69+
--hash=sha256:31c55fad7529d6ee508f268534eeca1433017f2e83082f88275bea362b94f30f \
70+
--hash=sha256:32a1b3d25c5154d17ee1e2f6c0051cbf8a1ea3babc12571231b8aa7191a5c82c \
71+
--hash=sha256:35e36d0479015b4dcb4261b8b68be85067cbd4bac5632bdfdb3ee3f8671d05a9 \
72+
--hash=sha256:3aa9ab2c82e111207515976b0561fb5a44a9834bcb7769cfd6c8fc66005e82c6 \
73+
--hash=sha256:41fa67434e9d841dbee785639b2766265753eec31cabaf7e6f47fbe3b06a1d9c \
74+
--hash=sha256:48525d92965cc65b61399a9e1fe1d7a8925981bb4430ef69866d4e5c67a77d16 \
75+
--hash=sha256:4c10d2022b3c4c245f5f421dbf01b012a4d04901df697d9aca69eaea329c8532 \
76+
--hash=sha256:614e042645a7a6af65942f610538b166205635e5eedeac2f41ecb589cd7bd40c \
77+
--hash=sha256:673a323402c266b1a1225565d69d31816c3d4a4c259383ed4fa9c15cacd12411 \
78+
--hash=sha256:6940dbab42507281dddc8dd7992e7ec36a2a2c4b5eaa340bfc577143251d1dc5 \
79+
--hash=sha256:6aadcdfb6f0f900bf7d66e815201ace8509926d1213019a2b87831d0eaef8362 \
80+
--hash=sha256:6e3b61a2d9dc4b4312f5cf2ccf9c9f7175fe13a12e5c08df99835c5275680919 \
81+
--hash=sha256:6f240c196f23126bfed79bd78de5baa1fdde9c8fbfe56de032a12657fc42da37 \
82+
--hash=sha256:810383267ed94091dd3f49c3bd45061dbdc4e0f7a766de6a8f0e62bee2edc494 \
83+
--hash=sha256:93fab5d7a113f9c0e8dd78a77ef083c654f3638fc9d160067fcdac1bb52af9ac \
84+
--hash=sha256:95236006859d6754be99629d4fb44788e742e962ac8c59caad421ca088f7350e \
85+
--hash=sha256:a1e8ee222b112f9df1b8fdc4a9d500957a5a6ccd789b34e955a05862aa211f9d \
86+
--hash=sha256:a49af2ffc5f18178cddb1ef0014568a7114f97fe9a12f2b905ab8e2158d40558 \
87+
--hash=sha256:bc55de6dca511a77dc5fc4ece750ae9afe8ab840455da60a119a61eb1269e338 \
88+
--hash=sha256:c095ba13da95223e6b55f5c3493d48a1c04926827b6d89ae4af426044633d710 \
89+
--hash=sha256:c5504454a7158c009e9270a9fce90f6e4b6007a5f62e0c30c5d750ce845db407 \
90+
--hash=sha256:d426e00afe21478828369df3aaa82905e710c5b1f72582ec45244e3739d6183d \
91+
--hash=sha256:d6d409d42899bf35cd949806231d382ee3e4f679dd0e960910b39207d2fbe62e \
92+
--hash=sha256:d94638feaac9d037690779c383592bb898eda9db460d23fc0652d10030d570c9 \
93+
--hash=sha256:e92d5be90f6c92bada6b5aea64dfe9c80813a06e1316a71d5a36203dd24492f5 \
94+
--hash=sha256:f0fb249f1a2897a22cbe4e0c2627abf49188cbbf19b942d4749972d1c3bdf12c \
95+
--hash=sha256:f6f7cd19a2a3bb3e494bb14e23a23c8c51afccf9f630d422c4242d2ed4917c2f \
96+
--hash=sha256:fb9465ab120837ecbd26b5af216a00715f04da087ddcfa09646892c8de720d09 \
97+
--hash=sha256:fc613f78bc88b4318d7f34f9fddacec52638c11b72cc618f911bdd7ca153f938 \
98+
--hash=sha256:fdd9e5ab85ba2fb113b8834422518f6e46a4aea2e0f6f7305cfc2ad0fcd07086
99+
# via -r src/py/requirements.in

0 commit comments

Comments
 (0)