Skip to content

Commit 63fc55b

Browse files
authored
allow macOS installer builds to package pre-built html docs (GH-20715)
build-installer now looks in its directory of source tarballs for a suitable html tarball of the same version. If so, it will unpack and use it rather than rebuilding the html format documentation set from the source repo. This is intended as a speedup for test builds of the installer. Files names must be in the same format as produced by the docs build for download, for example, `python-3.9.0b1-docs-html.tar.bz2`.
1 parent 3ff51d4 commit 63fc55b

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

Mac/BuildScript/build-installer.py

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,14 +1066,40 @@ def buildPythonDocs():
10661066
curDir = os.getcwd()
10671067
os.chdir(buildDir)
10681068
runCommand('make clean')
1069-
# Create virtual environment for docs builds with blurb and sphinx
1070-
runCommand('make venv')
1071-
runCommand('venv/bin/python3 -m pip install -U Sphinx==2.2.0')
1072-
runCommand('make html PYTHON=venv/bin/python')
1069+
1070+
# Search third-party source directory for a pre-built version of the docs.
1071+
# Use the naming convention of the docs.python.org html downloads:
1072+
# python-3.9.0b1-docs-html.tar.bz2
1073+
doctarfiles = [ f for f in os.listdir(DEPSRC)
1074+
if f.startswith('python-'+getFullVersion())
1075+
if f.endswith('-docs-html.tar.bz2') ]
1076+
if doctarfiles:
1077+
doctarfile = doctarfiles[0]
1078+
if not os.path.exists('build'):
1079+
os.mkdir('build')
1080+
# if build directory existed, it was emptied by make clean, above
1081+
os.chdir('build')
1082+
# Extract the first archive found for this version into build
1083+
runCommand('tar xjf %s'%shellQuote(os.path.join(DEPSRC, doctarfile)))
1084+
# see if tar extracted a directory ending in -docs-html
1085+
archivefiles = [ f for f in os.listdir('.')
1086+
if f.endswith('-docs-html')
1087+
if os.path.isdir(f) ]
1088+
if archivefiles:
1089+
archivefile = archivefiles[0]
1090+
# make it our 'Docs/build/html' directory
1091+
print(' -- using pre-built python documentation from %s'%archivefile)
1092+
os.rename(archivefile, 'html')
1093+
os.chdir(buildDir)
1094+
1095+
htmlDir = os.path.join('build', 'html')
1096+
if not os.path.exists(htmlDir):
1097+
# Create virtual environment for docs builds with blurb and sphinx
1098+
runCommand('make venv')
1099+
runCommand('venv/bin/python3 -m pip install -U Sphinx==2.2.0')
1100+
runCommand('make html PYTHON=venv/bin/python')
1101+
os.rename(htmlDir, docdir)
10731102
os.chdir(curDir)
1074-
if not os.path.exists(docdir):
1075-
os.mkdir(docdir)
1076-
os.rename(os.path.join(buildDir, 'build', 'html'), docdir)
10771103

10781104

10791105
def buildPython():

0 commit comments

Comments
 (0)