1f71983781cd189008a7a84697418b1f1dba9ae8
[gentoo.git] / dev-python / django / django-1.11.20.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{5,6,7} pypy )
7 PYTHON_REQ_USE='sqlite?,threads(+)'
8 WEBAPP_NO_AUTO_INSTALL="yes"
9
10 inherit bash-completion-r1 distutils-r1 eutils eapi7-ver webapp
11
12 MY_PN="Django"
13 MY_P="${MY_PN}-${PV}"
14
15 DESCRIPTION="High-level Python web framework"
16 HOMEPAGE="https://www.djangoproject.com/ https://pypi.org/project/Django/"
17 SRC_URI="
18         https://www.djangoproject.com/m/releases/$(ver_cut 1-2)/${MY_P}.tar.gz
19         mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_P}.tar.gz
20         "
21
22 LICENSE="BSD"
23 # admin fonts: Roboto (media-fonts/roboto)
24 LICENSE+=" Apache-2.0"
25 # admin icons, jquery, xregexp.js
26 LICENSE+=" MIT"
27 SLOT="0"
28 KEYWORDS="amd64 ~arm64 ~ia64 ~ppc ~ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
29 IUSE="doc sqlite test"
30 RESTRICT="!test? ( test )"
31
32 RDEPEND=""
33 DEPEND="${RDEPEND}
34         dev-python/pytz[${PYTHON_USEDEP}]
35         dev-python/setuptools[${PYTHON_USEDEP}]
36         doc? ( >=dev-python/sphinx-1.0.7[${PYTHON_USEDEP}] )
37         test? (
38                 $(python_gen_impl_dep sqlite)
39                 dev-python/docutils[${PYTHON_USEDEP}]
40                 dev-python/numpy[$(python_gen_usedep 'python*')]
41                 dev-python/pillow[${PYTHON_USEDEP}]
42                 dev-python/pyyaml[${PYTHON_USEDEP}]
43                 dev-python/mock[${PYTHON_USEDEP}]
44                 virtual/python-enum34[${PYTHON_USEDEP}]
45                 )"
46
47 S="${WORKDIR}/${MY_P}"
48
49 WEBAPP_MANUAL_SLOT="yes"
50
51 PATCHES=(
52         "${FILESDIR}"/${PN}-1.9-bashcomp.patch
53 )
54
55 pkg_setup() {
56         webapp_pkg_setup
57 }
58
59 python_prepare_all() {
60         # Prevent d'loading in the doc build
61         sed -e '/^    "sphinx.ext.intersphinx",/d' -i docs/conf.py || die
62
63         distutils-r1_python_prepare_all
64 }
65
66 python_compile_all() {
67         use doc && emake -C docs html
68 }
69
70 python_test() {
71         # Tests have non-standard assumptions about PYTHONPATH,
72         # and don't work with ${BUILD_DIR}/lib.
73         PYTHONPATH=. "${PYTHON}" tests/runtests.py --settings=test_sqlite -v2 --parallel 1 \
74                 || die "Tests fail with ${EPYTHON}"
75 }
76
77 python_install_all() {
78         newbashcomp extras/django_bash_completion ${PN}-admin
79         bashcomp_alias ${PN}-admin django-admin.py
80
81         if use doc; then
82                 rm -fr docs/_build/html/_sources || die
83                 local HTML_DOCS=( docs/_build/html/. )
84         fi
85
86         insinto "${MY_HTDOCSDIR#${EPREFIX}}"
87         doins -r django/contrib/admin/static/admin/.
88         distutils-r1_python_install_all
89 }
90
91 src_install() {
92         distutils-r1_src_install
93         webapp_src_install
94 }
95
96 pkg_postinst() {
97         elog "Additional Backend support can be enabled via"
98         optfeature "MySQL backend support in python 2.7 only" dev-python/mysql-python
99         optfeature "MySQL backend support in python 2.7 - 3.4" dev-python/mysqlclient
100         optfeature "PostgreSQL backend support" dev-python/psycopg:2
101         echo ""
102         elog "Other features can be enhanced by"
103         optfeature "GEO Django" sci-libs/gdal[geos]
104         optfeature "Memcached support" dev-python/pylibmc dev-python/python-memcached
105         optfeature "ImageField Support" dev-python/pillow
106         optfeature "Password encryption" dev-python/bcrypt
107         optfeature "High-level abstractions for Django forms" dev-python/django-formtools
108         echo ""
109         elog "A copy of the admin media is available to webapp-config for installation in a"
110         elog "webroot, as well as the traditional location in python's site-packages dir"
111         elog "for easy development."
112         webapp_pkg_postinst
113 }