diff mbox

[1/2] gnu: add python-django.

Message ID 1471865497-7324-2-git-send-email-h.goebel@crazy-compilers.com
State New
Headers show

Commit Message

Hartmut Goebel Aug. 22, 2016, 11:31 a.m. UTC
* gnu/packages/django.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
* gnu/packages/patches/django-fix-testcase.patch: New file.
---
 gnu/local.mk                                       |   1 +
 gnu/packages/django.scm                            | 110 +++++++++++++++++++++
 .../patches/python-django-fix-testcase.patch       |  42 ++++++++
 3 files changed, 153 insertions(+)
 create mode 100644 gnu/packages/django.scm
 create mode 100644 gnu/packages/patches/python-django-fix-testcase.patch

Comments

Efraim Flashner Sept. 8, 2016, 5:11 p.m. UTC | #1
On Mon, Aug 22, 2016 at 01:31:36PM +0200, Hartmut Goebel wrote:
> * gnu/packages/django.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/packages/patches/django-fix-testcase.patch: New file.
> ---
>  gnu/local.mk                                       |   1 +
>  gnu/packages/django.scm                            | 110 +++++++++++++++++++++
>  .../patches/python-django-fix-testcase.patch       |  42 ++++++++
>  3 files changed, 153 insertions(+)
>  create mode 100644 gnu/packages/django.scm
>  create mode 100644 gnu/packages/patches/python-django-fix-testcase.patch
> 
> diff --git a/gnu/local.mk b/gnu/local.mk
> index b8c5378..df8d235 100644
> --- a/gnu/local.mk
> +++ b/gnu/local.mk
> @@ -95,6 +95,7 @@ GNU_SYSTEM_MODULES =				\
>    %D%/packages/dictionaries.scm			\
>    %D%/packages/dillo.scm			\
>    %D%/packages/disk.scm				\
> +  %D%/packages/django.scm				\
>    %D%/packages/djvu.scm				\
>    %D%/packages/dns.scm				\
>    %D%/packages/docbook.scm			\
> diff --git a/gnu/packages/django.scm b/gnu/packages/django.scm
> new file mode 100644
> index 0000000..ec3f25f
> --- /dev/null
> +++ b/gnu/packages/django.scm
> @@ -0,0 +1,110 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
> +;;;
> +;;; This file is part of GNU Guix.
> +;;;
> +;;; GNU Guix is free software; you can redistribute it and/or modify it
> +;;; under the terms of the GNU General Public License as published by
> +;;; the Free Software Foundation; either version 3 of the License, or (at
> +;;; your option) any later version.
> +;;;
> +;;; GNU Guix is distributed in the hope that it will be useful, but
> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +;;; GNU General Public License for more details.
> +;;;
> +;;; You should have received a copy of the GNU General Public License
> +;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
> +
> +(define-module (gnu packages django)
> +  #:use-module ((guix licenses) #:prefix license:)
> +  #:use-module (guix packages)
> +  #:use-module (guix download)
> +  #:use-module (guix build-system python)
> +  #:use-module (gnu packages) ; for search-patches
> +  #:use-module (gnu packages base)
> +  #:use-module (gnu packages python))
> +
> +(define-public python-django
> +  (package
> +    (name "python-django")
> +    (version "1.10")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (pypi-uri "Django" version))
> +              (sha256
> +               (base32
> +                "01bh5yra6zyxcpqacahbwfbn0y4ivw07j2jsw3crvmjzivb6if26"))
> +              ; fix test-case failures due to translation updates
> +              ; - was fixed shortly after release
> +              (patches (search-patches "python-django-fix-testcase.patch"))))
> +    (build-system python-build-system)
> +    (arguments
> +     '(#:phases
> +       (modify-phases %standard-phases
> +         (add-before 'check 'set-tzdir
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (setenv "TZDIR"
> +                     (string-append (assoc-ref inputs "tzdata")
> +                                    "/share/zoneinfo"))
> +             #t))
> +         (replace
> +             'check
> +           (lambda* _
> +           (let* ((old-path (getenv "PYTHONPATH")))
> +             (setenv "PYTHONPATH"
> +                     (string-append "." (if old-path
> +                                             (string-append ":" old-path))))
> +             (zero? (system* "python" "tests/runtests.py"))))))))
> +    ;; todo: install extras/django_bash_completion
> +    (inputs
> +     ; Django uses pkg_resources (which is part of setuptools) to
> +     ; locate templates at run-time.
> +     `(("python-setuptools" ,python-setuptools)))
> +    (native-inputs
> +     `(;; bcrypt and argon2-cffi are extra requirements not yet in guix
> +       ;;("python-argon2-cffi" ,python-argon2-cffi) ; >= 16.1.0
> +       ;;("python-bcrypt" ,python-bcrypt) ; not py-bcrypt!
> +       ; The test-suite tests some timezone dependant functions,
> +       ; thus tzdata needs to be installed.
> +       ("tzdata", tzdata)
> +       ; these are taken from tests/requirements/py3.txt
> +       ("python-docutils" ,python-docutils)
> +       ; optional for tests: ("python-geoip2" ,python-geoip2)
> +       ("python-jinja2" ,python-jinja2) ; >= 2.7
> +       ; optional for tests: ("python-memcached" ,python-memcached)
> +       ("python-numpy" ,python-numpy)
> +       ("python-pillow" ,python-pillow)
> +       ("python-pyyaml" ,python-pyyaml)
> +       ("python-pytz" ,python-pytz)
> +       ; optional for tests: ("python-selenium" ,python-selenium)
> +       ("python-sqlparse" ,python-sqlparse)
> +       ("python-tblib" ,python-tblib)))
> +    (home-page "http://www.djangoproject.com/")
> +    (synopsis "High-level Python Web framework")
> +    (description
> +     "Django is a high-level Python Web framework that encourages rapid
> +development and clean, pragmatic design.
> +
> +Developed and used over the past two years by a fast-moving online-news
> +operation, Django was designed from scratch to handle two challenges: the
> +intensive deadlines of a newsroom and the stringent requirements of
> +experienced Web developers.  It has convenient niceties for developing
> +content-management systems, but it's an excellent tool for building any Web
> +site.
> +
> +Django focuses on automating as much as possible and adhering to the
> +DRY principle.")
> +    (license license:bsd-3)
> +    (properties `((python2-variant . ,(delay python2-django))))))
> +
> +(define-public python2-django
> +  (let ((base (package-with-python2 (strip-python2-variant python-django))))
> +    (package
> +      (inherit base)
> +      (native-inputs
> +       `(; required for Python 2: enum34 and mock
> +         ("python2-enum34" ,python2-enum34)
> +         ("python2-mock" ,python2-mock)
> +         ; when adding memcached mind: for Python 2 memcached <= 1.53 is required
> +         ,@(package-native-inputs base))))))
> diff --git a/gnu/packages/patches/python-django-fix-testcase.patch b/gnu/packages/patches/python-django-fix-testcase.patch
> new file mode 100644
> index 0000000..4c1f980
> --- /dev/null
> +++ b/gnu/packages/patches/python-django-fix-testcase.patch
> @@ -0,0 +1,42 @@
> +From 24123c31362b5f3783d84d133c160e9fe16805fe Mon Sep 17 00:00:00 2001
> +From: Tim Graham <timograham@gmail.com>
> +Date: Mon, 1 Aug 2016 15:40:46 -0400
> +Subject: [PATCH] Fixed admin_utils test failures due to translation updates.
> +
> +https://github.com/django/django/commit/24123c31362b5f3783d84d133c160e9fe16805fe
> +
> +---
> + tests/admin_utils/test_logentry.py | 7 ++++---
> + 1 file changed, 4 insertions(+), 3 deletions(-)
> +
> +diff --git a/tests/admin_utils/test_logentry.py b/tests/admin_utils/test_logentry.py
> +index 7798373..8259bf0 100644
> +--- a/tests/admin_utils/test_logentry.py
> ++++ b/tests/admin_utils/test_logentry.py
> +@@ -59,7 +59,7 @@ class LogEntryTests(TestCase):
> +         logentry = LogEntry.objects.filter(content_type__model__iexact='article').latest('id')
> +         self.assertEqual(logentry.get_change_message(), 'Changed title and hist.')
> +         with translation.override('fr'):
> +-            self.assertEqual(logentry.get_change_message(), 'Modification de title et hist.')
> ++            self.assertEqual(logentry.get_change_message(), 'Title et hist modifié(s).')
> + 
> +         add_url = reverse('admin:admin_utils_article_add')
> +         post_data['title'] = 'New'
> +@@ -117,11 +117,12 @@ class LogEntryTests(TestCase):
> +             'Changed domain. Added article "Article object". '
> +             'Changed title for article "Article object". Deleted article "Article object".'
> +         )
> ++
> +         with translation.override('fr'):
> +             self.assertEqual(
> +                 logentry.get_change_message(),
> +-                'Modification de domain. Article « Article object » ajouté. '
> +-                'Modification de title pour l\'objet article « Article object ». Article « Article object » supprimé.'
> ++                "Domain modifié(s). Article « Article object » ajouté. "
> ++                "Title modifié(s) pour l'objet article « Article object ». Article « Article object » supprimé."
> +             )
> + 
> +     def test_logentry_get_edited_object(self):
> +-- 
> +2.7.4
> +
> -- 
> 2.7.4
> 

