We've got a Bazel monorepo with all external python deps managed by ofiuco - one pyproject.toml + lock for the whole repo.
Works great for the usual py_binary /py_library case: targets just depend on @poetry//:<pkg> and it all resolves from the lock.
Some of our client-side tools I'd like to ship as wheels built with py_wheel. I don't particularly want to vendor deps into those wheels (size), so I list them as pinned runtime requirements (requires / Requires-Dist) - a subset of what's already in our lock.
So the annoying part that requirements list duplicates stuff the lock already knows - the names and the pinned versions.
I have to keep it in sync by hand, so it drifts (stale versions end up in the published wheel) and I're maintaining name/version in two places.
Example
# Direct deps pins copied by hand from the pyproject lock
requirements = [
"dep-a==1.2.3",
"dep-b==0.9.0",
"dep-c==1.33",
# ...
]
# Strip version + add the ofiuco repo to get the library deps
poetry_requirements = [
"@poetry//:" + x.split("=")[0]
for x in requirements
]
py_library(
name = "mytool_core",
srcs = glob(["mytool_core/**/*.py"]),
visibility = ["//:__subpackages__"],
deps = poetry_requirements,
)
py_package(
name = "mytool_pkg",
packages = ["myorg.mytool"],
deps = [":mytool_core"],
)
py_wheel(
name = "mytool_core_wheel",
distribution = "mytool_core",
entry_points = {
"console_scripts": ["mytool = myorg.mytool.mytool_core.main:main"],
},
platform = "any",
python_tag = "py3",
requires = requirements,
deps = [":mytool_pkg"],
)
Before I go build something: is there already a way (or a recommended pattern) in ofiuco to get a py_wheel's pinned requires straight from the lock, instead of copying the pins by hand? Just want to make sure I'm not reinventing the wheel here.
Thank you.
We've got a Bazel monorepo with all external python deps managed by ofiuco - one
pyproject.toml+ lock for the whole repo.Works great for the usual
py_binary/py_librarycase: targets just depend on@poetry//:<pkg>and it all resolves from the lock.Some of our client-side tools I'd like to ship as wheels built with
py_wheel. I don't particularly want to vendor deps into those wheels (size), so I list them as pinned runtime requirements (requires/Requires-Dist) - a subset of what's already in our lock.So the annoying part that
requirementslist duplicates stuff the lock already knows - the names and the pinned versions.I have to keep it in sync by hand, so it drifts (stale versions end up in the published wheel) and I're maintaining
name/versionin two places.Example
Before I go build something: is there already a way (or a recommended pattern) in ofiuco to get a
py_wheel's pinnedrequiresstraight from the lock, instead of copying the pins by hand? Just want to make sure I'm not reinventing the wheel here.Thank you.