32
32
import logging .handlers
33
33
from functools import total_ordering
34
34
from os import readlink
35
- import platform
36
35
import re
37
36
import shlex
38
37
import shutil
@@ -630,6 +629,11 @@ def html_only(self):
630
629
self .select_output == "only-html" or self .quick or self .language .html_only
631
630
)
632
631
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
+
633
637
def run (self , http : urllib3 .PoolManager ) -> bool :
634
638
"""Build and publish a Python doc, for a language, and a version."""
635
639
start_time = perf_counter ()
@@ -737,20 +741,18 @@ def build(self):
737
741
python = self .venv / "bin" / "python"
738
742
sphinxbuild = self .venv / "bin" / "sphinx-build"
739
743
blurb = self .venv / "bin" / "blurb"
740
- # Disable CPython switchers, we handle them now:
741
-
742
- def is_mac ():
743
- return platform .system () == "Darwin"
744
744
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
+ )
754
756
run_with_logging (
755
757
[
756
758
"make" ,
@@ -767,9 +769,10 @@ def is_mac():
767
769
)
768
770
run (["mkdir" , "-p" , self .log_directory ])
769
771
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
+ )
773
776
logging .info ("Build done (%s)." , format_seconds (perf_counter () - start_time ))
774
777
775
778
def build_venv (self ):
@@ -817,42 +820,47 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
817
820
except subprocess .CalledProcessError as err :
818
821
logging .warning ("Can't change group of %s: %s" , target , str (err ))
819
822
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
+
855
862
if not self .quick :
863
+ # Copy archive files to /archives/
856
864
logging .debug ("Copying dist files." )
857
865
run (
858
866
[
0 commit comments