I can't get this patch to apply
Ludovic Courtès Sept. 12, 2016, 1:30 p.m. UTC | #2
Hi Hartmut,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> * gnu/packages/django.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
> * gnu/packages/patches/django-fix-testcase.patch: New file.

I finally reviewed this patch and pushed it as
d18197af7844151e38322605b11e0c75b18b55bf with small changes: adjust the
list of ‘native-inputs’, use ‘propagated-inputs’ for all the run-time
dependencies, use two semicolons for line comments (as opposed to margin
comments), and add the patch to gnu/local.mk.

Let me know if anything broke!

I’m really sorry that this patch sit there for 3 weeks, which is why I
didn’t dare ask you for these changes.  ;-)

Thanks!

Ludo’.
Hartmut Goebel Sept. 12, 2016, 1:58 p.m. UTC | #3
Hi Ludo,

> I finally reviewed this patch and pushed it as
> d18197af7844151e38322605b11e0c75b18b55bf with small changes: adjust the
> list of ‘native-inputs’, use ‘propagated-inputs’ for all the run-time
> dependencies, use two semicolons for line comments (as opposed to margin
> comments), and add the patch to gnu/local.mk.

Thanks :-)

Unfortunately most of the inputs are now mixed now - but maybe I'm wrong
here, since I still did not get when to use propagated-inputs and normal
inputs for Python packages. [*]

 1.

    setuptools is a run-time dependence, so it needs to be a
    propagated-input (I assume). This is why there is a comment "Django
    uses 'pkg_resources' (part of setuptools) to locate templates at
    run-time.

 2.

    All packages below the line "Taken from tests/requirements/py3.txt."
    are required for tests only. So I assume they are normal inputs.

 3. Same for python2-django: enum34 and mock are used for testing only.
