Repository navigation
Conversation
|
This PR was prepared by an agent under human direction. Review comments are triaged by the human author; agent-drafted replies and changes are reviewed and approved by the author before posting. This is an agent-generated comment reviewed and approved by the user. |
Generating console script entry points via Python requires executing a full Python binary during `py_console_script_gen` actions. Add `//crates/py_console_script_gen:py_console_script_gen_lib` with an `entry_points.txt` reader and PEP 503 distribution name normalizer, register `py_console_script_gen` on `shrubbery`, and wire the rule to `get_shrubbery_tool`.
| } | ||
|
|
||
| /// Expands `@flagfile` arguments into `OsString` values via `argfile`. | ||
| pub fn expand_args<I, T>(args: I) -> Result<Vec<OsString>, String> |
There was a problem hiding this comment.
the parent pr has a similar function. reconcile.
There was a problem hiding this comment.
Reconciled in fe584c3: the per-crate expand_args is gone; like the parent PR this now calls argfile::expand_args_from(..., argfile::parse_fromfile, argfile::PREFIX) directly.
This is an agent-generated comment reviewed and approved by the user.
| match arg { | ||
| Short('h') | Long("help") => { | ||
| return Err( | ||
| "Usage: py_console_script_gen [--console-script <str>] --console-script-guess <str> [--shebang <str>] <ENTRY_POINTS_TXT> <OUT>" |
There was a problem hiding this comment.
same comment here as in parent pr.
several comments in the parent pr apply to this pr: fix and reconcile
There was a problem hiding this comment.
Applied in fe584c3: USAGE constant + Cli::Help, keep-sorted flags module, anyhow errors with {err:#}, long-only arguments with a single arg.unexpected() fall-through, run_with_options folded into run(&Options). The same conventions are folded into every later level of the stack (03–07) so the whole stack now shares one arg-parsing shape.
This is an agent-generated comment reviewed and approved by the user.
| ); | ||
| } | ||
| Long("console-script") => { | ||
| let val = parser |
There was a problem hiding this comment.
similar comment here as in parent pr: this same logic is done by almost all the sub commands. reconcile/unify arg parsing logic for whole stack
There was a problem hiding this comment.
Unified across the stack in fe584c3 (and the corresponding commits on 03–07): every subcommand now uses the identical argfile → lexopt::Parser → flags::* match → bail!(arg.unexpected()) pattern with anyhow ? instead of per-call map_err chains; parser.value()?.string()? is the only per-flag logic left.
This is an agent-generated comment reviewed and approved by the user.
| if trimmed.is_empty() || trimmed.starts_with(['#', ';']) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
a prior PR mentioned using chaining of iterators to do this type of pre-filtering: respect that. apply throughout stack
There was a problem hiding this comment.
Done in b27e846: parse_console_scripts now pre-filters with lines().map(trim).filter(!empty && !comment) instead of the continue guard. The only other continue-style pre-filter in the stack was sanitize_extract_path in 03 (extract_wheel_files), which now uses split(...).filter(...) + extend.
This is an agent-generated comment reviewed and approved by the user.
| format!( | ||
| "{shebang_prefix}import sys | ||
|
|
||
| # See @rules_python//python/private:py_console_script_gen.py for explanation |
There was a problem hiding this comment.
this comment is outdated
There was a problem hiding this comment.
Fixed in b27e846: the generated script now says # See @rules_python//crates/py_console_script_gen for explanation, and the sys.path explanation from the Python module's docstring is carried over into this crate's module docs so the pointer stays meaningful once the Python fallback goes away.
This is an agent-generated comment reviewed and approved by the user.
Use argfile's parse_fromfile directly instead of a per-crate flagfile wrapper, adopt the USAGE constant, flags module, anyhow errors, and long-only arguments used by the other shrubbery subcommands, and fold run_with_options into run(&Options).
727ea34 to
fe584c3
Compare
Pre-filter blank and comment lines via lines().map().filter() instead of early continue guards, and point the generated script's comment at this crate (with the sys.path explanation carried over into the crate docs) now that the Python module is only a fallback.
Use argfile's parse_fromfile directly instead of a per-crate flagfile
wrapper, adopt the USAGE constant, flags module, anyhow errors, and
long-only arguments used by the other shrubbery subcommands, and fold
run_with_options into run(&Options).