`shiv -c <script>` builds a broken pyz when the console script declares extras (e.g. `blackd`)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in shiv.cli.find_entry_point, where the issue says the raw console script value is selected, and inspect how it is written to environment.json. Check the existing tests for entry point handling and add a regression case for a value with a trailing extras marker. Done means the built pyz stores a plain module:attr and runs the blackd entry point successfully.
Written by the indexing model from the issue text.
Description
Summary
When a console script in entry_points.txt carries an extras marker, find_entry_point returns the raw value including the marker, and it is written verbatim into environment.json as entry_point. The build succeeds, but every run of the resulting pyz fails in import_string.
A real example is black's blackd. black 26.10.1's entry_points.txt contains:
[console_scripts]
black = black:patched_main
blackd = blackd:patched_main [d]
Reproduction (shiv main @ ff542cb, Python 3.12, macOS arm64)
shiv -q -c blackd -o blackd.pyz 'black[d]==26.10.1' # exit 0
unzip -p blackd.pyz environment.json | python -c "import json,sys; print(json.load(sys.stdin)['entry_point'])"
# blackd:patched_main [d]
python blackd.pyz --help; echo $?
Output:
File ".../blackd.pyz/_bootstrap/__init__.py", line 87, in import_string
ImportError: module 'blackd' has no attribute 'patched_main [d]'
1
Control: shiv -c black -o black.pyz 'black==26.10.1' (no extras on that script) works; python black.pyz --version prints black.pyz, 26.10.1 and exits 0.
Expected
Extras are not part of the import target. pip's generated bin/blackd script (in the same staged site-packages) is from blackd import patched_main and prints its usage for --help. importlib.metadata parses the same entry as module='blackd', attr='patched_main', extras=['d'], and ep.load() returns the function. The pyz should resolve to blackd:patched_main too.
Any console script declared with an extras marker hits this. -e blackd:patched_main works around it.
Proposed fix
Strip a trailing [...] extras group from the value in shiv.cli.find_entry_point at build time, so environment.json holds a plain module:attr. This is independent of #284 (which changes the ConfigParser delimiters in the same function). I have a small patch with a regression test and can open a PR if that approach is OK.
This issue was drafted with Claude Code (claude-opus-5-5); the results above are from the runs described.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 118
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from linkedin/shiv
-
DuplicateOptionError when there is { in entry_points.txt filePossibly taken @Shubham-Padkonde claimed this 63 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
GoogleCloudPlatform/professional-services-data-validator#1899 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mohanraj00/entelos#200 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
sweep
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bketelsen/truenas-mcp#77 ·
Maintainers usually reply within 1 day
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
sandbox-quantum/switch#2163 ·
Maintainers usually reply within 1 day