Ludovic Courtès Sept. 12, 2016, 9:07 p.m. UTC | #4
Hi,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

>> I finally reviewed this patch and pushed it as
>> d18197af7844151e38322605b11e0c75b18b55bf with small changes: adjust the
>> list of ‘native-inputs’, use ‘propagated-inputs’ for all the run-time
>> dependencies, use two semicolons for line comments (as opposed to margin
>> comments), and add the patch to gnu/local.mk.
>
> Thanks :-)
>
> Unfortunately most of the inputs are now mixed now - but maybe I'm wrong
> here, since I still did not get when to use propagated-inputs and normal
> inputs for Python packages. [*]

Sorry for messing up!

>  1.
>
>     setuptools is a run-time dependence, so it needs to be a
>     propagated-input (I assume). This is why there is a comment "Django
>     uses 'pkg_resources' (part of setuptools) to locate templates at
>     run-time.

Ooh, OK, I misinterpreted that.

>  2.
>
>     All packages below the line "Taken from tests/requirements/py3.txt."
>     are required for tests only. So I assume they are normal inputs.

That would mean that Django has no run-time dependency other than
setuptools?  I would think pillow, pyyaml, sqlparse, etc. are run-time
dependencies no?

I tested current master with:

  guix environment -C --ad-hoc python-django python -- python2

