diff --git a/config/CConfig.py b/config/CConfig.py index 705350d6..055ceba3 100644 --- a/config/CConfig.py +++ b/config/CConfig.py @@ -1,3 +1,5 @@ +# ************************************************************************************************************** +# # Copyright 2020-2022 Robert Bosch Car Multimedia GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/config/CExtendedSetup.py b/config/CExtendedSetup.py index 26d3d14c..541501a5 100644 --- a/config/CExtendedSetup.py +++ b/config/CExtendedSetup.py @@ -1,3 +1,5 @@ +# ************************************************************************************************************** +# # Copyright 2020-2022 Robert Bosch Car Multimedia GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -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 # @@ -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: + # \bdist.win-amd64\wheel\\doc + # with 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/'. 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(): # -------------------------------------------------------------------------------------------------------------- diff --git a/setup.py b/setup.py index 3e36b422..93532637 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +# ************************************************************************************************************** +# # Copyright 2020-2022 Robert Bosch Car Multimedia GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -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 @@ -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') @@ -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, .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") # ( and _doc under \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 \Lib\site-packages\_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 \Lib\site-packages\_doc) + print() + nReturn = oExtendedSetup.add_htmldoc_to_installation() + if nReturn != SUCCESS: + return nReturn + print() print(COLBG + "Extended installation done") print() @@ -174,6 +174,7 @@ 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.) @@ -181,10 +182,25 @@ def run(self): nReturn = oExtendedSetup.gen_doc() if nReturn != SUCCESS: sys.exit(nReturn) + + print(COLBY + "Extended setup step 2/5: Deleting previous setup outputs (build, dist, .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") # ( and _doc under \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() + # -------------------------------------------------------------------------------------------------------------- diff --git a/sphinx-makeall.py b/sphinx-makeall.py index 8dea34bf..c995a7e9 100644 --- a/sphinx-makeall.py +++ b/sphinx-makeall.py @@ -1,3 +1,5 @@ +# ************************************************************************************************************** +# # Copyright 2020-2022 Robert Bosch Car Multimedia GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -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