Cleanup of the setup script
This commit is contained in:
@@ -12,7 +12,6 @@
|
|||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
#
|
#
|
||||||
# import os
|
|
||||||
# import sys
|
# import sys
|
||||||
# sys.path.insert(0, os.path.abspath("."))
|
# sys.path.insert(0, os.path.abspath("."))
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -4,27 +4,22 @@ import sys
|
|||||||
import subprocess
|
import subprocess
|
||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
##
|
# =========================================================================== #
|
||||||
# Build the Package
|
# Qt Assistant Documentation Builder
|
||||||
##
|
# =========================================================================== #
|
||||||
|
|
||||||
buildDocs = False
|
def buildQtDocs():
|
||||||
buildSample = False
|
"""This function will build the documentation as a Qt help file. The
|
||||||
|
file is then copied into the nw/assets/help directory and can be
|
||||||
|
included in builds.
|
||||||
|
|
||||||
if "qthelp" in sys.argv:
|
Depends on packages:
|
||||||
buildDocs = True
|
* pip install sphinx
|
||||||
sys.argv.remove("qthelp")
|
* pip install sphinx-rtd-theme
|
||||||
|
* pip install sphinxcontrib-qthelp
|
||||||
if "sample" in sys.argv:
|
|
||||||
buildSample = True
|
|
||||||
sys.argv.remove("sample")
|
|
||||||
|
|
||||||
##
|
|
||||||
# Qt Assistant Documentation
|
|
||||||
##
|
|
||||||
|
|
||||||
if buildDocs:
|
|
||||||
|
|
||||||
|
It also requires the qhelpgenerator to be available on the system.
|
||||||
|
"""
|
||||||
buildDir = os.path.join("docs", "build", "qthelp")
|
buildDir = os.path.join("docs", "build", "qthelp")
|
||||||
helpDir = os.path.join("nw", "assets", "help")
|
helpDir = os.path.join("nw", "assets", "help")
|
||||||
|
|
||||||
@@ -41,14 +36,14 @@ if buildDocs:
|
|||||||
try:
|
try:
|
||||||
subprocess.call(["make", "-C", "docs", "qthelp"])
|
subprocess.call(["make", "-C", "docs", "qthelp"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failed with error:")
|
print("QtHelp Build Error:")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
buildFail = True
|
buildFail = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.call(["qhelpgenerator", os.path.join(buildDir, inFile)])
|
subprocess.call(["qhelpgenerator", os.path.join(buildDir, inFile)])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failed with error:")
|
print("QtHelp Build Error:")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
buildFail = True
|
buildFail = True
|
||||||
|
|
||||||
@@ -56,7 +51,7 @@ if buildDocs:
|
|||||||
try:
|
try:
|
||||||
os.mkdir(helpDir)
|
os.mkdir(helpDir)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failed with error:")
|
print("QtHelp Build Error:")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
buildFail = True
|
buildFail = True
|
||||||
|
|
||||||
@@ -68,7 +63,7 @@ if buildDocs:
|
|||||||
os.rename(os.path.join(buildDir, outFile), os.path.join(helpDir, outFile))
|
os.rename(os.path.join(buildDir, outFile), os.path.join(helpDir, outFile))
|
||||||
os.rename(os.path.join(buildDir, datFile), os.path.join(helpDir, datFile))
|
os.rename(os.path.join(buildDir, datFile), os.path.join(helpDir, datFile))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Failed with error:")
|
print("QtHelp Build Error:")
|
||||||
print(str(e))
|
print(str(e))
|
||||||
buildFail = True
|
buildFail = True
|
||||||
|
|
||||||
@@ -80,11 +75,20 @@ if buildDocs:
|
|||||||
print("Documentation build: OK")
|
print("Documentation build: OK")
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
##
|
return
|
||||||
# Sample Project ZIP file
|
|
||||||
##
|
|
||||||
|
|
||||||
if buildSample:
|
# =========================================================================== #
|
||||||
|
# Sample Project ZIP File Builder
|
||||||
|
# =========================================================================== #
|
||||||
|
|
||||||
|
def buildSampleZip():
|
||||||
|
"""Bundle the sample project into a single zip file to be saved into
|
||||||
|
the nw/assets folder for further bundling into builds.
|
||||||
|
"""
|
||||||
|
print("")
|
||||||
|
print("Building Sample ZIP File")
|
||||||
|
print("========================")
|
||||||
|
print("")
|
||||||
|
|
||||||
srcSample = "sample"
|
srcSample = "sample"
|
||||||
dstSample = os.path.join("nw", "assets", "sample.zip")
|
dstSample = os.path.join("nw", "assets", "sample.zip")
|
||||||
@@ -96,8 +100,10 @@ if buildSample:
|
|||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
with ZipFile(dstSample, "w") as zipObj:
|
with ZipFile(dstSample, "w") as zipObj:
|
||||||
|
print("Compressing: nwProject.nwx")
|
||||||
zipObj.write(os.path.join(srcSample, "nwProject.nwx"), "nwProject.nwx")
|
zipObj.write(os.path.join(srcSample, "nwProject.nwx"), "nwProject.nwx")
|
||||||
for docFile in os.listdir(os.path.join(srcSample, "content")):
|
for docFile in os.listdir(os.path.join(srcSample, "content")):
|
||||||
|
print("Compressing: content/%s" % docFile)
|
||||||
srcDoc = os.path.join(srcSample, "content", docFile)
|
srcDoc = os.path.join(srcSample, "content", docFile)
|
||||||
zipObj.write(srcDoc, "content/"+docFile)
|
zipObj.write(srcDoc, "content/"+docFile)
|
||||||
|
|
||||||
@@ -105,12 +111,33 @@ if buildSample:
|
|||||||
print("Error: Could not find sample project source directory.")
|
print("Error: Could not find sample project source directory.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
print("")
|
||||||
# Nothing more to do
|
print("Built file: %s" % dstSample)
|
||||||
sys.exit(0)
|
print("")
|
||||||
|
|
||||||
##
|
return
|
||||||
# Build the Package
|
|
||||||
##
|
|
||||||
|
|
||||||
setuptools.setup()
|
# =========================================================================== #
|
||||||
|
# Process Jobs
|
||||||
|
# =========================================================================== #
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
# Process non-standard jobs
|
||||||
|
|
||||||
|
if "qthelp" in sys.argv:
|
||||||
|
sys.argv.remove("qthelp")
|
||||||
|
buildQtDocs()
|
||||||
|
|
||||||
|
if "sample" in sys.argv:
|
||||||
|
sys.argv.remove("sample")
|
||||||
|
buildSampleZip()
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
# Nothing more to do
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Run the standard setup
|
||||||
|
setuptools.setup()
|
||||||
|
|
||||||
|
# END Main
|
||||||
|
|||||||
Reference in New Issue
Block a user