Name: pypy Version: 1.4 Release: 3%{?dist} Summary: Implementation of the Python language, using Python itself Group: Development/Languages # LGPL and another free license we'd need to ask spot about are present in some # java jars that we're not building with atm (in fact, we're deleting them # before building). If we restore those we'll have to work out the new # licensing terms License: MIT and Python and UCD URL: http://pypy.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # High-level configuration of the build: # How many different builds do we want? # A build of pypy-jit on i686 took 77 mins: # [Timer] Timings: # [Timer] annotate --- 583.3 s # [Timer] rtype_lltype --- 760.9 s # [Timer] pyjitpl_lltype --- 567.3 s # [Timer] backendopt_lltype --- 375.6 s # [Timer] stackcheckinsertion_lltype --- 54.1 s # [Timer] database_c --- 852.2 s # [Timer] source_c --- 1007.3 s # [Timer] compile_c --- 419.9 s # [Timer] =========================================== # [Timer] Total: --- 4620.5 s # # A build of pypy-nojit on x86_64 took about an hour: # [Timer] Timings: # [Timer] annotate --- 537.5 s # [Timer] rtype_lltype --- 667.3 s # [Timer] backendopt_lltype --- 385.4 s # [Timer] stackcheckinsertion_lltype --- 42.5 s # [Timer] database_c --- 625.3 s # [Timer] source_c --- 1040.2 s # [Timer] compile_c --- 273.9 s # [Timer] =========================================== # [Timer] Total: --- 3572.0 s # # # A build of pypy-sandbox on i686 took about 40 mins: # [Timer] Timings: # [Timer] annotate --- 436.4 s # [Timer] rtype_lltype --- 452.6 s # [Timer] backendopt_lltype --- 267.2 s # [Timer] stackcheckinsertion_lltype --- 26.1 s # [Timer] database_c --- 317.6 s # [Timer] source_c --- 635.4 s # [Timer] compile_c --- 270.3 s # [Timer] =========================================== # [Timer] Total: --- 2405.5 s # # A build of pypy-stackless on i686 took about 87 mins: # [Timer] Timings: # [Timer] annotate --- 584.2 s # [Timer] rtype_lltype --- 777.3 s # [Timer] backendopt_lltype --- 365.9 s # [Timer] stackcheckinsertion_lltype --- 39.3 s # [Timer] database_c --- 1089.6 s # [Timer] source_c --- 1868.6 s # [Timer] compile_c --- 490.4 s # [Timer] =========================================== # [Timer] Total: --- 5215.3 s # # giving a total build time of about # 77 + 60 + 40 + 87 = 264 mins = 4.5 hours with the jit # or 3.25 hours without the jit # Should we build a "pypy-jit" binary? # pypy-1.2/pypy/jit/backend/detect_cpu.py:getcpuclass currently supports the # following options: # 'i386', 'x86' # 'x86-without-sse2': # 'cli' # 'llvm' # We may eventually want 'llvm' on x86_64 for the jit build; # turning off for now for simplicity %ifarch %{ix86} x86_64 # FIXME: is there a better way of expressing "intel" here? %global with_jit 1 %else %global with_jit 0 %endif # Should we build a "pypy-nojit" binary? %global with_nojit 1 # Should we build a "pypy-sandbox" binary? %global with_sandbox 1 # Should we build a "pypy-stackless" binary? %global with_stackless 1 # Turn off the brp-python-bytecompile script for now; ultimately we'll want to # precompile the .pyc files using one of the freshly built pypy binaries %global __os_install_post \ %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') # pypy uses .pyc files be default (--objspace-usepycfiles) # and pypy-1.2/pypy/module/imp/importing.py has this comment: # XXX picking a magic number is a mess. So far it works because we # have only two extra opcodes, which bump the magic number by +1 and # +2 respectively, and CPython leaves a gap of 10 when it increases # its own magic number. To avoid assigning exactly the same numbers # as CPython we always add a +2. We'll have to think again when we # get at the fourth new opcode :-( # # * CALL_LIKELY_BUILTIN +1 # * CALL_METHOD +2 # # In other words: # # default_magic -- used by CPython without the -U option # default_magic + 1 -- used by CPython with the -U option # default_magic + 2 -- used by PyPy without any extra opcode # ... # default_magic + 5 -- used by PyPy with both extra opcodes # # Source and patches: Source0: http://pypy.org/download/pypy-%{version}-src.tar.bz2 # Edit a translator file for linux in order to configure our cflags and dynamic libffi Patch0: pypy-1.4-config.patch # By default, if built at a tty, the translation process renders a Mandelbrot # set to indicate progress. # This obscures useful messages, and may waste CPU cycles, so suppress it, and # merely render dots: Patch1: pypy-1.2-suppress-mandelbrot-set-during-tty-build.patch # Build-time requirements: BuildRequires: python-devel # FIXME: I'm seeing errors like this in the logs: # [translation:WARNING] The module '_rawffi' is disabled # [translation:WARNING] because importing pypy.rlib.libffi raised ImportError # [translation:WARNING] 'libffi.a' not found in ['/usr/lib/libffi', '/usr/lib'] # Presumably we need to fix things to support dynamically-linked libffi BuildRequires: libffi-devel BuildRequires: zlib-devel BuildRequires: bzip2-devel BuildRequires: ncurses-devel BuildRequires: expat-devel BuildRequires: openssl-devel BuildRequires: valgrind-devel # pypy is bundling these so we delete them in %%prep. I don't think they are # needed unless we build pypy targetted at running on the jvm. #BuildRequires: jna #BuildRequires: jasmin # Not yet in Fedora %description pypy is a reimplementation of the Python language in Python itself, which is then compiled into implementations with particular properties. %package libs Group: Development/Languages Summary: Run-time libraries used by PyPy implementations of Python %description libs Libraries required by the various PyPy implementations of Python. %if 0%{with_jit} %package jit Group: Development/Languages Summary: Python implementation with a Just-In-Time compiler Requires: pypy-libs = %{version}-%{release} %description jit Python implementation with a Just-In-Time compiler %endif %if 0%{with_nojit} %package nojit Group: Development/Languages Summary: Python interpreter built using PyPy Requires: pypy-libs = %{version}-%{release} %description nojit This is a Python interpreter built using PyPy, without a Just-in-Time compiler. It is typically slower than CPython, but may use 1.5x or 2x less RAM for programs requiring hundred of MB to run. %endif %if 0%{with_sandbox} %package sandbox Group: Development/Languages Summary: Sandboxed Python interpreter built using PyPy Requires: pypy-libs = %{version}-%{release} %description sandbox Experimental build of PyPy that replace all calls to external libraries (C or platform) with a stub that communicates with an external process handling the policy. %endif %if 0%{with_stackless} %package stackless Group: Development/Languages Summary: Stackless Python interpreter built using PyPy Requires: pypy-libs = %{version}-%{release} %description stackless Build of PyPy with support for micro-threads for massive concurrency %endif %prep %setup -q %patch0 -p1 -b .configure-fedora %patch1 -p1 -b .suppress-mandelbrot-set-during-tty-build # Replace /usr/local/bin/python shebangs with /usr/bin/python: find -name "*.py" -exec \ sed \ -i -e "s|/usr/local/bin/python|/usr/bin/python|" \ "{}" \ \; find . -name '*.jar' -exec rm \{\} \; %build BuildPyPy() { ExeName=$1 Options=$2 echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" echo "STARTING BUILD OF: $ExeName" echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" pushd pypy/translator/goal # For now, filter our CFLAGS of everything that could be conflicting with # pypy. Need to check these and reenable ones that are okay later. export CFLAGS=$(echo "$RPM_OPT_FLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//' -e 's/-fexceptions//' -e 's/-fstack-protector//' -e 's/--param=ssp-buffer-size=4//' -e 's/-O2//' -e 's/-g//' -e 's/-fasynchronous-unwind-tables//' -e 's/-march=i686//' -e 's/-mtune=atom//') # The generated binary embeds copies of the values of all environment # variables. We need to unset "RPM_BUILD_ROOT" to avoid a fatal error from # /usr/lib/rpm/check-buildroot # during the postprocessing of the rpmbuild, complaining about this # reference to the buildroot # By default, pypy's autogenerated C code is placed in # /tmp/usession-N # # and it appears that this stops rpm from extracting the source code to the # debuginfo package # # The logic in pypy-1.2/pypy/tool/udir.py indicates that it is generated in: # $PYPY_USESSION_DIR/usession-$PYPY_USESSION_BASENAME-N # and so we set PYPY_USESSION_DIR so that this tempdir is within the build # location, and set $PYPY_USESSION_BASENAME so that the tempdir is unique # for each invocation of BuildPyPy if test -x './pypy-jit' ; then INTERP='./pypy-jit' else INTERP='python' fi time \ RPM_BUILD_ROOT= \ PYPY_USESSION_DIR=$(pwd) \ PYPY_USESSION_BASENAME=$ExeName \ $INTERP translate.py \ --cflags="$CFLAGS" \ --batch \ --output=$ExeName \ $Options echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" echo "FINISHED BUILDING: $ExeName" echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" echo "--------------------------------------------------------------" popd } %if 0%{with_jit} BuildPyPy \ pypy-jit \ "-Ojit" %endif %if 0%{with_nojit} BuildPyPy \ pypy-nojit \ "-O2" %endif %if 0%{with_sandbox} BuildPyPy \ pypy-sandbox \ "--sandbox" %endif %if 0%{with_stackless} BuildPyPy \ pypy-stackless \ "--stackless" %endif %install rm -rf $RPM_BUILD_ROOT # Install the various executables: InstallPyPy() { ExeName=$1 install -m 755 pypy/translator/goal/$ExeName %{buildroot}/%{_bindir} } mkdir -p %{buildroot}/%{_bindir} %if 0%{with_jit} InstallPyPy pypy-jit %endif %if 0%{with_nojit} InstallPyPy pypy-nojit %endif %if 0%{with_sandbox} InstallPyPy pypy-sandbox %endif %if 0%{with_stackless} InstallPyPy pypy-stackless %endif # Install the various support libraries as described at: # http://codespeak.net/pypy/dist/pypy/doc/getting-started-python.html#installation # which refers to a "PREFIX" found relative to the location of the binary. # Given that the pypy binaries will be in /usr/bin, PREFIX can be # "../share/pypy-1.2" relative to that directory, i.e. /usr/share/pypy-1.2 # # Running "strace" on a built binary indicates that it searches within # PREFIX/lib-python/modified-2.5.2 # not # PREFIX/lib-python/modified.2.5.2 # as given on the above page, i.e. it uses '-' not '.' %global pypyprefix %{_datadir}/pypy-%{version} %global pylibver 2.5.2 mkdir -p %{buildroot}/%{pypyprefix} cp -a lib-python %{buildroot}/%{pypyprefix} cp -a lib_pypy %{buildroot}/%{pypyprefix} # Remove a text file that documents which selftests fail on Win32: rm %{buildroot}/%{pypyprefix}/lib-python/win32-failures.txt mkdir -p %{buildroot}/%{pypyprefix}/site-packages %clean rm -rf $RPM_BUILD_ROOT %files libs %defattr(-,root,root,-) %doc LICENSE README demo %dir %{pypyprefix} %dir %{pypyprefix}/lib-python %{pypyprefix}/lib-python/%{pylibver}/ %{pypyprefix}/lib-python/modified-%{pylibver}/ %{pypyprefix}/lib-python/conftest.py %{pypyprefix}/lib_pypy/ %{pypyprefix}/site-packages/ %if 0%{with_jit} %files jit %defattr(-,root,root,-) %{_bindir}/pypy-jit %endif %if 0%{with_nojit} %files nojit %defattr(-,root,root,-) %{_bindir}/pypy-nojit %endif %if 0%{with_sandbox} %files sandbox %defattr(-,root,root,-) %{_bindir}/pypy-sandbox %endif %if 0%{with_stackless} %files stackless %defattr(-,root,root,-) %{_bindir}/pypy-stackless %endif %changelog * Sun Nov 28 2010 Toshio Kuratomi - 1.4-3 - BuildRequire valgrind-devel - Install pypy library from the new directory - Disable building with our CFLAGS for now because they are causing a build failure. - Include site-packages directory * Sat Nov 27 2010 Toshio Kuratomi - 1.4-2 - Add patch to configure the build to use our CFLAGS and link libffi dynamically * Sat Nov 27 2010 Toshio Kuratomi - 1.4-1 - Update to 1.4 - Drop patch for py2.6 that's in this build - Switch to building pypy with itself once pypy is built once as recommended by upstream - Remove bundled, prebuilt java libraries - Fix license tag - Fix source url - Version pypy-libs Req * Tue May 4 2010 David Malcolm - 1.2-2 - cherrypick r72073 from upstream SVN in order to fix the build against python 2.6.5 (patch 2) * Wed Apr 28 2010 David Malcolm - 1.2-1 - initial packaging