Creating a venv can run a local ensurepip.py
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start by reproducing the report with the supplied script on a tested CPython version, then trace how venv invokes ensurepip during environment creation. The issue links PR gh-160282, indicating work is already underway; the desired result is that a local .venv/ensurepip.py is not executed across the listed cases.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug report
When you run python -m venv .venv, and .venv/ensurepip.py already exists, the file gets run.
Repro script:
import os
from pathlib import Path
import subprocess
import sys
from tempfile import TemporaryDirectory
with TemporaryDirectory() as name:
root = Path(name)
home = root / "private"
home.mkdir(mode=0o700)
env = {k: v for k, v in os.environ.items() if not k.startswith("PYTHON")}
env["PIP_NO_INDEX"] = "1"
cases = [
("normal", [], [], True),
("isolated", ["-I"], [], True),
("without-pip", ["-I"], ["--without-pip"], False),
("clear-regular-directory", ["-I"], ["--clear"], False),
]
if len(sys.argv) > 1:
cases.append(("vscode", ["-I"], [], True))
for case, interpreter_options, venv_options, expected in cases:
project = root / case
target = project / ".venv"
target.mkdir(parents=True)
marker = home / case
(target / "ensurepip.py").write_text(
"import os, runpy, sys\n"
"from pathlib import Path\n"
f"Path({str(marker)!r}).write_text('bootstrap executed')\n"
"sys.path[:] = [s for s in sys.path if os.path.realpath(s) != os.getcwd()]\n"
"runpy.run_module('ensurepip', run_name='__main__')\n"
)
if case == "vscode":
arguments = [str(Path(sys.argv[1]).resolve())]
else:
arguments = ["-m", "venv", *venv_options, ".venv"]
command = [sys.executable, *interpreter_options, *arguments]
subprocess.run(command, env=env, cwd=project, check=True, timeout=90)
print(case, "marker", marker.exists(), flush=True)
assert marker.exists() is expected
CPython versions tested on:
3.12, 3.13, CPython main branch
Operating systems tested on:
macOS, Linux
Linked PRs
- gh-160282
- Lingua principale
- Python
- Stelle
- 77.7k
- Fork
- 38.3k
- Merge medio
- 13h 43m
- PR unite (30g)
- 704
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un 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 python/cpython
-
topic-socket type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python/cpython#160561 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
tests topic-profiling type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
python/cpython#160334 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
`iso2022_jp_3` encodes U+9B1D but decodes the result as U+9B1CForse già presa @kinqsradio l’ha presa 1 giorno fa. Apertaextension-modules type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Remove unused FVS_* macrosApertainterpreter-core type-feature
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
python/cpython#160109 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
extension-modules type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python/cpython#160001 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di python/cpython
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
pydot/pydot#601 · 4 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
letsencrypt/cp-cps#361 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
CI: startup_failure because callers grant fewer permissions than ledger-app-workflows@v1 declaresForse già presa @maykonmichel l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
LedgerHQ/app-boilerplate-rust#227 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
linuxmint/mintupdate#1107 ·