Skip to content

Commit bcb4425

Browse files
committed
Recreate venv for each build
1 parent 3c18032 commit bcb4425

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

build_docs.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -804,24 +804,30 @@ def build(self) -> None:
804804
def build_venv(self) -> None:
805805
"""Build a venv for the specific Python version.
806806
807-
So we can reuse them from builds to builds, while they contain
808-
different Sphinx versions.
807+
The venv is recreated from scratch for every build: pip considers
808+
a requirement satisfied when the installed version number matches,
809+
even if the requirement is a direct URL now pointing at different
810+
code, so a reused venv can silently keep outdated packages
811+
(see python/cpython#153227).
809812
"""
810813
requirements = list(self.build_meta.dependencies)
811814
if self.includes_html:
812815
# opengraph previews
813816
requirements.append("matplotlib>=3")
814817

815-
venv_path = self.build_root / self.build_meta.venv_name
816-
venv.create(venv_path, symlinks=os.name != "nt", with_pip=True)
818+
venv_name = self.build_meta.venv_name
819+
if self.select_output is not None:
820+
# Never share a venv with a concurrent differently-selected
821+
# build, which may recreate it mid-build.
822+
venv_name += f"-{self.select_output}"
823+
venv_path = self.build_root / venv_name
824+
venv.create(venv_path, symlinks=os.name != "nt", with_pip=True, clear=True)
817825
run(
818826
(
819827
venv_path / "bin" / "python",
820828
"-m",
821829
"pip",
822830
"install",
823-
"--upgrade",
824-
"--upgrade-strategy=eager",
825831
self.theme,
826832
*requirements,
827833
),

0 commit comments

Comments
 (0)