and then:

  import django

That should detect if we forgot to propagate some of the dependencies,
but of course it does not detect if we propagate too many dependencies.

>  3. Same for python2-django: enum34 and mock are used for testing only.

OK.

Do you want to send a patch to fix this?

Thanks,
Ludo’.
diff mbox

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index b8c5378..df8d235 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -95,6 +95,7 @@  GNU_SYSTEM_MODULES =				\
   %D%/packages/dictionaries.scm			\
   %D%/packages/dillo.scm			\
   %D%/packages/disk.scm				\
+  %D%/packages/django.scm				\
   %D%/packages/djvu.scm				\
   %D%/packages/dns.scm				\
   %D%/packages/docbook.scm			\
diff --git a/gnu/packages/django.scm b/gnu/packages/django.scm
new file mode 100644
index 0000000..ec3f25f
--- /dev/null
+++ b/gnu/packages/django.scm
@@ -0,0 +1,110 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages django)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix build-system python)
+  #:use-module (gnu packages) ; for search-patches
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages python))
+
+(define-public python-django
+  (package
+    (name "python-django")
+    (version "1.10")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "Django" version))
+              (sha256
+               (base32
+                "01bh5yra6zyxcpqacahbwfbn0y4ivw07j2jsw3crvmjzivb6if26"))
+              ; fix test-case failures due to translation updates
+              ; - was fixed shortly after release
+              (patches (search-patches "python-django-fix-testcase.patch"))))
+    (build-system python-build-system)
+    (arguments
+     '(#:phases
+       (modify-phases %standard-phases
+         (add-before 'check 'set-tzdir
+           (lambda* (#:key inputs #:allow-other-keys)
+             (setenv "TZDIR"
+                     (string-append (assoc-ref inputs "tzdata")
+                                    "/share/zoneinfo"))
+             #t))
+         (replace
+             'check
+           (lambda* _
+           (let* ((old-path (getenv "PYTHONPATH")))
+             (setenv "PYTHONPATH"
+                     (string-append "." (if old-path
+                                             (string-append ":" old-path))))
+             (zero? (system* "python" "tests/runtests.py"))))))))
+    ;; todo: install extras/django_bash_completion
+    (inputs
+     ; Django uses pkg_resources (which is part of setuptools) to
+     ; locate templates at run-time.
+     `(("python-setuptools" ,python-setuptools)))
+    (native-inputs
+     `(;; bcrypt and argon2-cffi are extra requirements not yet in guix
+       ;;("python-argon2-cffi" ,python-argon2-cffi) ; >= 16.1.0
+       ;;("python-bcrypt" ,python-bcrypt) ; not py-bcrypt!
+       ; The test-suite tests some timezone dependant functions,
+       ; thus tzdata needs to be installed.
+       ("tzdata", tzdata)
+       ; these are taken from tests/requirements/py3.txt
+       ("python-docutils" ,python-docutils)
+       ; optional for tests: ("python-geoip2" ,python-geoip2)
+       ("python-jinja2" ,python-jinja2) ; >= 2.7
+       ; optional for tests: ("python-memcached" ,python-memcached)
+       ("python-numpy" ,python-numpy)
+       ("python-pillow" ,python-pillow)
+       ("python-pyyaml" ,python-pyyaml)
+       ("python-pytz" ,python-pytz)
+       ; optional for tests: ("python-selenium" ,python-selenium)
+       ("python-sqlparse" ,python-sqlparse)
+       ("python-tblib" ,python-tblib)))
+    (home-page "http://www.djangoproject.com/")
+    (synopsis "High-level Python Web framework")
+    (description
+     "Django is a high-level Python Web framework that encourages rapid
+development and clean, pragmatic design.
+
+Developed and used over the past two years by a fast-moving online-news
+operation, Django was designed from scratch to handle two challenges: the
+intensive deadlines of a newsroom and the stringent requirements of
+experienced Web developers.  It has convenient niceties for developing
+content-management systems, but it's an excellent tool for building any Web
+site.
+
+Django focuses on automating as much as possible and adhering to the
+DRY principle.")
+    (license license:bsd-3)
+    (properties `((python2-variant . ,(delay python2-django))))))
+
+(define-public python2-django
+  (let ((base (package-with-python2 (strip-python2-variant python-django))))
+    (package
+      (inherit base)
+      (native-inputs
+       `(; required for Python 2: enum34 and mock
+         ("python2-enum34" ,python2-enum34)
+         ("python2-mock" ,python2-mock)
+         ; when adding memcached mind: for Python 2 memcached <= 1.53 is required
+         ,@(package-native-inputs base))))))
diff --git a/gnu/packages/patches/python-django-fix-testcase.patch b/gnu/packages/patches/python-django-fix-testcase.patch
new file mode 100644
index 0000000..4c1f980
--- /dev/null
+++ b/gnu/packages/patches/python-django-fix-testcase.patch
@@ -0,0 +1,42 @@ 
+From 24123c31362b5f3783d84d133c160e9fe16805fe Mon Sep 17 00:00:00 2001
+From: Tim Graham <timograham@gmail.com>
+Date: Mon, 1 Aug 2016 15:40:46 -0400
+Subject: [PATCH] Fixed admin_utils test failures due to translation updates.
+
+https://github.com/django/django/commit/24123c31362b5f3783d84d133c160e9fe16805fe
+
+---
+ tests/admin_utils/test_logentry.py | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/tests/admin_utils/test_logentry.py b/tests/admin_utils/test_logentry.py
+index 7798373..8259bf0 100644
+--- a/tests/admin_utils/test_logentry.py
++++ b/tests/admin_utils/test_logentry.py
+@@ -59,7 +59,7 @@ class LogEntryTests(TestCase):
+         logentry = LogEntry.objects.filter(content_type__model__iexact='article').latest('id')
+         self.assertEqual(logentry.get_change_message(), 'Changed title and hist.')
+         with translation.override('fr'):
+-            self.assertEqual(logentry.get_change_message(), 'Modification de title et hist.')
++            self.assertEqual(logentry.get_change_message(), 'Title et hist modifié(s).')
+ 
+         add_url = reverse('admin:admin_utils_article_add')
+         post_data['title'] = 'New'
+@@ -117,11 +117,12 @@ class LogEntryTests(TestCase):
+             'Changed domain. Added article "Article object". '
+             'Changed title for article "Article object". Deleted article "Article object".'
+         )
++
+         with translation.override('fr'):
+             self.assertEqual(
+                 logentry.get_change_message(),
+-                'Modification de domain. Article « Article object » ajouté. '
+-                'Modification de title pour l\'objet article « Article object ». Article « Article object » supprimé.'
++                "Domain modifié(s). Article « Article object » ajouté. "
++                "Title modifié(s) pour l'objet article « Article object ». Article « Article object » supprimé."
+             )
+ 
+     def test_logentry_get_edited_object(self):
+-- 
+2.7.4
+