Windows: cached venv initialization fails on dangling package symlinks
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 45/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- python
- Domínio
- build-system
Direção de pesquisa
The failure is in _create_venv in python/private/python_bootstrap_template.txt, at the os.makedirs(dirname(venv_abs_path), exist_ok=True) call (around line 657). The issue's reproduction script execs that template and simulates a dangling directory symlink followed by a new one; start there. Done when the script's final assertions pass on Windows, with the stale link replaced by the required directory.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
🐞 bug report
Affected Rule
py_binary: _create_venv in
python/private/python_bootstrap_template.txt.
Is this a regression?
Nope. Present since Windows site-packages venv support. (Great feature by the way - saved us with 'awesome' windows path length lmitations)
Description
On Windows, a persistent venv contains a dangling
Lib/site-packages/annotated_types directory symlink into obsolete runfiles (Got obsolete through a python version upgrade).
The next initialization fails at:
os.makedirs(dirname(venv_abs_path), exist_ok=True)
The executable exits before creating the runtime symlink. The Bazel build
succeeds. Expected: replace the dangling link with the required directory.
🔬 Minimal Reproduction
Run this from a rules_python checkout on Windows. It exercises
_create_venv with the blocking state;
import sys
import tempfile
from pathlib import Path
template = Path("python/private/python_bootstrap_template.txt")
source = template.read_text(encoding="utf-8")
for placeholder, value in [
("%shebang%", "#!/usr/bin/env python3"),
("%stage2_bootstrap%", "unused.py"),
("%runtime_venv_symlinks%", ""),
]:
source = source.replace(placeholder, value)
bootstrap = {"__name__": "bootstrap_repro"}
saved_path = sys.path[:]
try:
exec(compile(source, str(template), "exec"), bootstrap)
finally:
sys.path[:] = saved_path
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
runfiles = root / "runfiles"
old = runfiles / "old/annotated_types"
old.mkdir(parents=True)
(old / "__init__.py").touch()
bootstrap.update(
EXTRACT_ROOT=str(root / "cache"),
PYTHON_BINARY="_main/_process.venv/Scripts/python.exe",
PYTHON_BINARY_ACTUAL=sys.executable,
RESOLVE_PYTHON_BINARY_AT_RUNTIME=False,
RUNTIME_VENV_SYMLINKS={
"Lib/site-packages/annotated_types": "old/annotated_types",
},
)
bootstrap["_create_venv"](str(runfiles), [])
old.rename(root / "retired-package")
new = runfiles / "new/annotated_types"
new.mkdir(parents=True)
(new / "__init__.py").touch()
bootstrap["RUNTIME_VENV_SYMLINKS"] = {
"Lib/site-packages/annotated_types/__init__.py":
"new/annotated_types/__init__.py",
}
bootstrap["_create_venv"](str(runfiles), [])
package = root / "cache/_main/_process.venv/Lib/site-packages/annotated_types"
assert not package.is_symlink()
assert (package / "__init__.py").is_symlink()
print("Cached regular package recovered successfully")
🔥 Exception or Error
File ".../python_bootstrap...", line 909, in main
python_program = _create_venv(runfiles_root, delete_dirs)
File ".../python_bootstrap...", line 657, in _create_venv
os.makedirs(dirname(venv_abs_path), exist_ok=True)
File "<frozen os>", line 228, in makedirs
FileExistsError: [WinError 183]
...\_process.venv\Lib\site-packages\annotated_types
🌍 Your Environment
Operating System: Windows 11 x86_64 (10.0.26200).
Output of bazel version:
Build label: 9.1.1
Rules_python version: c9c1794dab34cc50260cab4a7ddf96f023cff575
Anything else relevant? CPython 3.12.7; Windows symlinks enabled;
persistent RULES_PYTHON_EXTRACT_ROOT.
- Linguagem predominante
- Starlark
- Estrelas
- 688
- Forks
- 728
- Merge médio
- 1d 2h
- PRs com merge (30d)
- 99
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de bazel-contrib/rules_python
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
bazel-contrib/rules_python#4251 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
bazel-contrib/rules_python#4164 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
pip.parse ignores uv.lock dependency-edge platform markersTalvez já em andamento @kdelalic assumiu há 2 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 20/100
bazel-contrib/rules_python#4287 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
bazel-contrib/rules_python#4278 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 20/100
bazel-contrib/rules_python#4250 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de bazel-contrib/rules_python
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
maniator/verticopolis#1303 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
`@vanilla-extract/turbopack-plugin`: "getImageSize is not a function" with Next.js 16.4.x when a `.css.ts` file imports an imageTalvez já em andamento @aevarOrigo assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
vanilla-extract-css/vanilla-extract#1799 · 1 comentário ·
-
Cannot find symbol CTypedefTalvez já em andamento @pellico assumiu hoje. Abertabug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
-
Make PDAQP an optional extraAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
-
in progress priority: low shared
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
storytold/photocraft#8616 · 1 comentário ·
Mantenedores costumam responder em até 2 dias