Merge branch 'python-tests'
[jackhill/guix/guix.git] / gnu / packages / django.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
3 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages django)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix build-system python)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages base)
27 #:use-module (gnu packages python))
28
29 (define-public python-django
30 (package
31 (name "python-django")
32 (version "1.10.5")
33 (source (origin
34 (method url-fetch)
35 (uri (pypi-uri "Django" version))
36 (sha256
37 (base32
38 "12szjsmnfhh2yr54sfynyjr8vl0q9gb6qak3ayqcifcinrs97f0d"))))
39 (build-system python-build-system)
40 (arguments
41 '(#:phases
42 (modify-phases %standard-phases
43 (add-before 'check 'set-tzdir
44 (lambda* (#:key inputs #:allow-other-keys)
45 ;; The test-suite tests timezone-dependent functions, thus tzdata
46 ;; needs to be available.
47 (setenv "TZDIR"
48 (string-append (assoc-ref inputs "tzdata")
49 "/share/zoneinfo"))
50 #t))
51 (replace 'check
52 (lambda _
53 (setenv "PYTHONPATH"
54 (string-append ".:" (getenv "PYTHONPATH")))
55 (zero? (system* "python" "tests/runtests.py")))))))
56 ;; TODO: Install extras/django_bash_completion.
57 (native-inputs
58 `(("tzdata", tzdata)
59 ;; bcrypt and argon2-cffi are extra requirements not yet in guix
60 ;;("python-argon2-cffi" ,python-argon2-cffi) ; >= 16.1.0
61 ;;("python-bcrypt" ,python-bcrypt) ; not py-bcrypt!
62 ;; Remaining packages are test requirements taken from
63 ;; tests/requirements/py3.txt
64 ("python-docutils" ,python-docutils)
65 ;; optional for tests: ("python-geoip2" ,python-geoip2)
66 ("python-jinja2" ,python-jinja2) ; >= 2.7
67 ;; optional for tests: ("python-memcached" ,python-memcached)
68 ("python-numpy" ,python-numpy)
69 ("python-pillow" ,python-pillow)
70 ("python-pyyaml" ,python-pyyaml)
71 ("python-pytz" ,python-pytz)
72 ;; optional for tests: ("python-selenium" ,python-selenium)
73 ("python-sqlparse" ,python-sqlparse)
74 ("python-tblib" ,python-tblib)))
75 (home-page "http://www.djangoproject.com/")
76 (synopsis "High-level Python Web framework")
77 (description
78 "Django is a high-level Python Web framework that encourages rapid
79 development and clean, pragmatic design. It provides many tools for building
80 any Web site. Django focuses on automating as much as possible and adhering
81 to the @dfn{don't repeat yourself} (DRY) principle.")
82 (license license:bsd-3)
83 (properties `((python2-variant . ,(delay python2-django))))))
84
85 (define-public python2-django
86 (let ((base (package-with-python2 (strip-python2-variant python-django))))
87 (package
88 (inherit base)
89 (native-inputs
90 `(;; Test requirements for Python 2 taken from
91 ;; tests/requirements/py3.txt: enum34 and mock.
92 ("python2-enum34" ,python2-enum34)
93 ("python2-mock" ,python2-mock)
94 ;; When adding memcached mind: for Python 2 memcached <= 1.53 is
95 ;; required.
96 ,@(package-native-inputs base))))))
97
98 (define-public python-django-simple-math-captcha
99 (package
100 (name "python-django-simple-math-captcha")
101 (version "1.0.7")
102 (source (origin
103 (method url-fetch)
104 (uri (pypi-uri "django-simple-math-captcha" version))
105 (sha256
106 (base32
107 "0906hms6y6znjhpd0g4wmzv9vcla4brkdpsm4zha9zdj8g5vq2hd"))))
108 (build-system python-build-system)
109 (arguments
110 ;; FIXME: Upstream uses a 'runtests.py' script that is not
111 ;; present in the pypi tarball.
112 '(#:tests? #f))
113 (propagated-inputs
114 `(("python-django" ,python-django)))
115 (home-page "https://github.com/alsoicode/django-simple-math-captcha")
116 (synopsis "Easy-to-use math field/widget captcha for Django forms")
117 (description
118 "A multi-value-field that presents a human answerable question,
119 with no settings.py configuration necessary, but instead can be configured
120 with arguments to the field constructor.")
121 (license license:asl2.0)))
122
123 (define-public python2-django-simple-math-captcha
124 (package-with-python2 python-django-simple-math-captcha))
125
126 (define-public python-pytest-django
127 (package
128 (name "python-pytest-django")
129 (version "2.9.1")
130 (source (origin
131 (method url-fetch)
132 (uri (pypi-uri "pytest-django" version))
133 (sha256
134 (base32
135 "1mmc7zsz3dlhs6sx4sppkj1vgshabi362r1a8b8wpj1qfximpqcb"))))
136 (build-system python-build-system)
137 (arguments
138 `(#:tests? #f ; FIXME: How to run tests?
139 #:phases
140 (modify-phases %standard-phases
141 (add-after 'unpack 'patch-setuppy
142 (lambda _
143 (substitute* "setup.py"
144 (("setuptools_scm==1.8.0") "setuptools_scm"))
145 #t)))))
146 (native-inputs
147 `(("python-django" ,python-django)
148 ("python-setuptools-scm" ,python-setuptools-scm)))
149 (propagated-inputs
150 `(("python-pytest" ,python-pytest)))
151 (home-page "http://pytest-django.readthedocs.org/")
152 (synopsis "Django plugin for py.test")
153 (description "Pytest-django is a plugin for py.test that provides a set of
154 useful tools for testing Django applications and projects.")
155 (license license:bsd-3)))
156
157 (define-public python2-pytest-django
158 (package-with-python2 python-pytest-django))
159
160 (define-public python-django-filter
161 (package
162 (name "python-django-filter")
163 (version "0.14.0")
164 (source (origin
165 (method url-fetch)
166 (uri (pypi-uri "django-filter" version))
167 (sha256
168 (base32
169 "0f78hmk8c903zwfzlsiw7ivgag81ymmb5hi73rzxbhnlg2v0l3fx"))))
170 (build-system python-build-system)
171 (arguments
172 '(#:phases
173 (modify-phases %standard-phases
174 (replace 'check
175 (lambda _
176 (zero? (system* "python" "runtests.py")))))))
177 (native-inputs
178 `(("python-django" ,python-django)
179 ("python-mock" ,python-mock)))
180 (home-page "https://django-filter.readthedocs.io/en/latest/")
181 (synopsis "Reusable Django application to filter querysets dynamically")
182 (description
183 "Django-filter is a generic, reusable application to alleviate writing
184 some of the more mundane bits of view code. Specifically, it allows users to
185 filter down a queryset based on a model’s fields, displaying the form to let
186 them do this.")
187 (license license:bsd-3)))
188
189 (define-public python2-django-filter
190 (package-with-python2 python-django-filter))