[bug#33185,6/7] gnu: Add patchwork.

Message ID 20181104104455.3527-6-mail@cbaines.net
State New
Headers show
Series
  • [bug#33185,1/7] gnu: Add python-jsmin.
Related show

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Christopher Baines Nov. 4, 2018, 10:44 a.m. UTC
---
 gnu/packages/patchutils.scm | 103 ++++++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)

Comments

swedebugia Nov. 4, 2018, 7:09 p.m. UTC | #1
Hi

I did not run the code. See question below.

On 2018-11-04 11:44, Christopher Baines wrote:
> ---
>   gnu/packages/patchutils.scm | 103 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 103 insertions(+)
>
> diff --git a/gnu/packages/patchutils.scm b/gnu/packages/patchutils.scm
snip
> +
> +(define-public patchwork
> +
snip
> +    (synopsis "")
> +    (description "")
> +    (home-page "")
> +    (license "")))
Perhaps you forgot to populate these 4 fields?
Ludovic Courtès Nov. 19, 2018, 4:37 p.m. UTC | #2
Christopher Baines <mail@cbaines.net> skribis:

> ---
>  gnu/packages/patchutils.scm | 103 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 103 insertions(+)

[...]

> +         (add-after 'unpack 'patch-wsgi.py
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (substitute* "patchwork/wsgi.py"
> +               (("import os")
> +                (string-append
> +                 "import os, sys
> +
> +sys.path.extend('" (string-append (getenv "PYTHONPATH") ":" (site-packages inputs outputs)) "'.split(':'))"))
> +               (("'patchwork\\.settings\\.production'")
> +                "os.getenv('DJANGO_SETTINGS_MODULE', 'guix.patchwork.settings')"))))
> +         (replace 'check
> +           (lambda* (#:key tests? #:allow-other-keys)
> +             (or (not tests?)
> +                 (begin
> +                   (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.dev")
> +                   (invoke
> +                    "python" "-Wonce" "./manage.py" "test" "--noinput")
> +                   #t))))
> +         (replace 'install
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let ((out (assoc-ref outputs "out")))
> +               (for-each (lambda (directory)
> +                           (copy-recursively
> +                            directory
> +                            (string-append (site-packages inputs outputs)
> +                                           "/" directory)))
> +                         '("patchwork"
> +                           "templates"))
> +               (delete-file-recursively (string-append
> +                                    (site-packages inputs outputs)
> +                                    "patchwork/tests"))
> +               (let ((static-root
> +                      (string-append out "/share/patchwork/htdocs")))
> +                 (mkdir-p static-root)
> +                 (copy-file "patchwork/settings/production.example.py"
> +                            "patchwork/settings/assets.py")
> +                 (setenv "DJANGO_SECRET_KEY" "dummyvalue")
> +                 (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.assets")
> +                 (setenv "STATIC_ROOT" static-root)
> +                 (invoke "./manage.py" "collectstatic" "--no-input"))
> +
> +               (copy-recursively "lib"
> +                                 (string-append
> +                                  out "/share/doc/" ,name "-" ,version)))
> +             #t))
> +         (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 (port)
> +                   (display "#!/usr/bin/env python3
> +import os, sys
> +
> +if __name__ == \"__main__\":
> +    os.environ.setdefault(
> +      \"DJANGO_SETTINGS_MODULE\",
> +      \"guix.patchwork.settings\"
> +    )
> +
> +    from django.core.management import execute_from_command_line
> +
> +    execute_from_command_line(sys.argv)" port)))
> +               (chmod (string-append out "/bin/patchwork-admin") #o555))
> +             #t)))))

IMO these phases would be less intimidating with a few comments
explaining what’s going on.  :-)

> +    (synopsis "")
> +    (description "")
> +    (home-page "")
> +    (license "")))

As swedebugia noted, you’re missing a few things here and in the commit
log. :-)

With these things fixed it should be good!

Thanks,
Ludo’.
Christopher Baines Jan. 22, 2019, 10:31 p.m. UTC | #3
Ludovic Courtès <ludo@gnu.org> writes:

> Christopher Baines <mail@cbaines.net> skribis:
>
>> ---
>>  gnu/packages/patchutils.scm | 103 ++++++++++++++++++++++++++++++++++++
>>  1 file changed, 103 insertions(+)
>
> [...]
>
>> +         (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 (port)
>> +                   (display "#!/usr/bin/env python3
>> +import os, sys
>> +
>> +if __name__ == \"__main__\":
>> +    os.environ.setdefault(
>> +      \"DJANGO_SETTINGS_MODULE\",
>> +      \"guix.patchwork.settings\"
>> +    )
>> +
>> +    from django.core.management import execute_from_command_line
>> +
>> +    execute_from_command_line(sys.argv)" port)))
>> +               (chmod (string-append out "/bin/patchwork-admin") #o555))
>> +             #t)))))
>
> IMO these phases would be less intimidating with a few comments
> explaining what’s going on.  :-)
>
>> +    (synopsis "")
>> +    (description "")
>> +    (home-page "")
>> +    (license "")))
>
> As swedebugia noted, you’re missing a few things here and in the commit
> log. :-)
>
> With these things fixed it should be good!

Thanks for taking a look. I've finally got around to taking another look
at these patches, and sent updated patches for the package, service and
system test.

I think it's a lot further forward, but there are still a few bits to
sort out. I'll send some comments in reply to the patches.
Christopher Baines Jan. 22, 2019, 10:36 p.m. UTC | #4
swedebugia <swedebugia@riseup.net> writes:

> Hi
>
> I did not run the code. See question below.
>
> On 2018-11-04 11:44, Christopher Baines wrote:
>> ---
>>   gnu/packages/patchutils.scm | 103 ++++++++++++++++++++++++++++++++++++
>>   1 file changed, 103 insertions(+)
>>
>> diff --git a/gnu/packages/patchutils.scm b/gnu/packages/patchutils.scm
> snip
>> +
>> +(define-public patchwork
>> +
> snip
>> +    (synopsis "")
>> +    (description "")
>> +    (home-page "")
>> +    (license "")))
> Perhaps you forgot to populate these 4 fields?

These patches for patchwork were just functional, not ready for
merging. However, I've now got around to sending some more polished
patches, not quite ready for merging yet still, but at least with values
for these fields.

Thanks,

Chris

Patch

diff --git a/gnu/packages/patchutils.scm b/gnu/packages/patchutils.scm
index 688e62cdc..0981cbc08 100644
--- a/gnu/packages/patchutils.scm
+++ b/gnu/packages/patchutils.scm
@@ -29,6 +29,8 @@ 
   #:use-module (gnu packages ed)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages django)
   #:use-module (gnu packages file)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gettext)
@@ -240,3 +242,104 @@  hexadecimal and ASCII (or EBCDIC).  It can also display two files at once, and
 highlight the differences between them.  It works well with large files (up to 4
 GiB).")
     (license gpl2+)))
+
+(define-public patchwork
+  (package
+    (name "patchwork")
+    (version "2.1.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/getpatchwork/patchwork/archive/v"
+                    version ".tar.gz"))
+              (sha256
+               (base32
+                "1q4i46gwwxvr8gjj983r8aacfsssp062dzi29ha7zba380fsxayy"))
+              (file-name (string-append name "-" version))))
+    (build-system python-build-system)
+    (arguments
+     `(;; TODO: Tests require a running database
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (delete 'build)
+         (add-after 'unpack 'patch-wsgi.py
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (substitute* "patchwork/wsgi.py"
+               (("import os")
+                (string-append
+                 "import os, sys
+
+sys.path.extend('" (string-append (getenv "PYTHONPATH") ":" (site-packages inputs outputs)) "'.split(':'))"))
+               (("'patchwork\\.settings\\.production'")
+                "os.getenv('DJANGO_SETTINGS_MODULE', 'guix.patchwork.settings')"))))
+         (replace 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+             (or (not tests?)
+                 (begin
+                   (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.dev")
+                   (invoke
+                    "python" "-Wonce" "./manage.py" "test" "--noinput")
+                   #t))))
+         (replace 'install
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (for-each (lambda (directory)
+                           (copy-recursively
+                            directory
+                            (string-append (site-packages inputs outputs)
+                                           "/" directory)))
+                         '("patchwork"
+                           "templates"))
+               (delete-file-recursively (string-append
+                                    (site-packages inputs outputs)
+                                    "patchwork/tests"))
+               (let ((static-root
+                      (string-append out "/share/patchwork/htdocs")))
+                 (mkdir-p static-root)
+                 (copy-file "patchwork/settings/production.example.py"
+                            "patchwork/settings/assets.py")
+                 (setenv "DJANGO_SECRET_KEY" "dummyvalue")
+                 (setenv "DJANGO_SETTINGS_MODULE" "patchwork.settings.assets")
+                 (setenv "STATIC_ROOT" static-root)
+                 (invoke "./manage.py" "collectstatic" "--no-input"))
+
+               (copy-recursively "lib"
+                                 (string-append
+                                  out "/share/doc/" ,name "-" ,version)))
+             #t))
+         (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 (port)
+                   (display "#!/usr/bin/env python3
+import os, sys
+
+if __name__ == \"__main__\":
+    os.environ.setdefault(
+      \"DJANGO_SETTINGS_MODULE\",
+      \"guix.patchwork.settings\"
+    )
+
+    from django.core.management import execute_from_command_line
+
+    execute_from_command_line(sys.argv)" port)))
+               (chmod (string-append out "/bin/patchwork-admin") #o555))
+             #t)))))
+    (inputs
+     `(("python-wrapper" ,python-wrapper)))
+    (propagated-inputs
+     `(("python-django" ,python-django)
+       ;; TODO: Make this configurable
+       ("python-psycopg2" ,python-psycopg2)
+       ("python-mysqlclient" ,python-mysqlclient)
+       ("python-django-filter" ,python-django-filter)
+       ("python-djangorestframework" ,python-djangorestframework)
+       ("python-django-debug-toolbar" ,python-django-debug-toolbar)))
+    (synopsis "")
+    (description "")
+    (home-page "")
+    (license "")))