`shiv -c <script>` builds a broken pyz when the console script declares extras (e.g. `blackd`)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia da shiv.cli.find_entry_point, dove l’issue indica che viene selezionato il valore grezzo dello script console, e controlla come viene scritto in environment.json. Esamina i test esistenti per la gestione dell’entry point e aggiungi un caso di regressione per un valore con un marker extras finale. Il lavoro è completato quando il pyz creato memorizza un semplice module:attr ed esegue correttamente l’entry point blackd.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 118
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di linkedin/shiv
-
DuplicateOptionError when there is { in entry_points.txt fileForse già presa @Shubham-Padkonde l’ha presa 63 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
-
Multiple-interpreter zipappAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 30/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Tutte le issue di linkedin/shiv
Issue simili
-
Internal ErrorApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
frappe/frappe_docker#2071 ·
I maintainer di solito rispondono entro 1 giorno
-
bug python
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
traceloop/openllmetry#4717 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
The-Pocket/PocketFlow#161 ·
-
[Bug]: Webapp workspace fails to render in Safari — "Can't find variable: requestIdleCallback"Apertacomp/desktop P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#157702 ·
I maintainer di solito rispondono entro 1 giorno
-
scibench_physics / scibench_chemistry: a correct answer scores 0 when the unit has a power of tenForse già presa @BahaaMattar l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
EvolvingLMMs-Lab/lmms-eval#1699 ·
I maintainer di solito rispondono entro 1 giorno