Aviv Keshet | 272eb70 | 2013-05-22 10:16:41 -0700 | [diff] [blame] | 1 | # Copyright 1999-2012 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | |
| 4 | EAPI="3" |
| 5 | PYTHON_DEPEND="2" |
| 6 | SUPPORT_PYTHON_ABIS="1" |
| 7 | RESTRICT_PYTHON_ABIS="3.*" |
| 8 | |
| 9 | inherit bash-completion-r1 distutils versionator webapp |
| 10 | |
| 11 | MY_P="Django-${PV}" |
| 12 | |
| 13 | DESCRIPTION="High-level Python web framework" |
| 14 | HOMEPAGE="http://www.djangoproject.com/ http://pypi.python.org/pypi/Django" |
| 15 | SRC_URI="https://www.djangoproject.com/m/releases/$(get_version_component_range 1-2)/${MY_P}.tar.gz" |
| 16 | |
| 17 | LICENSE="BSD" |
| 18 | SLOT="0" |
| 19 | KEYWORDS="amd64 ~ia64 ~ppc ~ppc64 ~sparc x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos" |
| 20 | IUSE="doc mysql postgres sqlite test" |
| 21 | |
| 22 | RDEPEND="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 )" |
| 26 | DEPEND="${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 | |
| 30 | S="${WORKDIR}/${MY_P}" |
| 31 | |
| 32 | WEBAPP_MANUAL_SLOT="yes" |
| 33 | |
| 34 | pkg_setup() { |
| 35 | python_pkg_setup |
| 36 | webapp_pkg_setup |
| 37 | } |
| 38 | |
| 39 | src_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 | |
| 54 | src_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 | |
| 65 | src_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 | |
| 74 | src_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 | |
| 90 | pkg_preinst() { |
| 91 | : |
| 92 | } |
| 93 | |
| 94 | pkg_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 | } |