5858 sentry_sdk .init ()
5959
6060VERSION = "19.0"
61-
61+ DEFAULT_SPHINX_VERSION = "2.3.1"
6262
6363if not hasattr (shlex , "join" ):
6464 # Add shlex.join if missing (pre 3.8)
7070class Version :
7171 STATUSES = {"EOL" , "security-fixes" , "stable" , "pre-release" , "in development" }
7272
73- def __init__ (self , name , branch , status ):
73+ def __init__ (self , name , branch , status , sphinx_version = DEFAULT_SPHINX_VERSION ):
7474 if status not in self .STATUSES :
7575 raise ValueError (
7676 "Version status expected to be in {}" .format (", " .join (self .STATUSES ))
7777 )
7878 self .name = name
7979 self .branch = branch
8080 self .status = status
81+ self .sphinx_version = sphinx_version
8182
8283 @property
8384 def url (self ):
@@ -93,11 +94,13 @@ def title(self):
9394)
9495
9596# EOL and security-fixes are not automatically built, no need to remove them
96- # from the list.
97+ # from the list, this way we can still rebuild them manually as needed.
98+ # Please pin the sphinx_versions of EOL and security-fixes, as we're not maintaining
99+ # their doc, they don't follow Sphinx deprecations.
97100VERSIONS = [
98- Version ("2.7" , "2.7" , "EOL" ),
99- Version ("3.5" , "3.5" , "security-fixes" ),
100- Version ("3.6" , "3.6" , "security-fixes" ),
101+ Version ("2.7" , "2.7" , "EOL" , sphinx_version = "2.3.1" ),
102+ Version ("3.5" , "3.5" , "security-fixes" , sphinx_version = "1.8.4" ),
103+ Version ("3.6" , "3.6" , "security-fixes" , sphinx_version = "2.3.1" ),
101104 Version ("3.7" , "3.7" , "stable" ),
102105 Version ("3.8" , "3.8" , "stable" ),
103106 Version ("3.9" , "3.9" , "pre-release" ),
@@ -455,6 +458,25 @@ def build_one(
455458 logging .info ("Build done for version: %s, language: %s" , version .name , language .tag )
456459
457460
461+ def build_venv (build_root , version ):
462+ """Build a venv for the specific version.
463+ This is used to pin old Sphinx versions to old cpython branches.
464+ """
465+ requirements = [
466+ "blurb" ,
467+ "jieba" ,
468+ "python-docs-theme" ,
469+ "sphinx=={}" .format (version .sphinx_version ),
470+ ]
471+ venv_path = os .path .join (build_root , "venv-with-sphinx-" + version .sphinx_version )
472+ shell_out (["python3" , "-m" , "venv" , venv_path ])
473+ shell_out (
474+ [os .path .join (venv_path , "bin" , "python" ), "-m" , "pip" , "install" ]
475+ + requirements
476+ )
477+ return venv_path
478+
479+
458480def copy_build_to_webroot (
459481 build_root ,
460482 version ,
@@ -469,6 +491,7 @@ def copy_build_to_webroot(
469491 logging .info (
470492 "Publishing start for version: %s, language: %s" , version .name , language .tag
471493 )
494+ Path (www_root ).mkdir (parents = True , exist_ok = True )
472495 checkout = os .path .join (
473496 build_root , version .name , "cpython-{lang}" .format (lang = language .tag )
474497 )
@@ -670,6 +693,7 @@ def setup_logging(log_directory):
670693 if sys .stderr .isatty ():
671694 logging .basicConfig (format = "%(levelname)s:%(message)s" , stream = sys .stderr )
672695 else :
696+ Path (log_directory ).mkdir (parents = True , exist_ok = True )
673697 handler = logging .handlers .WatchedFileHandler (
674698 os .path .join (log_directory , "docsbuild.log" )
675699 )
@@ -691,7 +715,6 @@ def main():
691715 if args .www_root :
692716 args .www_root = os .path .abspath (args .www_root )
693717 setup_logging (args .log_directory )
694- venv = os .path .join (args .build_root , "venv" )
695718 if args .branch :
696719 versions_to_build = [
697720 version
@@ -720,6 +743,7 @@ def main():
720743 scope .set_tag ("version" , version .name )
721744 scope .set_tag ("language" , language .tag )
722745 try :
746+ venv = build_venv (args .build_root , version )
723747 build_one (
724748 version ,
725749 args .quick ,
0 commit comments