mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 03:20:08 +01:00
* make clean_sphinx a command function
* Move sphinx specific stuff to the sphinx command out of the etg command * Make it possible to not run the docs generator * Don't update some files unless they are newer or changed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@70221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
137
build.py
137
build.py
@@ -19,7 +19,7 @@ import urllib2
|
|||||||
|
|
||||||
from distutils.dep_util import newer, newer_group
|
from distutils.dep_util import newer, newer_group
|
||||||
from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip, findCmd, \
|
from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip, findCmd, \
|
||||||
phoenixDir, wxDir
|
phoenixDir, wxDir, copyIfNewer
|
||||||
|
|
||||||
from sphinxtools.postprocess import SphinxIndexes, MakeHeadings, PostProcess, GenGallery
|
from sphinxtools.postprocess import SphinxIndexes, MakeHeadings, PostProcess, GenGallery
|
||||||
|
|
||||||
@@ -54,30 +54,32 @@ def usage():
|
|||||||
print """\
|
print """\
|
||||||
Usage: ./build.py [command(s)] [options]
|
Usage: ./build.py [command(s)] [options]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
N.N NN Major.Minor version number of the Python to use to run
|
N.N NN Major.Minor version number of the Python to use to run
|
||||||
the other commands. Default is 2.7
|
the other commands. Default is 2.7
|
||||||
dox Run Doxygen to produce the XML file used by ETG scripts
|
dox Run Doxygen to produce the XML file used by ETG scripts
|
||||||
doxhtml Run Doxygen to create the HTML documetation for wx
|
doxhtml Run Doxygen to create the HTML documetation for wx
|
||||||
touch 'touch' the etg files so they will all get run in the
|
touch 'touch' the etg files so they will all get run in the
|
||||||
next build
|
next build
|
||||||
etg Run the ETG scripts that are out of date to update their
|
etg Run the ETG scripts that are out of date to update their
|
||||||
SIP files
|
SIP files
|
||||||
sphinx Run the documentation building process using Sphinx (this
|
sphinx Run the documentation building process using Sphinx (this
|
||||||
needs to be done after dox and etg)
|
needs to be done after dox and etg)
|
||||||
sip Run sip
|
sip Run sip
|
||||||
test Run the unit test suite
|
test Run the unit test suite
|
||||||
test_* Run just one test module
|
test_* Run just one test module
|
||||||
|
|
||||||
build_wx Do the wxWidgets part of the build
|
build_wx Do the wxWidgets part of the build
|
||||||
build_py Build wxPython only
|
build_py Build wxPython only
|
||||||
build Build both wxWidgets and wxPython
|
build Build both wxWidgets and wxPython
|
||||||
|
|
||||||
bdist Create a binary release of wxPython Phoenix
|
bdist Create a binary release of wxPython Phoenix
|
||||||
|
|
||||||
clean_wx Clean the wx parts of the build
|
clean_wx Clean the wx parts of the build
|
||||||
clean_py Clean the wxPython parts of the build
|
clean_py Clean the wxPython parts of the build
|
||||||
clean Clean both wx and wxPython
|
clean_sphinx Clean the sphinx files
|
||||||
|
|
||||||
|
clean Clean wx, wxPython and Sphinx
|
||||||
"""
|
"""
|
||||||
# cleanall Clean both wx and wxPython, and a little extra scrubbing
|
# cleanall Clean both wx and wxPython, and a little extra scrubbing
|
||||||
|
|
||||||
@@ -114,7 +116,7 @@ def main(args):
|
|||||||
testOne(cmd, options, args)
|
testOne(cmd, options, args)
|
||||||
elif cmd in ['dox', 'doxhtml', 'etg', 'sip', 'touch', 'test',
|
elif cmd in ['dox', 'doxhtml', 'etg', 'sip', 'touch', 'test',
|
||||||
'build_wx', 'build_py', 'build', 'bdist',
|
'build_wx', 'build_py', 'build', 'bdist',
|
||||||
'clean', 'clean_wx', 'clean_py', 'cleanall',
|
'clean', 'clean_wx', 'clean_py', 'cleanall', 'clean_sphinx',
|
||||||
'sphinx']:
|
'sphinx']:
|
||||||
function = globals()[cmd]
|
function = globals()[cmd]
|
||||||
function(options, args)
|
function(options, args)
|
||||||
@@ -263,7 +265,8 @@ def makeOptionParser():
|
|||||||
("unicode", (True, "Build wxPython with unicode support (always on for wx2.9)")),
|
("unicode", (True, "Build wxPython with unicode support (always on for wx2.9)")),
|
||||||
("waf", (False, "Use waf to build the bindings.")),
|
("waf", (False, "Use waf to build the bindings.")),
|
||||||
("verbose", (False, "Print out more information.")),
|
("verbose", (False, "Print out more information.")),
|
||||||
("upload_package", (False, "Upload package to nightly server.")),
|
("nodoc", (False, "Do not run the default docs generator")),
|
||||||
|
("upload_package", (False, "Upload bdist package to nightly server.")),
|
||||||
]
|
]
|
||||||
|
|
||||||
parser = optparse.OptionParser("build options:")
|
parser = optparse.OptionParser("build options:")
|
||||||
@@ -425,9 +428,10 @@ def etg(options, args):
|
|||||||
msg('Running command: etg')
|
msg('Running command: etg')
|
||||||
pwd = pushDir(phoenixDir())
|
pwd = pushDir(phoenixDir())
|
||||||
|
|
||||||
sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
|
# TODO: Better support for selecting etg cmd-line flags...
|
||||||
|
flags = '--sip'
|
||||||
clean_sphinx(sphinxDir, full=True)
|
if options.nodoc:
|
||||||
|
flags += ' --nodoc'
|
||||||
|
|
||||||
etgfiles = glob.glob('etg/_*.py')
|
etgfiles = glob.glob('etg/_*.py')
|
||||||
for script in etgfiles:
|
for script in etgfiles:
|
||||||
@@ -441,39 +445,15 @@ def etg(options, args):
|
|||||||
if hasattr(ns, 'OTHERDEPS'):
|
if hasattr(ns, 'OTHERDEPS'):
|
||||||
deps += ns.OTHERDEPS
|
deps += ns.OTHERDEPS
|
||||||
|
|
||||||
# run the script if any dependencies are newer
|
# run the script only if any dependencies are newer
|
||||||
if newer_group(deps, sipfile):
|
if newer_group(deps, sipfile):
|
||||||
runcmd('%s %s --sip' % (PYTHON, script))
|
runcmd('%s %s %s' % (PYTHON, script, flags))
|
||||||
|
|
||||||
# Copy the rst files into txt files
|
|
||||||
restDir = os.path.join(sphinxDir, 'rest_substitutions', 'overviews')
|
|
||||||
rstFiles = glob.glob(restDir + '/*.rst')
|
|
||||||
|
|
||||||
for rst in rstFiles:
|
|
||||||
rstName = os.path.split(rst)[1]
|
|
||||||
txt = os.path.join(sphinxDir, os.path.splitext(rstName)[0] + '.txt')
|
|
||||||
shutil.copyfile(rst, txt)
|
|
||||||
|
|
||||||
SphinxIndexes(sphinxDir)
|
|
||||||
GenGallery()
|
|
||||||
|
|
||||||
|
|
||||||
def clean_sphinx(sphinxDir, full=True):
|
|
||||||
|
|
||||||
sphinxfiles = []
|
|
||||||
|
|
||||||
if full:
|
|
||||||
sphinxfiles = glob.glob(sphinxDir + '/*.txt')
|
|
||||||
sphinxfiles += glob.glob(sphinxDir + '/*.inc')
|
|
||||||
|
|
||||||
pklfiles = glob.glob(sphinxDir + '/*.pkl')
|
|
||||||
lstfiles = glob.glob(sphinxDir + '/*.lst')
|
|
||||||
|
|
||||||
for f in sphinxfiles + pklfiles + lstfiles:
|
|
||||||
os.remove(f)
|
|
||||||
|
|
||||||
|
|
||||||
def sphinx(options, args):
|
def sphinx(options, args):
|
||||||
|
msg('Running command: sphinx')
|
||||||
|
pwd = pushDir(phoenixDir())
|
||||||
|
|
||||||
sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
|
sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
|
||||||
|
|
||||||
@@ -484,24 +464,33 @@ def sphinx(options, args):
|
|||||||
if not textFiles:
|
if not textFiles:
|
||||||
raise Exception('No documentation files found. Please run "build.py touch etg" first')
|
raise Exception('No documentation files found. Please run "build.py touch etg" first')
|
||||||
|
|
||||||
todos = os.path.join(phoenixDir(), 'TODO.txt')
|
# Copy the rst files into txt files
|
||||||
migration_guide = os.path.join(phoenixDir(), 'docs', 'MigrationGuide.txt')
|
restDir = os.path.join(sphinxDir, 'rest_substitutions', 'overviews')
|
||||||
|
rstFiles = glob.glob(restDir + '/*.rst')
|
||||||
|
|
||||||
if os.path.isfile(migration_guide):
|
for rst in rstFiles:
|
||||||
shutil.copy(migration_guide, sphinxDir)
|
rstName = os.path.split(rst)[1]
|
||||||
|
txt = os.path.join(sphinxDir, os.path.splitext(rstName)[0] + '.txt')
|
||||||
if os.path.isfile(todos):
|
copyIfNewer(rst, txt)
|
||||||
shutil.copy(todos, sphinxDir)
|
|
||||||
|
|
||||||
|
SphinxIndexes(sphinxDir)
|
||||||
|
GenGallery()
|
||||||
|
|
||||||
|
todo = os.path.join(phoenixDir(), 'TODO.txt')
|
||||||
|
migration_guide = os.path.join(phoenixDir(), 'docs', 'MigrationGuide.txt')
|
||||||
|
copyIfNewer(todo, sphinxDir)
|
||||||
|
copyIfNewer(migration_guide, sphinxDir)
|
||||||
|
|
||||||
MakeHeadings()
|
MakeHeadings()
|
||||||
|
|
||||||
pwd = pushDir(sphinxDir)
|
pwd2 = pushDir(sphinxDir)
|
||||||
runcmd('make html')
|
runcmd('make html')
|
||||||
|
del pwd2
|
||||||
|
|
||||||
buildDir = os.path.join(sphinxDir, 'build')
|
buildDir = os.path.join(sphinxDir, 'build')
|
||||||
|
msg('Postprocesing sphinx...')
|
||||||
PostProcess(buildDir)
|
PostProcess(buildDir)
|
||||||
|
|
||||||
clean_sphinx(sphinxDir, full=False)
|
|
||||||
|
|
||||||
|
|
||||||
def sip(options, args):
|
def sip(options, args):
|
||||||
@@ -859,18 +848,42 @@ def clean_py(options, args):
|
|||||||
options.both = False
|
options.both = False
|
||||||
clean_py(options, args)
|
clean_py(options, args)
|
||||||
options.both = True
|
options.both = True
|
||||||
|
|
||||||
|
|
||||||
|
def clean_sphinx(options, args, full=True):
|
||||||
|
msg('Running command: clean_sphinx')
|
||||||
|
assert os.getcwd() == phoenixDir()
|
||||||
|
|
||||||
|
sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
|
||||||
|
sphinxfiles = []
|
||||||
|
|
||||||
|
if full:
|
||||||
|
sphinxfiles = glob.glob(sphinxDir + '/*.txt')
|
||||||
|
sphinxfiles += glob.glob(sphinxDir + '/*.inc')
|
||||||
|
|
||||||
|
pklfiles = glob.glob(sphinxDir + '/*.pkl')
|
||||||
|
lstfiles = glob.glob(sphinxDir + '/*.lst')
|
||||||
|
|
||||||
|
for f in sphinxfiles + pklfiles + lstfiles:
|
||||||
|
os.remove(f)
|
||||||
|
|
||||||
|
buildDir = os.path.join(sphinxDir, 'build')
|
||||||
|
if os.path.exists(buildDir):
|
||||||
|
shutil.rmtree(buildDir)
|
||||||
|
|
||||||
|
|
||||||
def clean(options, args):
|
def clean(options, args):
|
||||||
clean_wx(options, args)
|
clean_wx(options, args)
|
||||||
clean_py(options, args)
|
clean_py(options, args)
|
||||||
|
clean_sphinx(options, args)
|
||||||
|
|
||||||
|
|
||||||
def cleanall(options, args):
|
def cleanall(options, args):
|
||||||
# These take care of all the object, lib, shared lib files created by the
|
# These take care of all the object, lib, shared lib files created by the
|
||||||
# compilation part of build
|
# compilation part of build
|
||||||
clean_wx(options, args)
|
clean_wx(options, args)
|
||||||
clean_py(options, args)
|
clean_py(options, args)
|
||||||
|
clean_sphinx(options, args)
|
||||||
|
|
||||||
# Now also scrub out all of the SIP and C++ source files that are
|
# Now also scrub out all of the SIP and C++ source files that are
|
||||||
# generated by the Phoenix ETG system.
|
# generated by the Phoenix ETG system.
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import glob
|
|||||||
import fnmatch
|
import fnmatch
|
||||||
import tempfile
|
import tempfile
|
||||||
import commands
|
import commands
|
||||||
|
import shutil
|
||||||
|
|
||||||
from distutils.file_util import copy_file
|
from distutils.file_util import copy_file
|
||||||
from distutils.dir_util import mkpath
|
from distutils.dir_util import mkpath
|
||||||
@@ -586,3 +587,10 @@ def wxDir():
|
|||||||
assert WXWIN not in [None, '']
|
assert WXWIN not in [None, '']
|
||||||
return WXWIN
|
return WXWIN
|
||||||
|
|
||||||
|
|
||||||
|
def copyIfNewer(src, dest):
|
||||||
|
if os.path.isdir(dest):
|
||||||
|
dest = os.path.join(dest, os.path.basename(src))
|
||||||
|
if newer(src, dest):
|
||||||
|
shutil.copy(src, dest)
|
||||||
|
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ def getWrapperGenerator():
|
|||||||
|
|
||||||
|
|
||||||
def getDocsGenerator():
|
def getDocsGenerator():
|
||||||
if '--nodocs' in sys.argv:
|
if '--nodoc' in sys.argv:
|
||||||
import generators
|
import generators
|
||||||
return generators.StubbedDocsGenerator()
|
return generators.StubbedDocsGenerator()
|
||||||
elif '--sphinx' in sys.argv:
|
elif '--sphinx' in sys.argv:
|
||||||
|
|||||||
Reference in New Issue
Block a user