Use https by default
[gentoo.git] / dev-python / pypy3-bin / pypy3-bin-2.4.0-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 # some random parts need python 2...
8 PYTHON_COMPAT=( python2_7 pypy )
9 inherit eutils multilib pax-utils python-any-r1 versionator
10
11 BINHOST="https://dev.gentoo.org/~mgorny/dist/pypy-bin/${PV}"
12
13 DESCRIPTION="A fast, compliant alternative implementation of Python 3 (binary package)"
14 HOMEPAGE="http://pypy.org/"
15 SRC_URI="https://bitbucket.org/pypy/pypy/downloads/pypy3-${PV}-src.tar.bz2
16         amd64? (
17                 jit? ( shadowstack? (
18                         ${BINHOST}/${P}-amd64+bzip2+jit+ncurses+shadowstack.tar.xz
19                 ) )
20                 jit? ( !shadowstack? (
21                         ${BINHOST}/${P}-amd64+bzip2+jit+ncurses.tar.xz
22                 ) )
23                 !jit? ( !shadowstack? (
24                         ${BINHOST}/${P}-amd64+bzip2+ncurses.tar.xz
25                 ) )
26         )
27         x86? (
28                 cpu_flags_x86_sse2? (
29                         jit? ( shadowstack? (
30                                 ${BINHOST}/${P}-x86+bzip2+jit+ncurses+shadowstack+sse2.tar.xz
31                         ) )
32                         jit? ( !shadowstack? (
33                                 ${BINHOST}/${P}-x86+bzip2+jit+ncurses+sse2.tar.xz
34                         ) )
35                         !jit? ( !shadowstack? (
36                                 ${BINHOST}/${P}-x86+bzip2+ncurses+sse2.tar.xz
37                         ) )
38                 )
39                 !cpu_flags_x86_sse2? (
40                         !jit? ( !shadowstack? (
41                                 ${BINHOST}/${P}-x86+bzip2+ncurses.tar.xz
42                         ) )
43                 )
44         )"
45
46 # Supported variants
47 REQUIRED_USE="!jit? ( !shadowstack )
48         x86? ( !cpu_flags_x86_sse2? ( !jit !shadowstack ) )"
49
50 LICENSE="MIT"
51 SLOT="0/$(get_version_component_range 1-2 ${PV})"
52 KEYWORDS="~amd64 ~x86"
53 IUSE="gdbm +jit shadowstack sqlite cpu_flags_x86_sse2 test tk"
54
55 # yep, world would be easier if people started filling subslots...
56 RDEPEND="
57         app-arch/bzip2:0
58         dev-libs/expat:0
59         dev-libs/libffi:0
60         dev-libs/openssl:0
61         sys-libs/glibc:2.2
62         sys-libs/ncurses:5/5
63         sys-libs/zlib:0
64         gdbm? ( sys-libs/gdbm:0= )
65         sqlite? ( dev-db/sqlite:3= )
66         tk? (
67                 dev-lang/tk:0=
68                 dev-tcltk/tix:0=
69         )
70         !dev-python/pypy3:0"
71 DEPEND="app-arch/xz-utils
72         test? ( ${RDEPEND}
73                 ${PYTHON_DEPS} )"
74 #       doc? ( ${PYTHON_DEPS}
75 #               dev-python/sphinx )
76 PDEPEND="app-admin/python-updater"
77
78 S=${WORKDIR}/pypy3-${PV}-src
79
80 src_prepare() {
81         epatch "${FILESDIR}/1.9-scripts-location.patch" \
82                 "${FILESDIR}/1.9-distutils.unixccompiler.UnixCCompiler.runtime_library_dir_option.patch"
83
84         epatch_user
85 }
86
87 src_compile() {
88         # Tadaam! PyPy compiled!
89         mv "${WORKDIR}"/${P}*/{libpypy-c.so,pypy-c} . || die
90         mv "${WORKDIR}"/${P}*/include/*.h include/ || die
91         mv pypy/module/cpyext/include/*.h include/ || die
92         mv pypy/module/cpyext/include/numpy include/ || die
93
94         #use doc && emake -C pypy/doc/ html
95         #needed even without jit :( also needed in both compile and install phases
96         pax-mark m pypy-c
97
98         # ctypes config cache
99         # this one we need to do with python2 too...
100         "${PYTHON}" lib_pypy/ctypes_config_cache/rebuild.py \
101                 || die "Failed to rebuild ctypes config cache"
102 }
103
104 src_test() {
105         # (unset)
106         local -x PYTHONDONTWRITEBYTECODE
107
108         # Test runner requires Python 2 too. However, it spawns PyPy3
109         # internally so that we end up testing the correct interpreter.
110         "${PYTHON}" ./pypy/test_all.py --pypy=./pypy-c lib-python || die
111 }
112
113 src_install() {
114         einfo "Installing PyPy ..."
115         insinto "/usr/$(get_libdir)/pypy3"
116         doins -r include lib_pypy lib-python pypy-c libpypy-c.so
117         fperms a+x ${INSDESTTREE}/pypy-c ${INSDESTTREE}/libpypy-c.so
118         pax-mark m "${ED%/}${INSDESTTREE}/pypy-c" "${ED%/}${INSDESTTREE}/libpypy-c.so"
119         dosym ../$(get_libdir)/pypy3/pypy-c /usr/bin/pypy3
120         dodoc README.rst
121
122         if ! use gdbm; then
123                 rm -r "${ED%/}${INSDESTTREE}"/lib_pypy/gdbm.py \
124                         "${ED%/}${INSDESTTREE}"/lib-python/*3/test/test_gdbm.py || die
125         fi
126         if ! use sqlite; then
127                 rm -r "${ED%/}${INSDESTTREE}"/lib-python/*3/sqlite3 \
128                         "${ED%/}${INSDESTTREE}"/lib_pypy/_sqlite3.py \
129                         "${ED%/}${INSDESTTREE}"/lib-python/*3/test/test_sqlite.py || die
130         fi
131         if ! use tk; then
132                 rm -r "${ED%/}${INSDESTTREE}"/lib-python/*3/{idlelib,tkinter} \
133                         "${ED%/}${INSDESTTREE}"/lib_pypy/_tkinter \
134                         "${ED%/}${INSDESTTREE}"/lib-python/*3/test/test_{tcl,tk,ttk*}.py || die
135         fi
136
137         # Install docs
138         #use doc && dohtml -r pypy/doc/_build/html/
139
140         einfo "Generating caches and byte-compiling ..."
141
142         python_export pypy3 EPYTHON PYTHON PYTHON_SITEDIR
143         local PYTHON=${ED%/}${INSDESTTREE}/pypy-c
144         local -x LD_LIBRARY_PATH="${ED%/}${INSDESTTREE}"
145
146         echo "EPYTHON='${EPYTHON}'" > epython.py
147         python_domodule epython.py
148
149         # Generate Grammar and PatternGrammar pickles.
150         "${PYTHON}" -c "import lib2to3.pygram, lib2to3.patcomp; lib2to3.patcomp.PatternCompiler()" \
151                 || die "Generation of Grammar and PatternGrammar pickles failed"
152
153         # Generate cffi cache
154         # Please keep in sync with pypy/tool/release/package.py!
155         "${PYTHON}" -c "import _curses" || die "Failed to import _curses (cffi)"
156         "${PYTHON}" -c "import syslog" || die "Failed to import syslog (cffi)"
157         if use gdbm; then
158                 "${PYTHON}" -c "import _gdbm" || die "Failed to import gdbm (cffi)"
159         fi
160         if use sqlite; then
161                 "${PYTHON}" -c "import _sqlite3" || die "Failed to import _sqlite3 (cffi)"
162         fi
163         if use tk; then
164                 "${PYTHON}" -c "import _tkinter" || die "Failed to import _tkinter (cffi)"
165         fi
166
167         # Cleanup temporary objects
168         find "${ED%/}${INSDESTTREE}" -name "_cffi_*.[co]" -delete || die
169         find "${ED%/}${INSDESTTREE}" -type d -empty -delete || die
170
171         # compile the installed modules
172         python_optimize "${ED%/}${INSDESTTREE}"
173 }