@@ -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