Mandeep Singh Baines | cf70c42 | 2010-02-01 16:43:24 -0800 | [diff] [blame] | 1 | # Copyright 1999-2009 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/dev-lang/python/python-2.6.4.ebuild,v 1.7 2009/12/13 16:34:03 armin76 Exp $ |
| 4 | |
| 5 | EAPI="2" |
| 6 | |
| 7 | inherit autotools eutils flag-o-matic multilib pax-utils python toolchain-funcs versionator |
| 8 | |
| 9 | # We need this so that we don't depend on python.eclass. |
| 10 | PYVER_MAJOR="$(get_major_version)" |
| 11 | PYVER_MINOR="$(get_version_component_range 2)" |
| 12 | PYVER="${PYVER_MAJOR}.${PYVER_MINOR}" |
| 13 | |
| 14 | MY_P="Python-${PV}" |
| 15 | S="${WORKDIR}/${MY_P}" |
| 16 | |
| 17 | PATCHSET_REVISION="0" |
| 18 | |
| 19 | DESCRIPTION="Python is an interpreted, interactive, object-oriented programming language." |
| 20 | HOMEPAGE="http://www.python.org/" |
| 21 | SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.bz2 |
| 22 | mirror://gentoo/python-gentoo-patches-${PV}$([[ "${PATCHSET_REVISION}" != "0" ]] && echo "-r${PATCHSET_REVISION}").tar.bz2" |
| 23 | |
| 24 | LICENSE="PSF-2.2" |
| 25 | SLOT="2.6" |
| 26 | KEYWORDS="~alpha amd64 arm hppa ~ia64 ~m68k ~mips ppc ~ppc64 ~s390 ~sh ~sparc x86 ~sparc-fbsd ~x86-fbsd" |
| 27 | IUSE="-berkdb build doc elibc_uclibc examples gdbm ipv6 +ncurses +readline sqlite ssl +threads tk +wide-unicode wininst +xml" |
| 28 | |
| 29 | # NOTE: dev-python/{elementtree,celementtree,pysqlite,ctypes} |
| 30 | # do not conflict with the ones in python proper. - liquidx |
| 31 | |
| 32 | RDEPEND=">=app-admin/eselect-python-20090606 |
| 33 | >=sys-libs/zlib-1.1.3 |
| 34 | virtual/libffi |
| 35 | virtual/libintl |
| 36 | !build? ( |
| 37 | berkdb? ( || ( |
| 38 | sys-libs/db:4.7 |
| 39 | sys-libs/db:4.6 |
| 40 | sys-libs/db:4.5 |
| 41 | sys-libs/db:4.4 |
| 42 | sys-libs/db:4.3 |
| 43 | sys-libs/db:4.2 |
| 44 | ) ) |
| 45 | doc? ( dev-python/python-docs:${SLOT} ) |
| 46 | gdbm? ( sys-libs/gdbm ) |
| 47 | ncurses? ( |
| 48 | >=sys-libs/ncurses-5.2 |
| 49 | readline? ( >=sys-libs/readline-4.1 ) |
| 50 | ) |
| 51 | sqlite? ( >=dev-db/sqlite-3 ) |
| 52 | ssl? ( dev-libs/openssl ) |
| 53 | tk? ( >=dev-lang/tk-8.0 ) |
| 54 | xml? ( >=dev-libs/expat-2 ) |
| 55 | )" |
| 56 | DEPEND="${RDEPEND} |
| 57 | dev-util/pkgconfig |
| 58 | !sys-devel/gcc[libffi]" |
| 59 | RDEPEND+=" !build? ( app-misc/mime-types )" |
| 60 | # ToDo(msb): Undo hack below which removes python-update PDEPEND |
| 61 | # python-update is not required currently for chrome-os |
| 62 | #msb: PDEPEND="app-admin/python-updater" |
| 63 | |
| 64 | PROVIDE="virtual/python" |
| 65 | |
| 66 | pkg_setup() { |
| 67 | if use berkdb; then |
| 68 | ewarn "\"bsddb\" module is out-of-date and no longer maintained inside dev-lang/python. It has" |
| 69 | ewarn "been additionally removed in Python 3. You should use external, still maintained \"bsddb3\"" |
| 70 | ewarn "module provided by dev-python/bsddb3 which supports both Python 2 and Python 3." |
| 71 | fi |
| 72 | |
| 73 | if ! has_version "=dev-lang/python-3*"; then |
| 74 | elog "It is highly recommended to additionally install Python 3, but without configuring Python wrapper to use Python 3." |
| 75 | fi |
| 76 | } |
| 77 | |
| 78 | src_prepare() { |
| 79 | # Ensure that internal copies of expat and libffi aren't used. |
| 80 | rm -fr Modules/expat |
| 81 | rm -fr Modules/_ctypes/libffi* |
| 82 | |
| 83 | if tc-is-cross-compiler; then |
| 84 | epatch "${FILESDIR}/python-2.5-cross-printf.patch" |
| 85 | epatch "${FILESDIR}/python-2.6-chflags-cross.patch" |
| 86 | epatch "${FILESDIR}/python-2.6-test-cross.patch" |
| 87 | else |
| 88 | rm "${WORKDIR}/${PV}"/*_all_crosscompile.patch |
| 89 | fi |
| 90 | |
| 91 | EPATCH_SUFFIX="patch" epatch "${WORKDIR}/${PV}" |
| 92 | |
| 93 | if tc-is-cross-compiler ; then |
| 94 | # Change setup.py to respect the SYSROOT environment variable |
| 95 | epatch "${FILESDIR}"/python-2.6.4-cross-setup-sysroot.patch |
| 96 | fi |
| 97 | |
| 98 | # Add a libdirname to enable python cross-compiling and add a user specifyable libdir |
| 99 | epatch "${FILESDIR}"/python-2.5.2-cross-Makefile.pre.in.patch |
| 100 | # Make distutils cross-compile aware |
| 101 | epatch "${FILESDIR}"/python-2.5.2-cross-distutils-build_ext.patch |
| 102 | epatch "${FILESDIR}"/python-2.6-cross-distutils-sysconfig.patch |
| 103 | epatch "${FILESDIR}"/python-2.5.2-cross-distutils-install.patch |
| 104 | # Use a cross-compile aware pkg-config command to setup libffi usage |
| 105 | epatch "${FILESDIR}"/python-2.6.4-cross-libffi-pkg-config.patch |
| 106 | |
| 107 | sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \ |
| 108 | Lib/distutils/command/install.py \ |
| 109 | Lib/distutils/sysconfig.py \ |
| 110 | Lib/site.py \ |
| 111 | Makefile.pre.in \ |
| 112 | Modules/Setup.dist \ |
| 113 | Modules/getpath.c \ |
| 114 | setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@" |
| 115 | |
| 116 | # Fix os.utime() on hppa. utimes it not supported but unfortunately reported as working - gmsoft (22 May 04) |
| 117 | # PLEASE LEAVE THIS FIX FOR NEXT VERSIONS AS IT'S A CRITICAL FIX !!! |
| 118 | [[ "${ARCH}" == "hppa" ]] && sed -e "s/utimes //" -i "${S}/configure" |
| 119 | |
| 120 | if ! use wininst; then |
| 121 | # Remove Microsoft Windows executables. |
| 122 | rm Lib/distutils/command/wininst-*.exe |
| 123 | fi |
| 124 | |
| 125 | # Fix OtherFileTests.testStdin() not to assume |
| 126 | # that stdin is a tty for bug #248081. |
| 127 | sed -e "s:'osf1V5':'osf1V5' and sys.stdin.isatty():" -i Lib/test/test_file.py || die "sed failed" |
| 128 | |
| 129 | eautoreconf |
| 130 | } |
| 131 | |
| 132 | src_configure() { |
| 133 | # Disable extraneous modules with extra dependencies. |
| 134 | if use build; then |
| 135 | export PYTHON_DISABLE_MODULES="dbm _bsddb gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat" |
| 136 | export PYTHON_DISABLE_SSL="1" |
| 137 | else |
| 138 | # dbm module can be linked against berkdb or gdbm. |
| 139 | # Defaults to gdbm when both are enabled, #204343. |
| 140 | local disable |
| 141 | use berkdb || use gdbm || disable+=" dbm" |
| 142 | use berkdb || disable+=" _bsddb" |
| 143 | use gdbm || disable+=" gdbm" |
| 144 | use ncurses || disable+=" _curses _curses_panel" |
| 145 | use readline || disable+=" readline" |
| 146 | use sqlite || disable+=" _sqlite3" |
| 147 | use ssl || export PYTHON_DISABLE_SSL="1" |
| 148 | use tk || disable+=" _tkinter" |
| 149 | use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat. |
| 150 | export PYTHON_DISABLE_MODULES="${disable}" |
| 151 | |
| 152 | if ! use xml; then |
| 153 | ewarn "You have configured Python without XML support." |
| 154 | ewarn "This is NOT a recommended configuration as you" |
| 155 | ewarn "may face problems parsing any XML documents." |
| 156 | fi |
| 157 | fi |
| 158 | |
| 159 | if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then |
| 160 | einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}" |
| 161 | fi |
| 162 | |
| 163 | export OPT="${CFLAGS}" |
| 164 | |
| 165 | filter-flags -malign-double |
| 166 | |
| 167 | [[ "${ARCH}" == "alpha" ]] && append-flags -fPIC |
| 168 | |
| 169 | # https://bugs.gentoo.org/show_bug.cgi?id=50309 |
| 170 | if is-flag -O3; then |
| 171 | is-flag -fstack-protector-all && replace-flags -O3 -O2 |
| 172 | use hardened && replace-flags -O3 -O2 |
| 173 | fi |
| 174 | |
| 175 | if tc-is-cross-compiler; then |
| 176 | OPT="-O1" CFLAGS="" LDFLAGS="" CC="" \ |
| 177 | ./configure --{build,host}=${CBUILD} || die "cross-configure failed" |
David James | 9d8e331 | 2010-03-12 14:10:46 -0800 | [diff] [blame] | 178 | # Does not support parallel building |
| 179 | emake -j1 python Parser/pgen || die "cross-make failed" |
Mandeep Singh Baines | cf70c42 | 2010-02-01 16:43:24 -0800 | [diff] [blame] | 180 | mv python hostpython |
| 181 | mv Parser/pgen Parser/hostpgen |
| 182 | make distclean |
| 183 | # Ugly fix, hostpython require few modules to pass test_unicode.py test |
| 184 | cp -v /usr/lib/python${PYVER}/lib-dynload/unicodedata.so Modules/. |
| 185 | cp -v /usr/lib/python${PYVER}/lib-dynload/time.so Modules/. |
| 186 | cp -v /usr/lib/python${PYVER}/lib-dynload/math.so Modules/. |
| 187 | sed -i \ |
| 188 | -e "/^HOSTPYTHON/s:=.*:=./hostpython:" \ |
| 189 | -e "/^HOSTPGEN/s:=.*:=./Parser/hostpgen:" \ |
| 190 | Makefile.pre.in || die "sed failed" |
| 191 | fi |
| 192 | |
| 193 | # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile. |
| 194 | tc-export CXX |
| 195 | |
| 196 | # Set LDFLAGS so we link modules with -lpython2.6 correctly. |
| 197 | # Needed on FreeBSD unless Python 2.6 is already installed. |
| 198 | # Please query BSD team before removing this! |
| 199 | append-ldflags "-L." |
| 200 | |
| 201 | econf \ |
| 202 | --with-fpectl \ |
| 203 | --enable-shared \ |
| 204 | $(use_enable ipv6) \ |
| 205 | $(use_with threads) \ |
| 206 | $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2") \ |
| 207 | --infodir='${prefix}'/share/info \ |
| 208 | --mandir='${prefix}'/share/man \ |
| 209 | --with-libc='' \ |
| 210 | --with-system-ffi |
| 211 | } |
| 212 | |
| 213 | src_test() { |
| 214 | # Tests won't work when cross compiling. |
| 215 | if tc-is-cross-compiler; then |
| 216 | elog "Disabling tests due to crosscompiling." |
| 217 | return |
| 218 | fi |
| 219 | |
| 220 | # Byte compiling should be enabled here. |
| 221 | # Otherwise test_import fails. |
| 222 | python_enable_pyc |
| 223 | |
| 224 | # Skip all tests that fail during emerge but pass without emerge: |
| 225 | # (See bug #67970) |
| 226 | local skip_tests="distutils minidom pyexpat sax tcl" |
| 227 | |
| 228 | # test_ctypes fails with PAX kernel (bug #234498). |
| 229 | host-is-pax && skip_tests+=" ctypes" |
| 230 | |
| 231 | for test in ${skip_tests}; do |
| 232 | mv "${S}/Lib/test/test_${test}.py" "${T}" |
| 233 | done |
| 234 | |
| 235 | # Rerun failed tests in verbose mode (regrtest -w). |
| 236 | EXTRATESTOPTS="-w" make test || die "make test failed" |
| 237 | |
| 238 | for test in ${skip_tests}; do |
| 239 | mv "${T}/test_${test}.py" "${S}/Lib/test/test_${test}.py" |
| 240 | done |
| 241 | |
| 242 | elog "The following tests have been skipped:" |
| 243 | for test in ${skip_tests}; do |
| 244 | elog "test_${test}.py" |
| 245 | done |
| 246 | |
| 247 | elog "If you'd like to run them, you may:" |
| 248 | elog "cd /usr/$(get_libdir)/python${PYVER}/test" |
| 249 | elog "and run the tests separately." |
| 250 | } |
| 251 | |
| 252 | src_install() { |
David James | 9d8e331 | 2010-03-12 14:10:46 -0800 | [diff] [blame] | 253 | # Does not support parallel building |
| 254 | emake -j1 DESTDIR="${D}" altinstall maninstall || die "emake altinstall maninstall failed" |
Mandeep Singh Baines | cf70c42 | 2010-02-01 16:43:24 -0800 | [diff] [blame] | 255 | |
| 256 | mv "${D}usr/bin/python${PYVER}-config" "${D}usr/bin/python-config-${PYVER}" |
| 257 | |
| 258 | # Fix collisions between different slots of Python. |
| 259 | mv "${D}usr/bin/2to3" "${D}usr/bin/2to3-${PYVER}" |
| 260 | mv "${D}usr/bin/pydoc" "${D}usr/bin/pydoc${PYVER}" |
| 261 | mv "${D}usr/bin/idle" "${D}usr/bin/idle${PYVER}" |
| 262 | mv "${D}usr/share/man/man1/python.1" "${D}usr/share/man/man1/python${PYVER}.1" |
| 263 | rm -f "${D}usr/bin/smtpd.py" |
| 264 | |
| 265 | # Fix the OPT variable so that it doesn't have any flags listed in it. |
| 266 | # Prevents the problem with compiling things with conflicting flags later. |
| 267 | sed -e "s:^OPT=.*:OPT=-DNDEBUG:" -i "${D}usr/$(get_libdir)/python${PYVER}/config/Makefile" |
| 268 | |
| 269 | if use build; then |
| 270 | rm -fr "${D}usr/$(get_libdir)/python${PYVER}/"{bsddb,email,lib-tk,sqlite3,test} |
| 271 | else |
| 272 | use elibc_uclibc && rm -fr "${D}usr/$(get_libdir)/python${PYVER}/"{bsddb/test,test} |
| 273 | use berkdb || rm -fr "${D}usr/$(get_libdir)/python${PYVER}/"{bsddb,test/test_bsddb*} |
| 274 | use sqlite || rm -fr "${D}usr/$(get_libdir)/python${PYVER}/"{sqlite3,test/test_sqlite*} |
| 275 | use tk || rm -fr "${D}usr/$(get_libdir)/python${PYVER}/lib-tk" |
| 276 | fi |
| 277 | |
| 278 | use threads || rm -fr "${D}usr/$(get_libdir)/python${PYVER}/multiprocessing" |
| 279 | |
| 280 | prep_ml_includes usr/include/python${PYVER} |
| 281 | |
| 282 | if use examples; then |
| 283 | insinto /usr/share/doc/${PF}/examples |
| 284 | doins -r "${S}/Tools" || die "doins failed" |
| 285 | fi |
| 286 | |
| 287 | newinitd "${FILESDIR}/pydoc.init" pydoc-${SLOT} |
| 288 | newconfd "${FILESDIR}/pydoc.conf" pydoc-${SLOT} |
| 289 | |
| 290 | # Don't install empty directory. |
| 291 | rmdir "${D}usr/$(get_libdir)/python${PYVER}/lib-old" |
| 292 | } |
| 293 | |
| 294 | pkg_preinst() { |
| 295 | if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version ">=${CATEGORY}/${PN}-${SLOT}_alpha"; then |
| 296 | python_updater_warning="1" |
| 297 | fi |
| 298 | } |
| 299 | |
| 300 | eselect_python_update() { |
| 301 | local ignored_python_slots_options= |
| 302 | [[ "$(eselect python show)" == "python2."* ]] && ignored_python_slots_options="--ignore 3.0 --ignore 3.1 --ignore 3.2" |
| 303 | |
| 304 | # Create python2 symlink. |
| 305 | eselect python update --ignore 3.0 --ignore 3.1 --ignore 3.2 > /dev/null |
| 306 | |
| 307 | eselect python update ${ignored_python_slots_options} |
| 308 | } |
| 309 | |
| 310 | pkg_postinst() { |
| 311 | eselect_python_update |
| 312 | |
| 313 | python_mod_optimize -x "(site-packages|test)" /usr/$(get_libdir)/python${PYVER} |
| 314 | |
| 315 | if [[ "${python_updater_warning}" == "1" ]]; then |
| 316 | ewarn |
| 317 | ewarn "\e[1;31m************************************************************************\e[0m" |
| 318 | ewarn |
| 319 | ewarn "You have just upgraded from an older version of Python." |
| 320 | ewarn "You should run 'python-updater \${options}' to rebuild Python modules." |
| 321 | ewarn |
| 322 | ewarn "\e[1;31m************************************************************************\e[0m" |
| 323 | ewarn |
| 324 | ebeep 12 |
| 325 | fi |
| 326 | } |
| 327 | |
| 328 | pkg_postrm() { |
| 329 | eselect_python_update |
| 330 | |
| 331 | python_mod_cleanup /usr/$(get_libdir)/python${PYVER} |
| 332 | } |