https://pantsbuild.org/ logo
#general
Title
# general
e

enough-analyst-54434

07/11/2022, 9:13 PM
Don't try this at home:
Copy code
$ cat expose-builtins 
exec(f"from builtins {'IMPORT'.lower()} *")

$ cat macro-uses-builtins 
def foo(name=None):
  if not name:
     raise Exception("A name is required.")
  python_sources(name=name)
   
$ cat BUILD.example 
foo(name="jake")
foo()

$ ./pants --build-file-prelude-globs='*-builtins' list :
15:12:53.20 [ERROR] 1 Exception encountered:

Engine traceback:
  in select
  in pants.backend.project_info.list_targets.list_targets
  in pants.engine.internals.specs_rules.resolve_addresses_from_specs
  in pants.engine.internals.specs_rules.resolve_addresses_from_raw_specs
  in pants.engine.internals.specs_rules.addresses_from_raw_specs_without_file_owners
  in pants.engine.internals.build_files.ensure_address_family ()
  in pants.engine.internals.build_files.parse_address_family ()
Traceback (most recent call last):
  File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/mapper.py", line 47, in parse
    target_adaptors = parser.parse(filepath, build_file_content, extra_symbols, defaults)
  File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/parser.py", line 167, in parse
    exec(build_file_content, global_symbols)
  File "<string>", line 2, in <module>
  File "macro-uses-builtins", line 3, in foo
    raise Exception("A name is required.")
Exception: A name is required.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/selectors.py", line 705, in native_engine_generator_send
    res = func.send(arg)
  File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/build_files.py", line 181, in parse_address_family
    for fc in digest_contents
  File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/build_files.py", line 181, in <listcomp>
    for fc in digest_contents
  File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/mapper.py", line 49, in parse
    raise MappingError(f"Failed to parse ./{filepath}:\n{e}")
pants.base.exceptions.MappingError: Failed to parse ./BUILD.example:
A name is required.
😵 1