gnu: patchwork: Switch to pyproject.

* gnu/packages/patchutils.scm (patchwork): Run guix style.
[build-system]: Switch to pyproject-build-system.
[arguments]: Refresh them, run guix style, remove trailing #t.
[native-inputs]: Add python-setuptools.

Change-Id: I811c5ded2b517e35c49f2ae2a67178e4e3417e67
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Nicolas Graves 2025-09-27 15:46:28 +02:00 committed by Sharlatan Hellseher
parent af4acb48a0
commit 3c62bfeba3
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5

View file

@ -35,6 +35,7 @@
#:use-module (guix build-system glib-or-gtk)
#:use-module (guix build-system meson)
#:use-module (guix build-system ocaml)
#:use-module (guix build-system pyproject)
#:use-module (guix build-system python)
#:use-module (gnu packages)
#:use-module (gnu packages autotools)
@ -367,21 +368,21 @@ you to figure out what is going on in that merge you keep avoiding.")
(package
(name "patchwork")
(version "3.2.1")
(source (origin
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/getpatchwork/patchwork")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"04ikawdyhjwspxvhazbp5f5vym672y0jcw8rd2m75h9ipcpnyxim"))))
(build-system python-build-system)
(base32 "04ikawdyhjwspxvhazbp5f5vym672y0jcw8rd2m75h9ipcpnyxim"))))
(build-system pyproject-build-system)
(arguments
`(;; TODO: Tests require a running database
#:tests? #f
(list
#:tests? #f ;TODO: Tests require a running database
#:phases
(modify-phases %standard-phases
#~(modify-phases %standard-phases
(delete 'configure)
(delete 'build)
(add-after 'unpack 'replace-wsgi.py
@ -393,14 +394,11 @@ you to figure out what is going on in that merge you keep avoiding.")
;; as the python modules in this package in the wsgi.py file,
;; as this will ensure they are available at runtime.
(define pythonpath
(string-append (getenv "GUIX_PYTHONPATH")
":"
(string-append (getenv "GUIX_PYTHONPATH") ":"
(site-packages inputs outputs)))
(display
(string-append "
import os, sys
sys.path.extend('" pythonpath "'.split(':'))
(display (string-append
"\nimport os, sys\n\nsys.path.extend('" pythonpath
"'.split(':'))
from django.core.wsgi import get_wsgi_application
@ -419,28 +417,27 @@ application = get_wsgi_application()\n") port)))))
(lambda* (#:key tests? #:allow-other-keys)
(when tests?
(setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.dev")
(invoke "python" "-Wonce" "./manage.py" "test" "--noinput"))
#t))
(invoke "python" "-Wonce" "./manage.py" "test" "--noinput"))))
(replace 'install
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(out-site-packages (site-packages inputs outputs)))
(for-each (lambda (directory)
(copy-recursively
directory
(string-append out-site-packages "/" directory)))
'(;; Contains the python code
(copy-recursively directory
(string-append out-site-packages
"/" directory)))
'( ;Contains the python code
"patchwork"
;; Contains the templates for the generated HTML
"templates"))
(delete-file-recursively
(string-append out-site-packages "/patchwork/tests"))
(delete-file-recursively (string-append out-site-packages
"/patchwork/tests"))
;; Install patchwork related tools
(for-each (lambda (file)
(install-file file (string-append out "/bin")))
(list
(string-append out-site-packages
(install-file file
(string-append out "/bin")))
(list (string-append out-site-packages
"/patchwork/bin/parsemail.sh")
(string-append out-site-packages
"/patchwork/bin/parsemail-batch.sh")))
@ -453,8 +450,8 @@ application = get_wsgi_application()\n") port)))))
;; The intent here is that you can serve files from this
;; directory through a webserver, which is recommended when
;; running Django applications.
(let ((static-root
(string-append out "/share/patchwork/htdocs")))
(let ((static-root (string-append out
"/share/patchwork/htdocs")))
(mkdir-p static-root)
(copy-file "patchwork/settings/production.example.py"
"patchwork/settings/assets.py")
@ -466,9 +463,9 @@ application = get_wsgi_application()\n") port)))))
;; The lib directory includes example configuration files that
;; may be useful when deploying patchwork.
(copy-recursively "lib"
(string-append
out "/share/doc/" ,name "-" ,version)))
#t))
(string-append out "/share/doc/"
#$name "-"
#$version)))))
;; The hasher script is used from the post-receive.hook
(add-after 'install 'install-hasher
(lambda* (#:key inputs outputs #:allow-other-keys)
@ -477,15 +474,15 @@ application = get_wsgi_application()\n") port)))))
(out-hasher.py (string-append out-site-packages
"/patchwork/hasher.py")))
(chmod out-hasher.py #o555)
(symlink out-hasher.py (string-append out "/bin/hasher")))
#t))
(symlink out-hasher.py
(string-append out "/bin/hasher")))))
;; Create a patchwork specific version of Django's command line admin
;; utility.
(add-after 'install 'install-patchwork-admin
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")))
(mkdir-p (string-append out "/bin"))
(call-with-output-file (string-append out "/bin/patchwork-admin")
(lambda _
(mkdir-p (string-append #$output "/bin"))
(call-with-output-file (string-append #$output
"/bin/patchwork-admin")
(lambda (port)
(simple-format port "#!~A
import os, sys
@ -494,10 +491,10 @@ if __name__ == \"__main__\":
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)" (which "python"))))
(chmod (string-append out "/bin/patchwork-admin") #o555))
#t)))))
(inputs
(list python-wrapper))
(chmod (string-append #$output "/bin/patchwork-admin")
#o555))))))
(native-inputs (list python-setuptools))
(inputs (list python-wrapper))
(propagated-inputs
(list python-django
;; TODO: Make this configurable