curved-policeman-2796
06/09/2023, 8:40 AMdef my_special_wrapper(**kwargs):
real_target(something=MY_SPECIAL_GLOBAL_VARIABLE, **kwargs)
and a BUILD file with something like
MY_SPECIAL_GLOBAL_VARIABLE = "something"
my_special_wrapper()
I've tried this and it raises a NameError
in the macro call. The error message it logs (see stack trace in 🧵) implies that MY_SPECIAL_GLOBAL_VARIABLE
maybe should be available.
My use case is that I want to wrap a number of target types to set python interpreter constraints across them consistently, and it would be nice if each of the wrapper macros could suck the value out of a single global variable in each BUILD file, rather than having to remember to pass it in to each macro call.curved-policeman-2796
06/09/2023, 8:42 AMAll registered symbols: ['MY_SPECIAL_GLOBAL_VARIABLE', ...
which implies that the value is there in the dict that's passed into exec
enough-analyst-54434
06/09/2023, 11:28 AMancient-france-42909
06/09/2023, 11:32 AMancient-france-42909
06/09/2023, 11:32 AMenough-analyst-54434
06/09/2023, 11:32 AMdef my_macro(ic: str, ...):
pex_binary(interpreter_constraints=[ic], ...)
BUILD file call site:
def curry_ic(...):
my_macro(ic=FIXED, ...)
curry_ic(name="bob", ...)
curry_ic(name="Jane", ...)
enough-analyst-54434
06/09/2023, 11:35 AMancient-france-42909
06/09/2023, 11:38 AMenough-analyst-54434
06/09/2023, 11:41 AM__defaults__(...)
?enough-analyst-54434
06/09/2023, 11:43 AMenough-analyst-54434
06/09/2023, 11:44 AMancient-france-42909
06/09/2023, 11:45 AMenough-analyst-54434
06/09/2023, 12:31 PM# We don't use the y target in this BUILD
x, _, z = my_macro("==3.11.*")
x(...)
x(name="bob", ...)
z(name="Jane", ...)
enough-analyst-54434
06/09/2023, 12:31 PMancient-france-42909
06/09/2023, 12:32 PM__defaults__
one seems the simplest so far. We won't even need to change the targets (int his case either, I guess, since you can override the builtin ones, I assume?)enough-analyst-54434
06/09/2023, 12:33 PMancient-france-42909
06/09/2023, 12:37 PM__defaults__
, we have a weird structure in places, with the sources and tests in different folders, we only need to do it for one BUILD file.curved-television-6568
06/09/2023, 12:49 PMancient-france-42909
06/09/2023, 12:50 PMcurved-television-6568
06/09/2023, 12:51 PMcurved-television-6568
06/09/2023, 12:56 PMcurved-television-6568
06/09/2023, 12:57 PMcurved-policeman-2796
06/09/2023, 12:58 PMpython_sources
targets and ~200 pex_binary
targets across ~300 BUILD files, adding support for 3.10 from the least-dependent targets up to the most-dependent. This is basically done now, but we'd also like to start dropping 3.7 support, and maybe think about testing out 3.11, and have realised that we have a LOT of copy/pasted boilerplate - which sometimes people get wrong (like forgetting to use parametrize
on python_tests
targets).curved-television-6568
06/09/2023, 12:59 PM__defaults__
could be a good option as long as the field values are not too dynamic in nature.curved-policeman-2796
06/09/2023, 1:02 PMcurved-policeman-2796
06/09/2023, 1:02 PMcurved-television-6568
06/09/2023, 1:05 PMcurved-television-6568
06/09/2023, 4:33 PMancient-france-42909
06/09/2023, 4:35 PMcurved-television-6568
06/09/2023, 4:36 PMcurved-television-6568
06/09/2023, 4:38 PM