From 92fd50d4479440b3bd56eca76a43c8c192953dde Mon Sep 17 00:00:00 2001 From: Ankur Sinha (Ankur Sinha Gmail) Date: Oct 11 2021 15:17:28 +0000 Subject: [PATCH 1/4] feat: install appdata and desktop file --- diff --git a/pyplane.spec b/pyplane.spec index f3b196e..278201d 100644 --- a/pyplane.spec +++ b/pyplane.spec @@ -17,12 +17,15 @@ Release: %autorelease License: GPLv3 URL: %{forgeurl} Source0: %{forgesource} +# Sent upstream https://github.com/TUD-RST/pyplane/pull/9 Source1: pyplane.metainfo.xml +Source2: pyplane.desktop BuildArch: noarch BuildRequires: python3-devel BuildRequires: libappstream-glib +BuildRequires: desktop-file-utils %if %{with tests} BuildRequires: %{py3_dist pytest} # bits not mentioned in install_requires @@ -57,16 +60,21 @@ sed -i -e '/sys.path.append/ d' -e 's/import core./import pyplane.core./' tests/ %pyproject_install %pyproject_save_files pyplane +install -p -m 0644 -Dt %{buildroot}/%{_metainfodir}/ %{SOURCE1} +desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE2} + %check %if %{with tests} %{pytest} %endif -appstream-util validate-relax --nonet %{buildroot}/pyplane.metainfo.xml +appstream-util validate-relax --nonet %{buildroot}/%{_metainfodir}/pyplane.metainfo.xml %files -f %{pyproject_files} %doc README.md AUTHORS %{_bindir}/pyplane +%{_metainfodir}/pyplane.metainfo.xml +%{_datadir}/applications/pyplane.desktop %changelog %autochangelog From 1372f3bb3c1b29e367419c8a56327a423351f375 Mon Sep 17 00:00:00 2001 From: Ankur Sinha (Ankur Sinha Gmail) Date: Oct 11 2021 15:18:08 +0000 Subject: [PATCH 2/4] feat: remove virtual provides, not needed --- diff --git a/pyplane.spec b/pyplane.spec index 278201d..8447114 100644 --- a/pyplane.spec +++ b/pyplane.spec @@ -38,9 +38,6 @@ BuildRequires: texlive-dvipng Recommends: texlive-latex Recommends: texlive-dvipng -# Add virtual provides to help users find it -Provides: python3-pyplane - %description %_description %prep From aafb0be39e0a4ed2708a296cf0dc2517b80b5af6 Mon Sep 17 00:00:00 2001 From: Ankur Sinha (Ankur Sinha Gmail) Date: Oct 11 2021 15:54:37 +0000 Subject: [PATCH 3/4] feat: add patch to log to XDG_DATA_DIR --- diff --git a/0001-feat-use-XDG_DATA_HOME-for-logging-file-on-Linux.patch b/0001-feat-use-XDG_DATA_HOME-for-logging-file-on-Linux.patch new file mode 100644 index 0000000..66ef80a --- /dev/null +++ b/0001-feat-use-XDG_DATA_HOME-for-logging-file-on-Linux.patch @@ -0,0 +1,54 @@ +From 4805d3f2158d94337c11c4e7970795a46bfdbe65 Mon Sep 17 00:00:00 2001 +From: "Ankur Sinha (Ankur Sinha Gmail)" +Date: Mon, 11 Oct 2021 16:34:33 +0100 +Subject: [PATCH] feat: use XDG_DATA_HOME for logging file on Linux + +On system installations, one cannot write to +`/usr/lib/pythonX.Y/site-packages` unless one always runs `pyplane` as +root (which is not suggested). On Linux, the `XDG_DATA_HOME` directory +should be used for user-specific data files, so the logging file is best +placed here. + +As the XDG base directory specification says, if `XDG_DATA_HOME` is not +defined, `$HOME/.local/share` should be used. + +References: +https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +--- + pyplane/core/Logging.py | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/pyplane/core/Logging.py b/pyplane/core/Logging.py +index c8a5fc8..8bc2fab 100644 +--- a/pyplane/core/Logging.py ++++ b/pyplane/core/Logging.py +@@ -23,13 +23,25 @@ Module implementing logging capabilities + import time + import os + import sys ++import platform + from PyQt5 import QtCore, QtWidgets, QtGui + + __author__ = 'Klemens Fritzsche' + + basedir = os.path.dirname(os.path.dirname(sys.modules.get(__name__).__file__)) +-defaultLogFileName = os.path.join(basedir, 'config','logmessages.txt') + ++if platform.system() == "Linux": ++ try: ++ datadir = os.environ["XDG_DATA_HOME"] + "/pyplane/" ++ except KeyError: ++ datadir = os.environ["HOME"] + "/.local/share/pyplane/" ++ try: ++ os.makedirs(datadir) ++ except FileExistsError: ++ pass ++ defaultLogFileName = os.path.join(datadir, 'logmessages.txt') ++else: ++ defaultLogFileName = os.path.join(basedir, 'config','logmessages.txt') + + class Logger(object): + """ +-- +2.33.0 + diff --git a/pyplane.spec b/pyplane.spec index 8447114..dd442cd 100644 --- a/pyplane.spec +++ b/pyplane.spec @@ -21,8 +21,13 @@ Source0: %{forgesource} Source1: pyplane.metainfo.xml Source2: pyplane.desktop +# Write logging file to XDG_DATA_HOME instead of /usr/lib/pythonX.Y/site-packages/ +# https://github.com/TUD-RST/pyplane/pull/10 +Patch0: 0001-feat-use-XDG_DATA_HOME-for-logging-file-on-Linux.patch + BuildArch: noarch +BuildRequires: git-core BuildRequires: python3-devel BuildRequires: libappstream-glib BuildRequires: desktop-file-utils @@ -41,7 +46,7 @@ Recommends: texlive-dvipng %description %_description %prep -%forgesetup +%forgeautosetup -S git %generate_buildrequires # the install requirements seem to be required for tests, so include them From 5106e1010718a213b61ca2220ff3c365d67e8cf8 Mon Sep 17 00:00:00 2001 From: Ankur Sinha (Ankur Sinha Gmail) Date: Oct 11 2021 15:55:13 +0000 Subject: [PATCH 4/4] feat: add missing requires --- diff --git a/pyplane.spec b/pyplane.spec index dd442cd..ac0bbb1 100644 --- a/pyplane.spec +++ b/pyplane.spec @@ -42,6 +42,8 @@ BuildRequires: texlive-dvipng # dependencies Recommends: texlive-latex Recommends: texlive-dvipng +# Not included automatically +Requires: python3-matplotlib-qt5 %description %_description