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 = ...@@ -7,55 +7,79 @@ extends =
../ncurses/buildout.cfg ../ncurses/buildout.cfg
../openssl/buildout.cfg ../openssl/buildout.cfg
../pkgconfig/buildout.cfg ../pkgconfig/buildout.cfg
../python-2.7/buildout.cfg
../sqlite3/buildout.cfg ../sqlite3/buildout.cfg
../zlib/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] [pypy2]
recipe = slapos.recipe.cmmi recipe = slapos.recipe.build
shared = true shared = true
version = 2.7 version = 2.7
executable = @@LOCATION@@/bin/pypy
url = https://downloads.python.org/pypy/pypy${:version}-v7.3.11-src.tar.bz2 url = https://downloads.python.org/pypy/pypy${:version}-v7.3.11-src.tar.bz2
md5sum = 249ad8b0ddffbb16a9d416c3ae85dd2c md5sum = 249ad8b0ddffbb16a9d416c3ae85dd2c
configure-command = pycparser-url = https://github.com/eliben/pycparser/archive/release_v2.21.tar.gz
set lib_pypy/pypy_tools/build_cffi_imports.py pycparser-md5sum = cf4b60f0beca2a25bb599e9e858a8223
sed -i '/"_tkinter",/s/^/#/' lib_pypy/pypy_tools/build_cffi_imports.py init =
cat <<EOF > Makefile import os, sys
PREFIX = %(location)s options['executable'] = os.path.join(location, 'bin', 'pypy')
export PYPY_USESSION_BASENAME=slapos if sys.version_info.major == 2:
export TMPDIR=\$(realpath ..) self.python = sys.executable
all: pypy/goal/pypy-c $1 else:
\$^ # XXX: We don't care which Python 2 we use to build PyPy
c_src_dir: # and we don't want to rebootstrap twice.
cd pypy/goal && PYTHONPATH=${pycparser-shared:location} $${PYTHON:-python2} ../../rpython/bin/rpython --batch --source --opt=jit --shared targetpypystandalone depends = options.depends
ln -s ../usession-\$\$PYPY_USESSION_BASENAME-\$\$USER/testing_1 \$@ options.depends = set(depends)
pypy/goal/pypy-c: c_src_dir self.python = self.buildout['python2.7']['executable']
\$(MAKE) -C \$< options.depends = depends
mv \$</libpypy-c.so \$</pypy-c pypy/goal install =
touch \$@ import os
install: env = self.environ
mkdir -p \$(PREFIX)/bin \$(PREFIX)/include pycparser = self.extract(self.download(
find lib_pypy lib-python/%(version)s -type d '(' '(' -name __pycache__ -o -name _tkinter -o -name test -o -name tests ')' -prune -o -print ')' \ options['pycparser-url'], options['pycparser-md5sum']))
|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 pycparser_lib = os.path.join(pycparser, 'lib')
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 call((self.python, 'setup.py', 'install', '--install-lib', pycparser_lib),
cd lib-python && cp conftest.py stdlib-version.* \$(PREFIX)/lib-python cwd=guessworkdir(pycparser), env=env)
cp -r include/pypy_*.h pypy/module/cpyext/include/* pypy/module/cpyext/parse/* \$(PREFIX)/include pypy_src = guessworkdir(self.extract(self.download()))
cd pypy/goal && cp libpypy-c.so \$(PREFIX)/bin && cp pypy-c \$(PREFIX)/bin/pypy build_cffi_imports = 'lib_pypy/pypy_tools/build_cffi_imports.py'
post-install = version = options['version']
cd '%(location)s/bin' with open(os.path.join(pypy_src, 'Makefile'), 'w') as f:
for x in '' 2 %(version)s f.write(options['makefile'].replace('\n|','\n')[1:] % {
do ln -s pypy python$x 'build_cffi_imports': build_cffi_imports,
done '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 = 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 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 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