Unverified Commit 3dd4b58d authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

Merge pull request #292837 from iFreilicht/update-persepolis

persepolis: 3.2.0 -> 4.0.1
parents d769131c 0535756b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ index aaabb35..69676d3 100644
@@ -72,16 +72,8 @@ def startAria():
 
     # in macintosh
     elif os_type == 'Darwin':
     elif os_type == OS.OSX:
-        if aria2_path == "" or aria2_path == None or os.path.isfile(str(aria2_path)) == False:
-
-            cwd = sys.argv[0]
+84 −0
Original line number Diff line number Diff line
{ lib
, stdenv
, buildPythonApplication
, qt5
, python3
, fetchFromGitHub
, aria2
, ffmpeg
, libnotify
, pulseaudio
, psutil
, pyqt5
, requests
, setproctitle
, setuptools
, sound-theme-freedesktop
, wrapQtAppsHook
, yt-dlp
, pkg-config
, meson
, ninja
}:

buildPythonApplication rec {
python3.pkgs.buildPythonApplication rec {
  pname = "persepolis";
  version = "3.2.0";
  version = "4.0.1";
  format = "other";

  src = fetchFromGitHub {
    owner = "persepolisdm";
    repo = "persepolis";
    rev = version;
    sha256 = "1rh7q432ynbysapsd075nif975ync71icpb71x2mb4j8jx1vzs45";
    rev = "57dc9d438bb3f126070a17c7a3677c45ea4dd332";
    hash = "sha256-7OXAITFQJ2/aY0QmqlAo7if7cY7+T3j6PUjfJJV8Z2Q=";
  };

  # see: https://github.com/persepolisdm/persepolis/blob/3.2.0/setup.py#L130
  doCheck = false;

  preBuild=
  # Make setup automatic
  ''
    substituteInPlace setup.py --replace "answer = input(" "answer = 'y'#"
  '' +
  # Replace abandoned youtube-dl with maintained fork yt-dlp. Fixes https://github.com/persepolisdm/persepolis/issues/930,
  # can be removed if that issue is fixed and/or https://github.com/persepolisdm/persepolis/pull/936 is merged
  ''
    substituteInPlace setup.py ./persepolis/scripts/video_finder_addlink.py --replace \
        "import youtube_dl" "import yt_dlp as youtube_dl"
  '';

  patches = lib.optionals stdenv.isDarwin [
    # Upstream is abandonware, the last commit to master was on 2021-08-26.
    # If it is forked or picked up again, consider upstreaming these patches.
    ./0001-Allow-building-on-darwin.patch
    ./0002-Fix-startup-crash-on-darwin.patch
  patches = [
    # Upstream does currently not allow building from source on macOS. These patches can likely
    # be removed if https://github.com/persepolisdm/persepolis/issues/943 is fixed upstream
    ./0003-Search-PATH-for-aria2c-on-darwin.patch
    ./0004-Search-PATH-for-ffmpeg-on-darwin.patch
  ];

  postPatch = ''
    sed -i 's|/usr/share/sounds/freedesktop/stereo/|${sound-theme-freedesktop}/share/sounds/freedesktop/stereo/|' setup.py
    sed -i "s|'persepolis = persepolis.__main__'|'persepolis = persepolis.scripts.persepolis:main'|" setup.py
    # Ensure dependencies with hard-coded FHS dependencies are properly detected
    substituteInPlace check_dependencies.py --replace-fail "isdir(notifications_path)" "isdir('${sound-theme-freedesktop}/share/sounds/freedesktop')"
  '';

  postInstall = ''
@@ -63,7 +44,7 @@ buildPythonApplication rec {

  # prevent double wrapping
  dontWrapQtApps = true;
  nativeBuildInputs = [ wrapQtAppsHook ];
  nativeBuildInputs = [ meson ninja pkg-config qt5.wrapQtAppsHook ];

  # feed args to wrapPythonApp
  makeWrapperArgs = [
@@ -71,22 +52,33 @@ buildPythonApplication rec {
    "\${qtWrapperArgs[@]}"
  ];

  # The presence of these dependencies is checked during setuptoolsCheckPhase,
  # but apart from that, they're not required during build, only runtime
  nativeCheckInputs = [
    aria2
    libnotify
    pulseaudio
    sound-theme-freedesktop
    ffmpeg
  ];

  propagatedBuildInputs = [
    pulseaudio
    sound-theme-freedesktop
  ] ++ (with python3.pkgs; [
    psutil
    pyqt5
    requests
    setproctitle
    setuptools
    sound-theme-freedesktop
    yt-dlp
  ];
  ]);

  meta = with lib; {
    description = "Persepolis Download Manager is a GUI for aria2";
    description = "A GUI for aria2";
    mainProgram = "persepolis";
    homepage = "https://persepolisdm.github.io/";
    license = licenses.gpl3;
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ iFreilicht ];
  };
}
+0 −45
Original line number Diff line number Diff line
---
 setup.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/setup.py b/setup.py
index 985d28d..933f3df 100755
--- a/setup.py
+++ b/setup.py
@@ -24,13 +24,9 @@ import shutil
 # finding os platform
 os_type = platform.system()
 
-if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD':
-    from setuptools import setup, Command, find_packages
-    setuptools_available = True
-    print(os_type + " detected!")
-else:
-    print('This script is only work for GNU/Linux or BSD!')
-    sys.exit(1)
+from setuptools import setup, Command, find_packages
+setuptools_available = True
+print(os_type + " detected!")
 
 # Checking dependencies!
 not_installed = ''
@@ -100,6 +96,7 @@ else:
     print('paplay is found!')
 
 # sound-theme-freedesktop
+notifications_path = ''
 if os_type == 'Linux':
     notifications_path = '/usr/share/sounds/freedesktop/stereo/'
 elif os_type == 'FreeBSD' or os_type == 'OpenBSD':
@@ -139,7 +136,7 @@ if sys.argv[1] == "test":
 
 DESCRIPTION = 'Persepolis Download Manager'
 
-if os_type == 'Linux':
+if os_type in ['Linux', 'Darwin']:
     DATA_FILES = [
         ('/usr/share/man/man1/', ['man/persepolis.1.gz']),
         ('/usr/share/applications/', ['xdg/com.github.persepolisdm.persepolis.desktop']),
-- 
2.39.3 (Apple Git-145)
+0 −41
Original line number Diff line number Diff line
---
 persepolis/scripts/mac_notification.py | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/persepolis/scripts/mac_notification.py b/persepolis/scripts/mac_notification.py
index 4d69929..9a9a7cf 100644
--- a/persepolis/scripts/mac_notification.py
+++ b/persepolis/scripts/mac_notification.py
@@ -15,20 +15,13 @@
 
 # native notification on mac! needs Xcode (latest version) installed and pyobjc
 # library from pip
-import Foundation
-import AppKit
-import objc
-
-NSUserNotification = objc.lookUpClass('NSUserNotification')
-NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
-
-
 def notifyMac(title, subtitle, info_text, delay=0):
-    notification = NSUserNotification.alloc().init()
-    notification.setTitle_(title)
-    notification.setSubtitle_(subtitle)
-    notification.setInformativeText_(info_text)
-    notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_(
-        delay, Foundation.NSDate.date()))
-    NSUserNotificationCenter.defaultUserNotificationCenter(
-    ).scheduleNotification_(notification)
+    print(f"""
+Warning: Persepolis was installed from nixpkgs, which currently breaks notifications
+         on macOS. Until https://github.com/NixOS/nixpkgs/issues/105156 is resolved,
+         this cannot be fixed. The notification that should've been displayed was:
+
+         title: {title}
+         subtitle: {subtitle}
+         info_text: {info_text}
+ """)
-- 
2.39.3 (Apple Git-145)
Loading