From d0fb6e9a3a08f5222eb812788f4451f853c2fa99 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Fri, 28 Jan 2022 23:49:23 +0100 Subject: [PATCH] Fixing deb building, putting changelog into cache for env without internet (e.g flatpak). --- LogarithmPlotter/helper.py | 12 ++++++++++-- MANIFEST.in | 1 + setup.py | 11 +++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/LogarithmPlotter/helper.py b/LogarithmPlotter/helper.py index 31fcebb..8ca4cbf 100644 --- a/LogarithmPlotter/helper.py +++ b/LogarithmPlotter/helper.py @@ -145,6 +145,14 @@ class Helper(QObject): @Slot() def fetchChangelog(self): - runnable = ChangelogFetcher(self) - QThreadPool.globalInstance().start(runnable) + changelog_cache_path = path.join(path.dirname(path.realpath(__file__), "CHANGELOG.md")) + if path.exists(changelog_cache_path): + # We have a cached version of the changelog, for env that don't have access to the internet. + f = open(changelog_cache_path); + self.changelogFetched.emit("".join(f.readlines()).strip()) + f.close() + else: + # Fetch it from the internet. + runnable = ChangelogFetcher(self) + ^QThreadPool.globalInstance().start(runnable) diff --git a/MANIFEST.in b/MANIFEST.in index ce9f6ba..7f5d041 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,5 @@ recursive-include LogarithmPlotter/qml *.qml *.js *.qdoc qmldir *.svg *.md LICENSE recursive-include LogarithmPlotter/i18n *.qm *.ts include LogarithmPlotter/ *.svg +include LogarithmPlotter/ *.md diff --git a/setup.py b/setup.py index 0463d1b..f3678be 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ import setuptools import os import sys +from shutil import copyfile print(sys.argv) @@ -41,7 +42,10 @@ if "PREFIX" not in os.environ and sys.platform == 'linux': rmdir("/usr/share/applications/test") os.environ["PREFIX"] = "/usr/share" except: - os.environ["PREFIX"] = os.environ["HOME"] + "/.local/share" + if ".pybuild" in os.environ["HOME"]: # Launchpad building. + os.environ["PREFIX"] = "/usr/share" + else: + os.environ["PREFIX"] = os.environ["HOME"] + "/.local/share" from LogarithmPlotter import __VERSION__ as pkg_version @@ -81,6 +85,7 @@ def package_data(): for d,folders,files in os.walk("LogarithmPlotter/i18n"): d = d[17:] pkg_data += [os.path.join(d, f) for f in files] + return pkg_data data_files = [] @@ -95,7 +100,6 @@ if sys.platform == 'linux': data_files.append((os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/', ['logplotter.svg'])) if len(sys.argv) > 1: if sys.argv[1] == "install": - from shutil import copyfile os.makedirs(os.environ["PREFIX"] + '/applications/', exist_ok=True) os.makedirs(os.environ["PREFIX"] + '/mime/packages/', exist_ok=True) os.makedirs(os.environ["PREFIX"] + '/icons/hicolor/scalable/mimetypes/', exist_ok=True) @@ -113,8 +117,7 @@ if sys.platform == 'linux': else: copyfile(current_dir + '/linux/eu.ad5001.LogarithmPlotter.metainfo.xml', os.environ["PREFIX"] + '/metainfo/eu.ad5001.LogarithmPlotter.metainfo.xml') - copyfile(current_dir + '/linux/logarithmplotter.desktop', - os.environ["PREFIX"] + '/applications/logarithmplotter.desktop') + #copyfile(current_dir + '/linux/logarithmplotter.desktop', os.environ["PREFIX"] + '/applications/logarithmplotter.desktop') elif sys.argv[1] == "uninstall": os.remove(os.environ["PREFIX"] + '/applications/logarithmplotter.desktop') os.remove(os.environ["PREFIX"] + '/mime/packages/x-logarithm-plot.xml')