google / emboss

Emboss is a tool for generating code that reads and writes binary data structures.
Apache License 2.0
70 stars 21 forks source link

Move generate_grammar_md to data deps in docs_are_up_to_date_test #20

Closed AaronWebster closed 1 year ago

AaronWebster commented 2 years ago

generate_grammar_md is a py_binary and should be listed in data instead of deps.

reventlov commented 2 years ago

I think you're just trading a quasi-supported Bazel feature (import from a py_binary in deps) for an unsupported Bazel feature (import from a py_binary in data).

docs_are_up_to_date_test is importing generate_grammar_md.py, not invoking the generate_grammar_md binary. That's fine from a Python standpoint, but Bazel doesn't really support the notion of having a single .py file that can be either a binary's entry point or an importable module.

I think the proper fix is to move the guts of generate_grammar_md.py into a new .py, add a py_library rule for that new .py, and then have docs_are_up_to_date_test and generate_grammar_md use the new library.