Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/CConfig.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# **************************************************************************************************************
#
# Copyright 2020-2022 Robert Bosch Car Multimedia GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
61 changes: 61 additions & 0 deletions config/CExtendedSetup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# **************************************************************************************************************
#
# Copyright 2020-2022 Robert Bosch Car Multimedia GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,6 +24,9 @@
#
# --------------------------------------------------------------------------------------------------------------
#
# 21.02.2022 / XC-CT/ECA3-Queckenstedt
# Added add_htmldoc_to_wheel() to support wheel based distribution
#
# 30.09.2021 / XC-CI1/ECA3-Queckenstedt
# Added wrapper for error messages
#
Expand Down Expand Up @@ -186,6 +191,62 @@ def add_htmldoc_to_installation(self):
return SUCCESS
# eof def add_htmldoc_to_installation():

# --------------------------------------------------------------------------------------------------------------

def add_htmldoc_to_wheel(self):
"""Adds the package documentation in HTML format to the wheel folder inside build
"""
sHTMLOutputFolder = self.__oRepositoryConfig.Get('sHTMLOutputFolder')
sSetupBuildFolder = self.__oRepositoryConfig.Get('sSetupBuildFolder')
sPackageName = self.__oRepositoryConfig.Get('sPackageName')
if os.path.isdir(sHTMLOutputFolder) is False:
print()
printerror(f"Error: Missing html output folder '{sHTMLOutputFolder}'")
print()
return ERROR

# The desired destination path for the documentation is:
# <build>\bdist.win-amd64\wheel\<package name>\doc
# with <build> is already available by 'sSetupBuildFolder' in CConfig.
# I am not convinced that it's a good idea to have hard coded parts like 'bdist.win-amd64' within a path here.
# Therefore we search recursively the file system for a subfolder with name 'wheel/<package name>'. And that's it!
sTargetFolder = f"wheel/{sPackageName}"
sWheelDocDestPath = None
bBreak = False
for sRootFolder, listFolders, listFiles in os.walk(sSetupBuildFolder):
for sFolder in listFolders:
sPath = os.path.join(sRootFolder, sFolder)
sPathMod = sPath.replace("\\", "/")
if sPathMod.endswith(sTargetFolder):
sWheelDocDestPath = f"{sPathMod}/doc"
bBreak = True
break # for sFolder in listFolders:
# eof if sPathMod.endswith(sTargetFolder):
# eof for sFolder in listFolders:
if bBreak is True:
break # walk
# eof for sRootFolder, listFolders, listFiles in os.walk(sSetupBuildFolder):

if sWheelDocDestPath is None:
print()
printerror(f"Error: Not able to find '{sTargetFolder}' inside {sSetupBuildFolder}")
print()
return ERROR

shutil.copytree(sHTMLOutputFolder, sWheelDocDestPath)
if os.path.isdir(sWheelDocDestPath) is False:
print()
printerror(f"Error: html documentation not copied to local wheel folder '{sWheelDocDestPath}'")
print()
return ERROR

print(COLBY + f"Folder '{sHTMLOutputFolder}'")
print(COLBY + "copied to")
print(COLBY + f"'{sWheelDocDestPath}'")
print()
return SUCCESS
# eof def add_htmldoc_to_wheel():

# eof class CExtendedSetup():

# --------------------------------------------------------------------------------------------------------------
Expand Down
60 changes: 38 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# **************************************************************************************************************
#
# Copyright 2020-2022 Robert Bosch Car Multimedia GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -11,8 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


#
# **************************************************************************************************************
#
# setup.py
Expand Down Expand Up @@ -59,6 +60,10 @@
#
# --------------------------------------------------------------------------------------------------------------
#
# 21.02.2022 / XC-CT/ECA3-Queckenstedt
#
# "sdist bdist_wheel" maintenance: some steps moved from inside 'ExtendedInstallCommand' to outside
#
# 09.02.2022 / XC-CT/ECA3-Queckenstedt
# Suppressed generation of documents and installations in case of command line
# parameter is not 'install' and not 'build' (this enables printing the help only). (10.02.2022: and not 'sdist')
Expand Down Expand Up @@ -106,32 +111,27 @@ class ExtendedInstallCommand(install):

def run(self):

# Extended installation step 1/5 (documentation builder) moved to outside ExtendedInstallCommand because results are needed earlier

listCmdArgs = sys.argv
if ( ('install' in listCmdArgs) or ('build' in listCmdArgs) or ('sdist' in listCmdArgs) or ('bdist_wheel' in listCmdArgs) ):
print()
print(COLBY + "Extended setup (install) step 2/5: Deleting previous setup outputs (build, dist, <package name>.egg-info within repository)")
print()
nReturn = oExtendedSetup.delete_previous_build()
if nReturn != SUCCESS:
return nReturn
print()
print(COLBY + "Extended setup (install) step 3/5: Deleting previous package installation folder within site-packages") # (<package name> and <package name>_doc under <Python installation>\Lib\site-packages
print()
nReturn = oExtendedSetup.delete_previous_installation()
if nReturn != SUCCESS:
return nReturn
print(COLBY + "Extended setup (install) step 4/5: install.run(self)") # creates the build folder .\build
print(COLBY + "Extended setup step 4/5: install.run(self)") # creates the build folder .\build
print()
install.run(self) # TODO: What does install.run(self) return? How to realize error handling?
print()
print(COLBY + "Extended setup (install) step 5/5: Add html documentation to package installation folder") # (./doc/_build/html to <Python installation>\Lib\site-packages\<package name>_doc)
print()
nReturn = oExtendedSetup.add_htmldoc_to_installation()
if nReturn != SUCCESS:
return nReturn
print()
if 'bdist_wheel' in listCmdArgs:
print(COLBY + "Extended setup step 5/5: Add html documentation to local wheel folder inside build")
print()
nReturn = oExtendedSetup.add_htmldoc_to_wheel()
if nReturn != SUCCESS:
return nReturn
print()
else:
print(COLBY + "Extended setup step 5/5: Add html documentation to package installation folder") # (./doc/_build/html to <Python installation>\Lib\site-packages\<package name>_doc)
print()
nReturn = oExtendedSetup.add_htmldoc_to_installation()
if nReturn != SUCCESS:
return nReturn
print()
print(COLBG + "Extended installation done")
print()

Expand Down Expand Up @@ -174,17 +174,33 @@ def run(self):
print()
print(COLBY + "Entering extended installation")
print()

print(COLBY + "Extended setup step 1/5: Calling the documentation builder")
# (previously called inside ExtendedInstallCommand - but this is too late, because the content of the initially
# generated or updated README file is already needed for the long_description below.)
print()
nReturn = oExtendedSetup.gen_doc()
if nReturn != SUCCESS:
sys.exit(nReturn)

print(COLBY + "Extended setup step 2/5: Deleting previous setup outputs (build, dist, <package name>.egg-info within repository)")
print()
nReturn = oExtendedSetup.delete_previous_build()
if nReturn != SUCCESS:
sys.exit(nReturn)

if not 'bdist_wheel' in listCmdArgs:
print()
print(COLBY + "Extended setup step 3/5: Deleting previous package installation folder within site-packages") # (<package name> and <package name>_doc under <Python installation>\Lib\site-packages
print()
nReturn = oExtendedSetup.delete_previous_installation()
if nReturn != SUCCESS:
sys.exit(nReturn)

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
print()


# --------------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 3 additions & 1 deletion sphinx-makeall.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# **************************************************************************************************************
#
# Copyright 2020-2022 Robert Bosch Car Multimedia GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -11,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# **************************************************************************************************************
#
# sphinx-makeall.py
Expand Down