feat(uv): Add a clean-sheet dependency implementation#650
Conversation
|
|
|
||
| for minor in MINORS: | ||
| selects.config_setting_group( | ||
| name = "is_{}{}{}".format(interpreter, major, minor), |
There was a problem hiding this comment.
generally %s is faster than .format because it avoids a function call and has simpler (faster) arg conversion. Also if you have only a single substitution it helps even more because you don't even need to construct a tuple. Up to you where to use it, but at least for the functions in the extension that are called repeatedly I would strongly consider it. (Honestly I pretty much always use it unless I have a complex/multiline template with 4+ args and/or using an arg multiple times)
dzbarsky
left a comment
There was a problem hiding this comment.
since you said you love nits...i left a bunch of nits. feel free to apply or disregard as you see fit!
| # We loop up to the second-to-last item to ensure we always have a 'next' stage. | ||
| for i, current_stage in enumerate(stages): | ||
| selects.config_setting_group( | ||
| name = "{}".format(current_stage.name), |
There was a problem hiding this comment.
nit: name = current_stage.name :)
| selects.config_setting_group( | ||
| name = "{}".format(current_stage.name), | ||
| match_any = [ | ||
| ":{}".format(current_stage.condition), |
There was a problem hiding this comment.
":" + current_Stage.condition or ":%s" % current_stage.condition are both faster and less chars :)
| """ | ||
| selects.config_setting_group( | ||
| name = "{}", | ||
| match_all = {}, |
There was a problem hiding this comment.
it might be a bit clearer to put the brackets in the expression here, especially since I think the way you did it I think the trailing ] isn't indented correctly? Here's a similar thing I did with build_deps here
| # Collect all hubs, ensure we have no dupes | ||
| for mod in module_ctx.modules: | ||
| for hub in mod.tags.declare_hub: | ||
| hub_specs.setdefault(hub.hub_name, {}) |
There was a problem hiding this comment.
I saw you use setdefault like this a bunch, I think you can tweak the pattern slightly to avoid repeated lookups:
hub_specs.setdefault(hub.hub_name, {})[mod.name] = 1
| problems = [] | ||
| for hub_name, modules in hub_specs.items(): | ||
| if len(modules.keys()) > 1: | ||
| problems.append( |
There was a problem hiding this comment.
I think you could combine this with the previous loop and make hub_specs store hub_name -> mod_name(just check if you already have an entry and add toproblems) instead of of hub_name -> mod_name -> 1`. I guess it would make it harder to handle 3 modules all using the same name, but meh? It would probably lead to simpler usage in the rest of the extension
| load(":parse_whl_name.bzl", "parse_whl_name") | ||
|
|
||
| def format_arms(d): | ||
| content = [" \"{}\": \"{}\"".format(k, v) for k, v in d.items()] |
There was a problem hiding this comment.
maybe clearer to use single quotes on the outside and/or repr the k/v to avoid inner ones?
| return [ | ||
| # FIXME: Need to generate PyInfo here | ||
| DefaultInfo( | ||
| files = depset([ |
There was a problem hiding this comment.
i guess you could create this depset once and reuse it below
4c2da1c to
82e6fc8
Compare
6505698 to
95a9045
Compare
|
TODO: Can we rip the uv toolchain out? |
ab53104 to
c8658ee
Compare
12139ec to
cb06830
Compare
|
, For later, more of Ignas' fine code we can leverage https://github.com/bazel-contrib/rules_python/pull/2692/files, bazel-contrib/rules_python#2856 |
3c07dd9 to
c654d0a
Compare
9eef6c9 to
5eb234d
Compare
99fde55 to
4694253
Compare
5e6a2a0 to
a02a226
Compare
2ee7aed to
517392f
Compare

Design doc
An implementation of pip based on consuming PEP-751 [1] like lockfiles. Specifically uv lockfiles, which contain internal dependency graph information that the PEP-751 specification labels optional.
Follows in the footsteps of rules_js's pnpm support by consuming a lockfile which contains enough information to produce materialize dependencies without performing any repository time operations which could be platform dependent.
Features
--editable-like workflowsconsole_scriptsentrypoints*Example
The active venv state can be overriden at the cli by specifying
--'@pip//venv=b'here for instance, or by using transitions to(re) set that same flag.Appendix
[1] https://peps.python.org/pep-0751/
[2] https://peps.python.org/pep-0751/#locking-build-requirements-for-sdists
Changes are visible to end-users: yes
To do list
uv_lockrulepip.parseinternally entirely--editable/ vendoring)rules_pythonequivalentrules_python's config settings for nowrules_python's config settings for now fix(toolchains): correctly register musl/freethreaded toolchains for workspace bazel-contrib/rules_python#3314Investigate implementing aThere isn't a great way to do this because dist-info is in our world part of the installed package, so any such target is just ignoring the PyInfo details on the fileset.dist_infotarget comparable to that whichrules_pythongeneratesrules_pythonall listpython_versiontransition consistency withrules_pythonrules_python's package name normalization so that migration is easier.rules_python@hub//package[:package]syntax?toml.bzlworkinguvdependencyTest plan
py_venv_tests covering that different versions of the same package can be concurrently configured via different venvspy_venv_testcovering that Airflow or another package with dependency cycles can be provisionedpy_venv_binaryembedded in and transitioned for a Linux OCI container across arch boundariespy_venv_testcovering overriding a pip dep with a 1stparty target