3232import logging .handlers
3333from functools import total_ordering
3434from os import readlink
35- import platform
3635import re
3736import shlex
3837import shutil
@@ -630,6 +629,11 @@ def html_only(self):
630629 self .select_output == "only-html" or self .quick or self .language .html_only
631630 )
632631
632+ @property
633+ def includes_html (self ):
634+ """Does the build we are running include HTML output?"""
635+ return self .select_output != "no-html"
636+
633637 def run (self , http : urllib3 .PoolManager ) -> bool :
634638 """Build and publish a Python doc, for a language, and a version."""
635639 start_time = perf_counter ()
@@ -737,20 +741,18 @@ def build(self):
737741 python = self .venv / "bin" / "python"
738742 sphinxbuild = self .venv / "bin" / "sphinx-build"
739743 blurb = self .venv / "bin" / "blurb"
740- # Disable CPython switchers, we handle them now:
741-
742- def is_mac ():
743- return platform .system () == "Darwin"
744744
745- run (
746- ["sed" , "-i" ]
747- + (["" ] if is_mac () else [])
748- + ["s/ *-A switchers=1//" , self .checkout / "Doc" / "Makefile" ]
749- )
750- self .version .setup_indexsidebar (
751- self .versions ,
752- self .checkout / "Doc" / "tools" / "templates" / "indexsidebar.html" ,
753- )
745+ if self .includes_html :
746+ # Disable CPython switchers, we handle them now:
747+ run (
748+ ["sed" , "-i" ]
749+ + (["" ] if sys .platform == "darwin" else [])
750+ + ["s/ *-A switchers=1//" , self .checkout / "Doc" / "Makefile" ]
751+ )
752+ self .version .setup_indexsidebar (
753+ self .versions ,
754+ self .checkout / "Doc" / "tools" / "templates" / "indexsidebar.html" ,
755+ )
754756 run_with_logging (
755757 [
756758 "make" ,
@@ -767,9 +769,10 @@ def is_mac():
767769 )
768770 run (["mkdir" , "-p" , self .log_directory ])
769771 run (["chgrp" , "-R" , self .group , self .log_directory ])
770- setup_switchers (
771- self .versions , self .languages , self .checkout / "Doc" / "build" / "html"
772- )
772+ if self .includes_html :
773+ setup_switchers (
774+ self .versions , self .languages , self .checkout / "Doc" / "build" / "html"
775+ )
773776 logging .info ("Build done (%s)." , format_seconds (perf_counter () - start_time ))
774777
775778 def build_venv (self ):
@@ -817,42 +820,47 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
817820 except subprocess .CalledProcessError as err :
818821 logging .warning ("Can't change group of %s: %s" , target , str (err ))
819822
820- changed = changed_files (self .checkout / "Doc" / "build" / "html" , target )
821- logging .info ("Copying HTML files to %s" , target )
822- run (
823- [
824- "chown" ,
825- "-R" ,
826- ":" + self .group ,
827- self .checkout / "Doc" / "build" / "html/" ,
828- ]
829- )
830- run (["chmod" , "-R" , "o+r" , self .checkout / "Doc" / "build" / "html" ])
831- run (
832- [
833- "find" ,
834- self .checkout / "Doc" / "build" / "html" ,
835- "-type" ,
836- "d" ,
837- "-exec" ,
838- "chmod" ,
839- "o+x" ,
840- "{}" ,
841- ";" ,
842- ]
843- )
844- run (
845- [
846- "rsync" ,
847- "-a" ,
848- "--delete-delay" ,
849- "--filter" ,
850- "P archives/" ,
851- str (self .checkout / "Doc" / "build" / "html" ) + "/" ,
852- target ,
853- ]
854- )
823+ changed = []
824+ if self .includes_html :
825+ # Copy built HTML files to webroot (default /srv/docs.python.org)
826+ changed = changed_files (self .checkout / "Doc" / "build" / "html" , target )
827+ logging .info ("Copying HTML files to %s" , target )
828+ run (
829+ [
830+ "chown" ,
831+ "-R" ,
832+ ":" + self .group ,
833+ self .checkout / "Doc" / "build" / "html/" ,
834+ ]
835+ )
836+ run (["chmod" , "-R" , "o+r" , self .checkout / "Doc" / "build" / "html" ])
837+ run (
838+ [
839+ "find" ,
840+ self .checkout / "Doc" / "build" / "html" ,
841+ "-type" ,
842+ "d" ,
843+ "-exec" ,
844+ "chmod" ,
845+ "o+x" ,
846+ "{}" ,
847+ ";" ,
848+ ]
849+ )
850+ run (
851+ [
852+ "rsync" ,
853+ "-a" ,
854+ "--delete-delay" ,
855+ "--filter" ,
856+ "P archives/" ,
857+ str (self .checkout / "Doc" / "build" / "html" ) + "/" ,
858+ target ,
859+ ]
860+ )
861+
855862 if not self .quick :
863+ # Copy archive files to /archives/
856864 logging .debug ("Copying dist files." )
857865 run (
858866 [
0 commit comments