Commit 1d823456 authored by Julien Muchembled's avatar Julien Muchembled

Fix bootstrap of PyPy when OS does not have Python 2

parent 690d4bb6
......@@ -7,55 +7,79 @@ extends =
../ncurses/buildout.cfg
../openssl/buildout.cfg
../pkgconfig/buildout.cfg
../python-2.7/buildout.cfg
../sqlite3/buildout.cfg
../zlib/buildout.cfg
[pycparser-shared]
# XXX:
recipe = slapos.recipe.cmmi
shared = true
url = https://github.com/eliben/pycparser/archive/release_v2.21.tar.gz
md5sum = cf4b60f0beca2a25bb599e9e858a8223
configure-command = :
make-binary =
make-targets = $${PYTHON:-python2} setup.py install --install-lib %(location)s
[pypy2]
recipe = slapos.recipe.cmmi
recipe = slapos.recipe.build
shared = true
version = 2.7
executable = @@LOCATION@@/bin/pypy
url = https://downloads.python.org/pypy/pypy${:version}-v7.3.11-src.tar.bz2
md5sum = 249ad8b0ddffbb16a9d416c3ae85dd2c
configure-command =
set lib_pypy/pypy_tools/build_cffi_imports.py
sed -i '/"_tkinter",/s/^/#/' lib_pypy/pypy_tools/build_cffi_imports.py
cat <<EOF > Makefile
PREFIX = %(location)s
export PYPY_USESSION_BASENAME=slapos
export TMPDIR=\$(realpath ..)
all: pypy/goal/pypy-c $1
\$^
c_src_dir:
cd pypy/goal && PYTHONPATH=${pycparser-shared:location} $${PYTHON:-python2} ../../rpython/bin/rpython --batch --source --opt=jit --shared targetpypystandalone
ln -s ../usession-\$\$PYPY_USESSION_BASENAME-\$\$USER/testing_1 \$@
pypy/goal/pypy-c: c_src_dir
\$(MAKE) -C \$<
mv \$</libpypy-c.so \$</pypy-c pypy/goal
touch \$@
install:
mkdir -p \$(PREFIX)/bin \$(PREFIX)/include
find lib_pypy lib-python/%(version)s -type d '(' '(' -name __pycache__ -o -name _tkinter -o -name test -o -name tests ')' -prune -o -print ')' \
|while read d; do mkdir -p \$(PREFIX)/\$\$d && find \$\$d -maxdepth 1 -type f ! -name '*.o' ! -name '*.c' |xargs -r cp -t \$(PREFIX)/\$\$d; done
d=lib-python/%(version)s/test && mkdir -p \$(PREFIX)/\$\$d && for x in __init__ pystone regrtest test_support; do echo \$\$d/\$\$x.py; done |xargs -r cp -t \$(PREFIX)/\$\$d
cd lib-python && cp conftest.py stdlib-version.* \$(PREFIX)/lib-python
cp -r include/pypy_*.h pypy/module/cpyext/include/* pypy/module/cpyext/parse/* \$(PREFIX)/include
cd pypy/goal && cp libpypy-c.so \$(PREFIX)/bin && cp pypy-c \$(PREFIX)/bin/pypy
post-install =
cd '%(location)s/bin'
for x in '' 2 %(version)s
do ln -s pypy python$x
done
pycparser-url = https://github.com/eliben/pycparser/archive/release_v2.21.tar.gz
pycparser-md5sum = cf4b60f0beca2a25bb599e9e858a8223
init =
import os, sys
options['executable'] = os.path.join(location, 'bin', 'pypy')
if sys.version_info.major == 2:
self.python = sys.executable
else:
# XXX: We don't care which Python 2 we use to build PyPy
# and we don't want to rebootstrap twice.
depends = options.depends
options.depends = set(depends)
self.python = self.buildout['python2.7']['executable']
options.depends = depends
install =
import os
env = self.environ
pycparser = self.extract(self.download(
options['pycparser-url'], options['pycparser-md5sum']))
pycparser_lib = os.path.join(pycparser, 'lib')
call((self.python, 'setup.py', 'install', '--install-lib', pycparser_lib),
cwd=guessworkdir(pycparser), env=env)
pypy_src = guessworkdir(self.extract(self.download()))
build_cffi_imports = 'lib_pypy/pypy_tools/build_cffi_imports.py'
version = options['version']
with open(os.path.join(pypy_src, 'Makefile'), 'w') as f:
f.write(options['makefile'].replace('\n|','\n')[1:] % {
'build_cffi_imports': build_cffi_imports,
'location': location,
'pycparser': pycparser_lib,
'python': self.python,
'version': version,
})
for cmd in ( ('sed', '-i', '/"_tkinter",/s/^/#/', build_cffi_imports)
, ('make',)
, ('make', 'install')
):
call(cmd, cwd=pypy_src, env=env)
for x in '', version[0], version:
os.symlink('pypy', os.path.join(location, 'bin', 'python' + x))
# WKRD: Buildout does not preserve leading tabs in .installed.cfg
# so prefix with a dummy character.
makefile =
|PREFIX = %(location)s
|export PYPY_USESSION_BASENAME=slapos
|export TMPDIR=$(realpath ..)
|all: pypy/goal/pypy-c %(build_cffi_imports)s
| $^
|c_src_dir:
| cd pypy/goal && PYTHONPATH=%(pycparser)s %(python)s ../../rpython/bin/rpython --batch --source --opt=jit --shared targetpypystandalone
| ln -s ../usession-$$PYPY_USESSION_BASENAME-$$USER/testing_1 $@
|pypy/goal/pypy-c: c_src_dir
| $(MAKE) -C $<
| mv $</libpypy-c.so $</pypy-c pypy/goal
| touch $@
|install:
| mkdir -p $(PREFIX)/bin $(PREFIX)/include
| find lib_pypy lib-python/%(version)s -type d '(' '(' -name __pycache__ -o -name _tkinter -o -name test -o -name tests ')' -prune -o -print ')' \
| |while read d; do mkdir -p $(PREFIX)/$$d && find $$d -maxdepth 1 -type f ! -name '*.o' ! -name '*.c' |xargs -r cp -t $(PREFIX)/$$d; done
| d=lib-python/%(version)s/test && mkdir -p $(PREFIX)/$$d && for x in __init__ pystone regrtest test_support; do echo $$d/$$x.py; done |xargs -r cp -t $(PREFIX)/$$d
| cd lib-python && cp conftest.py stdlib-version.* $(PREFIX)/lib-python
| cp -r include/pypy_*.h pypy/module/cpyext/include/* pypy/module/cpyext/parse/* $(PREFIX)/include
| cd pypy/goal && cp libpypy-c.so $(PREFIX)/bin && cp pypy-c $(PREFIX)/bin/pypy
environment =
C_INCLUDE_PATH=${bzip2:location}/include:${gdbm:location}/include:${libexpat:location}/include:${ncurses:location}/include:${ncurses:location}/include:${openssl:location}/include:${sqlite3:location}/include:${zlib:location}/include
LDFLAGS=-L${bzip2:location}/lib -L${gdbm:location}/lib -L${libexpat:location}/lib -L${libffi:location}/lib -L${ncurses:location}/lib -L${openssl:location}/lib -L${sqlite3:location}/lib -L${zlib:location}/lib -Wl,-rpath=${bzip2:location}/lib -Wl,-rpath=${gdbm:location}/lib -Wl,-rpath=${libexpat:location}/lib -Wl,-rpath=${libffi:location}/lib -Wl,-rpath=${ncurses:location}/lib -Wl,-rpath=${openssl:location}/lib -Wl,-rpath=${sqlite3:location}/lib -Wl,-rpath=${zlib:location}/lib
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment