ancient-france-42909
10/19/2023, 5:44 PMBUILD files to a loop rather than the parametrize for interpreter constraints we use now, since that's in a macro that sets __defaults__ . There's this ticket, but no activity on it, is this still a 2023 priority? I've been looking at the suggestions there, not sure I like any of them, tbh. The context manager one is a bit weird, it'd require just indenting all the file if you want to use __defaults__ (or some deeper magic in how that's handled). The **parametrize_group is also not great, since you can't use defaults with it. The parameterize_group kwarg to parametrize might break people's stuff, so it can't go in immediately...curved-television-6568
10/19/2023, 7:00 PMcurved-television-6568
10/19/2023, 7:02 PM**parametrize_group approach?
I can make it work in a backwards compatible way.
How would you want to use __defaults__ with it..?curved-television-6568
10/19/2023, 7:03 PM__defaults__, I guess you just omit that field from the group.. 😉curved-television-6568
10/19/2023, 7:08 PMcurved-television-6568
10/19/2023, 7:08 PMcurved-television-6568
10/19/2023, 7:17 PMancient-france-42909
10/21/2023, 7:18 PMparametrize doesn't accept a mix of kwargs and args? I guess with some magic, this can be made to be backwards compatible.
As for **parametrize_group, if that's just syntactic sugar, and not some magic to get it to work, I have no objection.
What we do is we have a function call at the top of our BUILD files that looks like this:
set_interpreter_constraints(supported_versions=["3_7", "3_10"], build_version="3_10")
That will set the __defaults__ for interpreter_constraints for tests and sources to 3.7 and 3.10 (tests parametrized, so it runs for both) and the pex_binary to 3.10.
If we couldn't use __defaults__ in a sensible and predictable manner, we couldn't use this, and literally every BUILD file we have uses it, and we only override in probably 10 (out of 300+)curved-television-6568
10/21/2023, 9:02 PM__defaults__, which makes sense now. So you could do:
__defaults__({python_sources: [parametrize("3_7", interpreter_constraints="3.7", ...), parametrize("3_10", ...)]})
The implication being, that you'd need two calls to __defaults__ if you want to provide both grouped parametrizations and regular field values to a particular target.
In general terms:
__defaults__({TARGET_TYPE(s): KWARGS_DICT | ARGS_LIST, ...})ancient-france-42909
10/21/2023, 9:11 PMparametrized_group was the syntactic sugar that... I don't remember who, mentioned, I wouldn't have any problem. I just think it should be obvious what that generates and be just an alternative to a well documented way of doing it 🙂curved-television-6568
10/21/2023, 9:11 PMparametrize does support mixing args and kwargs (I'm pretty sure). But, targets do currently not accept args, only kwargs, so opening up the args slot for targets to treat parametrize values as args differently is a new possibility. I'm no longer sure the **parametrize_group is a great idea (in light of the new args based one), which I'm currently in favor of..curved-television-6568
10/21/2023, 9:12 PMcurved-television-6568
10/21/2023, 9:12 PMancient-france-42909
10/21/2023, 9:13 PMparametrize won't work.curved-television-6568
10/21/2023, 9:13 PMcurved-television-6568
10/21/2023, 9:14 PMcurved-television-6568
10/21/2023, 9:15 PMcurved-television-6568
10/21/2023, 9:16 PMancient-france-42909
10/21/2023, 9:17 PMancient-france-42909
10/21/2023, 9:18 PMancient-france-42909
10/21/2023, 9:19 PMancient-france-42909
10/21/2023, 9:19 PMcurved-television-6568
10/21/2023, 9:19 PMancient-france-42909
10/21/2023, 9:20 PMcurved-television-6568
10/21/2023, 9:21 PMcurved-television-6568
10/21/2023, 9:22 PMancient-france-42909
10/21/2023, 9:24 PMresolves_to_interpreter_constraints, and that's why they want different resolves.curved-television-6568
10/21/2023, 9:26 PM# Creates four targets:
#
# example:tests@interpreter_constraints=py2,resolve=lock-a
# example:tests@interpreter_constraints=py2,resolve=lock-b
# example:tests@interpreter_constraints=py3,resolve=lock-a
# example:tests@interpreter_constraints=py3,resolve=lock-b
python_test(
name="tests",
source="tests.py",
interpreter_constraints=parametrize(py2=["==2.7.*"], py3=[">=3.6"]),
resolve=parametrize("lock-a", "lock-b"),
)
shows you'll have both resolves for both ICs in the commented part.. so it's not an example of what we're trying to solve here.. (which is a missing feature..)curved-television-6568
10/21/2023, 9:27 PMancient-france-42909
10/21/2023, 9:27 PMcurved-television-6568
10/21/2023, 9:28 PMancient-france-42909
10/21/2023, 9:28 PMancient-france-42909
10/21/2023, 9:32 PMcurved-television-6568
10/21/2023, 9:34 PMcurved-television-6568
10/21/2023, 9:35 PMancient-france-42909
10/21/2023, 9:35 PMancient-france-42909
10/21/2023, 9:38 PMcurved-television-6568
10/21/2023, 9:38 PMancient-france-42909
10/21/2023, 9:39 PMcurved-television-6568
10/21/2023, 9:39 PM