The only issue so far with `object` for `contrib_p...
# development
h
The only issue so far with
object
for
contrib_plugin
is that we need access to the target’s relative path (spec path). Does this mean I need to use
context_aware_object_factory
?
w
so… that might call for a builtin.
h
Meaning?
w
oh. you said
object
.
hm. yea, not sure.
h
Yeah, I have an
object
and everything works great, minus needing the spec path. I think CAFO handles this? A CAFO is just a fancy way to create something like an
object
, right?
w
the difference is that the context it receives allows it to declare targets
(…and also contains the relative path)
adding additional built in functions (or
objects
) to macro/BUILD file evaluation might satisfy these usecases.
h
Oh. Wait. We can just use
Path.cwd()
in this
contrib_setup_py
object!
w
i don’t think so… would get you the buildroot, afaik
h
Oh, hm. Sad
Can CAOFs not take additional arguments? This is my function:
Copy code
def contrib_setup_py(
    parse_context,
    name: str,
    description: str,
    build_file_aliases: bool = False,
    global_subsystems: bool = False,
    register_goals: bool = False,
    rules: bool = False,
    target_types: bool = False,
    additional_classifiers: Optional[List[str]] = None,
    **kwargs,
) -> PythonArtifact:
w
the parse context is passed to the outer thing, which returns a closure containing the inner thing.
sec. lemme find an example.
❤️ 1
so, a more modern example is actually this one:
src/python/pants/backend/python/python_requirements.py
which is the equivalent of:
Copy code
def outer(parse_context):
  def inner(requirements_relpath="requirements.txt"):
    # do things with the parse_context and my args
  return inner
the first call takes one arg and creates a callable
h
And the inner can still have any arbitrary args? I’m hoping in a BUILD file that you can say
contrib_setup_py(arg1=..., arg2=...)
w
yes
the inner callable (or
__call__
in the first case) is effectively directly exposed in the BUILD file.
❤️ 1
h
Okay, will try. Thank you!
It worked! Thanks for the help Stu 😄