blob: 698ac7ab024170c8369688ed61cecee8db8b9d97 [file] [log] [blame]
Aviv Keshet272eb702013-05-22 10:16:41 -07001# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2
3
4EAPI="3"
5PYTHON_DEPEND="2"
6SUPPORT_PYTHON_ABIS="1"
7RESTRICT_PYTHON_ABIS="3.*"
8
9inherit bash-completion-r1 distutils versionator webapp
10
11MY_P="Django-${PV}"
12
13DESCRIPTION="High-level Python web framework"
14HOMEPAGE="http://www.djangoproject.com/ http://pypi.python.org/pypi/Django"
15SRC_URI="https://www.djangoproject.com/m/releases/$(get_version_component_range 1-2)/${MY_P}.tar.gz"
16
17LICENSE="BSD"
18SLOT="0"
19KEYWORDS="amd64 ~ia64 ~ppc ~ppc64 ~sparc x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
20IUSE="doc mysql postgres sqlite test"
21
22RDEPEND="dev-python/imaging
23 sqlite? ( || ( dev-lang/python:2.7[sqlite] dev-lang/python:2.6[sqlite] dev-lang/python:2.5[sqlite] dev-python/pysqlite:2 ) )
24 postgres? ( dev-python/psycopg:2 )
25 mysql? ( >=dev-python/mysql-python-1.2.1_p2 )"
26DEPEND="${RDEPEND}
27 doc? ( >=dev-python/sphinx-0.3 )
28 test? ( || ( dev-lang/python:2.7[sqlite] dev-lang/python:2.6[sqlite] dev-lang/python:2.5[sqlite] dev-python/pysqlite:2 ) )"
29
30S="${WORKDIR}/${MY_P}"
31
32WEBAPP_MANUAL_SLOT="yes"
33
34pkg_setup() {
35 python_pkg_setup
36 webapp_pkg_setup
37}
38
39src_prepare() {
40 distutils_src_prepare
41
42 # Disable tests requiring network connection.
43 sed \
44 -e "s/test_correct_url_value_passes/_&/" \
45 -e "s/test_correct_url_with_redirect/_&/" \
46 -i tests/modeltests/validation/tests.py
47 sed \
48 -e "s/test_urlfield_3/_&/" \
49 -e "s/test_urlfield_4/_&/" \
50 -e "s/test_urlfield_10/_&/" \
51 -i tests/regressiontests/forms/tests/fields.py
52}
53
54src_compile() {
55 distutils_src_compile
56
57 if use doc; then
58 einfo "Generation of documentation"
59 pushd docs > /dev/null
60 emake html || die "Generation of documentation failed"
61 popd > /dev/null
62 fi
63}
64
65src_test() {
66 testing() {
67 # Tests have non-standard assumptions about PYTHONPATH and
68 # don't work with usual "build-${PYTHON_ABI}/lib".
69 PYTHONPATH="." "$(PYTHON)" tests/runtests.py --settings=test_sqlite -v1
70 }
71 python_execute_function testing
72}
73
74src_install() {
75 distutils_src_install
76
77 newbashcomp extras/django_bash_completion ${PN} || die
78
79 if use doc; then
80 rm -fr docs/_build/html/_sources
81 dohtml -A txt -r docs/_build/html/* || die "dohtml failed"
82 fi
83
84 insinto "${MY_HTDOCSDIR#${EPREFIX}}"
85 doins -r django/contrib/admin/static/admin/* || die "doins failed"
86
87 webapp_src_install
88}
89
90pkg_preinst() {
91 :
92}
93
94pkg_postinst() {
95 distutils_pkg_postinst
96
97 einfo "Now, Django has the best of both worlds with Gentoo,"
98 einfo "ease of deployment for production and development."
99 echo
100 elog "A copy of the admin media is available to"
101 elog "webapp-config for installation in a webroot,"
102 elog "as well as the traditional location in python's"
103 elog "site-packages dir for easy development"
104 echo
105 ewarn "If you build Django ${PV} without USE=\"vhosts\""
106 ewarn "webapp-config will automatically install the"
107 ewarn "admin media into the localhost webroot."
108}