RFC: poetry_install rule #340
Comments
I'm not a contributor, only a user of My question(s): Why I'd personally prefer to see the existing rules improved for standard If there is a desire for a "lockfile", it is perfectly valid to use a
I'm not saying I'd be against Of course, I'd be generally supportive of seeing |
IMO we should fix the Google baggage here, and make this a monorepo that houses as much high-quality, self-consistent stuff as the maintainer community has time to properly support. So yes to pip, poetry, pipenv, and other package managers, provided of course that we minimize the surface area to what's strictly needed. My understanding is that poetry is the only package manager that pins your transitive dependencies. It's not sufficient to just give the hashes of direct dependencies - you can still get a non-reproducible build if a newer version of a transitive dep is published and satisfies the semver constraints of the direct dependencies. If there isn't a file exhaustively listing the entire set of transitive dependencies, then it's not a sufficient guarantee IIUC. Anyway even if poetry were feature-compatible with other package managers, I think we should make the Bazel onramp less steep by supporting all common existing codebases including their dependency manifest files. |
Yes, there have been recent movements which finally start to open this as a possibility.
Probably off-topic to your RFC, but this is a common misconception. A fairly common way of "locking" a Additional thought: If it is decided to consolidate support for the various combinations of Python dependency management, package management and project management tools and specifications that are used in the ecosystem such as Finally: Good discussion. I'm only an interested party. Will be good to hear what the maintainers and others think. |
Ooh this is interesting to clear up! But pip-tools isn't part of the python distribution right? You'd still need to get that on your machine as a bootstrap step. Also it's not maintained by python core so it doesn't seem obviously more canonical than pipenv or poetry, it just predates them right? |
We used to use Pipenv with Bazel but abandoned it in favour of pip-tools because the former's locking behaviour wasn't good enough for us. So far I like that pip-tools does one thing, transitive locking, and does it well. It also means we keep our locked requirements 'out in the open' outside of Bazel's internals, which is nice when managing platform-dependent behaviour in Python's packaging ecosystem. Platform-dependent behaviour is my biggest reservation with the above. Delegating the locking to Poetry means you have low visibility on any platform inconsistency that arises. With pip-tools with have CI checks on the lock file that can detect platform inconsistency early. |
I've written a poetry_install rule and would like to upstream.
High-level design
From my reading of https://github.com/soniaai/rules_poetry it runs
pip
to download and install individual wheels, and I don't understand why you would do it that way.My proposal is that in a repository rule,
python poetry_bin.py install --no-interaction --no-ansi
in that working directory, with"POETRY_VIRTUALENVS_IN_PROJECT": "true",
in the envpy_library
targets. This program always runs after poetry so you can look at whatever you like on disk to mirror the dependency graph and sources into BUILD filesIt's simple and does exactly the same thing
poetry install
does outside of Bazel. Here's the prototype code: https://gist.github.com/alexeagle/9fd6684e9306cf741f246dd3518a48ecHow it should look for users
In
WORKSPACE
you should:(it has no transitive dependencies)
That should create a
@some_dir_deps
repository with these labels:@some_dir_deps//:all
- a conveniencepy_library
exposing all the dependencies, useful since there is no BUILD file generator and it matches existing semantics so it makes migration easier@some_dir_deps//pkg
- apy_library
providing thepkg
packageTODO: I need to figure out how "extras" should work - I think that's the reason pip makes you load a "requirements" helper function?
So you'd use it in your BUILD file:
(no
load
statement is required)Here's my plan:
poetry
folder--repository_cache
is shared among workers (maybe requires better documentation on bazel.build)The text was updated successfully, but these errors were encountered: