--- a/setup.py Tue Apr 16 19:43:53 2019 +0200 +++ b/setup.py Wed Apr 17 19:44:50 2019 +0200 @@ -15,14 +15,15 @@ import subprocess import shutil import fnmatch +import datetime from setuptools import setup, find_packages -from distutils.command.install_data import install_data ###################################################################### ## some helper functions below ###################################################################### + def getVersion(): """ Function to get the version from file. @@ -37,7 +38,6 @@ del sys.argv[-1] else: # calculate according our version scheme (year.month) - import datetime today = datetime.date.today() version = "{0}.{1}".format(today.year - 2000, today.month) return version @@ -63,9 +63,13 @@ os.path.relpath(os.path.join(dirpath, fname), package)) return filesList + def getDataFiles(): """ - Return data_files in a platform dependent manner + Return data_files in a platform dependent manner. + + @return list containing the platform specific data files + @rtype list of tuples of (str, list of str) """ if sys.platform.startswith('linux'): dataFiles = [ @@ -91,40 +95,13 @@ return dataFiles ###################################################################### -## make Linux detect eric6 desktop files -###################################################################### - -class Eric6InstallDataWrapper(install_data): - """ - Class providing an install_data command wrapper to perform - post-installation tasks. - """ - def run(self): - """ - Public method to perform the data installation. - """ - # do the distutils install_data first - install_data.run(self) - - # now perform our post installation stuff - if sys.platform.startswith('linux'): - try: - subprocess.call(['update-desktop-database']) - except: - print("ERROR: unable to update desktop database", - file=sys.stderr) - -CmdClass = { - 'install_data': Eric6InstallDataWrapper, -} - -###################################################################### ## functions to prepare the sources for building ###################################################################### + def prepareInfoFile(fileName, version): """ - Function to prepare an Info.py file when installing from source. + Function to prepare an Info.py file. @param fileName name of the Python file containing the info (string) @param version version string for the package (string) @@ -158,6 +135,30 @@ shutil.copy(fileName + ".orig", fileName) +def prepareAppdataFile(fileName, version): + """ + Function to prepare a .appdata.xml file. + + @param fileName name of the .appdata.xml file (string) + @param version version string for the package (string) + """ + if not fileName: + return + + try: + os.rename(fileName, fileName + ".orig") + except EnvironmentError: + pass + f = open(fileName + ".orig", "r", encoding="utf-8") + text = f.read() + f.close() + text = text.replace("@VERSION@", version)\ + .replace("@DATE@", datetime.date.today().isoformat()) + f = open(fileName, "w") + f.write(text) + f.close() + + def cleanupSource(dirName): """ Cleanup the sources directory to get rid of leftover files @@ -225,23 +226,26 @@ Version = getVersion() sourceDir = os.path.join(os.path.dirname(__file__), "eric6") infoFileName = os.path.join(sourceDir, "UI", "Info.py") +appdataFileName = os.path.join(os.path.dirname(__file__), "linux", + "eric6.appdata.xml") if sys.argv[1].startswith("bdist"): # prepare the sources under "eric6" for building the wheel file - print("preparing the sources...") + print("preparing the sources...") # __IGNORE_WARNING_M801__ cleanupSource(sourceDir) compileUiFiles(sourceDir) prepareInfoFile(infoFileName, Version) - print("Preparation finished") + prepareAppdataFile(appdataFileName, Version) + print("Preparation finished") # __IGNORE_WARNING_M801__ setup( name="eric6", version=Version, description="eric6 is an integrated development environment for the" - " Python language.", + " Python language.", long_description="eric6 is an integrated development environment for the" - " Python language. It uses the PyQt5 bindings and the QScintilla2" - " editor widget. See https://eric-ide.python-projects.org for more" - " details.", + " Python language. It uses the PyQt5 bindings and the" + " QScintilla2 editor widget. See" + " https://eric-ide.python-projects.org for more details.", author="Detlev Offenbach", author_email="detlev@die-offenbachs.de", url="https://eric-ide.python-projects.org", @@ -296,7 +300,7 @@ ".e6h", ".api", ".bas" ".dat"] ) + ["i18n/eric6_de.qm", "i18n/eric6_en.qm", "i18n/eric6_es.qm", "i18n/eric6_ru.qm", - ] + ] }, entry_points={ "gui_scripts": [ @@ -322,18 +326,19 @@ "eric6_uipreviewer = eric6.eric6_uipreviewer:main", "eric6_unittest = eric6.eric6_unittest:main", ], - "console_scripts":[ + "console_scripts": [ "eric6_api = eric6.eric6_api:main", "eric6_doc = eric6.eric6_doc:main", "eric6_post_install = eric6.eric6_post_install:main" ], }, - cmdclass=CmdClass, ) -if os.path.exists(infoFileName + ".orig"): - try: - os.remove(infoFileName) - os.rename(infoFileName + ".orig", infoFileName) - except EnvironmentError: - pass +# cleanup +for fileName in [infoFileName, appdataFileName]: + if os.path.exists(fileName + ".orig"): + try: + os.remove(fileName) + os.rename(fileName + ".orig", fileName) + except EnvironmentError: + pass