#2 Install the desktop and appstream files
Merged 3 years ago by shaneallcroft. Opened 3 years ago by ankursinha.
neuro-sig/ ankursinha/python-pyplane main  into  main

@@ -0,0 +1,54 @@ 

+ From 4805d3f2158d94337c11c4e7970795a46bfdbe65 Mon Sep 17 00:00:00 2001

+ From: "Ankur Sinha (Ankur Sinha Gmail)" <sanjay.ankur@gmail.com>

+ 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

+ 

file modified
+17 -5
@@ -17,12 +17,20 @@ 

  License:        GPLv3

  URL:            %{forgeurl}

  Source0:        %{forgesource}

+ # Sent upstream https://github.com/TUD-RST/pyplane/pull/9

  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

  %if %{with tests}

  BuildRequires:  %{py3_dist pytest}

  # bits not mentioned in install_requires
@@ -34,14 +42,13 @@ 

  # dependencies

  Recommends:     texlive-latex

  Recommends:     texlive-dvipng

- 

- # Add virtual provides to help users find it

- Provides:       python3-pyplane

+ # Not included automatically

+ Requires:       python3-matplotlib-qt5

  

  %description %_description

  

  %prep

- %forgesetup

+ %forgeautosetup -S git

  

  %generate_buildrequires

  # the install requirements seem to be required for tests, so include them
@@ -57,16 +64,21 @@ 

  %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

Since they are extra source files, they're not in the buildroot, so we need to manually install them there for the RPM.

2 new commits added

  • feat: add missing requires
  • feat: add patch to log to XDG_DATA_DIR
3 years ago

@shaneallcroft : updated to also include the patch etc.

Pull-Request has been merged by shaneallcroft

3 years ago