Read about our upcoming Code of Conduct on this issue

Commit e5ca99fb authored by Matti Picus's avatar Matti Picus
Browse files

backport changes from py3.6 to minimize diff

parent b3fa16549942
......@@ -24,7 +24,19 @@ cffi_build_scripts = {
# the OS, such as a recent openssl/libressl.
curdir = os.path.abspath(os.path.dirname(__file__))
deps_destdir = os.path.join(curdir, 'dest')
configure_args = ['./configure',
'--prefix=/usr',
'--disable-shared',
'--enable-silent-rules',
'--disable-dependency-tracking',
]
cffi_dependencies = {
'lzma': ('https://tukaani.org/xz/xz-5.2.3.tar.gz',
'71928b357d0a09a12a4b4c5fafca8c31c19b0e7d3b8ebb19622e96f26dbf28cb',
[configure_args,
['make', '-s', '-j', str(multiprocessing.cpu_count())],
['make', 'install', 'DESTDIR={}/'.format(deps_destdir)],
]),
'_ssl': ('https://www.openssl.org/source/openssl-1.1.1c.tar.gz',
'f6fb3079ad15076154eda9413fed42877d668e7069d9b87396d0804fdb3f4c90',
[['./config', '--prefix=/usr', 'no-shared'],
......@@ -33,7 +45,7 @@ cffi_dependencies = {
]),
'_gdbm': ('http://ftp.gnu.org/gnu/gdbm/gdbm-1.13.tar.gz',
'9d252cbd7d793f7b12bcceaddda98d257c14f4d1890d851c386c37207000a253',
[['./config', '--without-readline'],
[configure_args,
['make', '-s', '-j', str(multiprocessing.cpu_count())],
['make', 'install', 'DESTDIR={}/'.format(deps_destdir)],
]),
......@@ -176,8 +188,11 @@ def create_cffi_import_libraries(pypy_c, options, basedir, only=None,
status, stdout, stderr = run_subprocess(str(pypy_c), args,
cwd=cwd, env=env)
if status != 0:
print(stdout, stderr, file=sys.stderr)
failures.append((key, module))
print("stdout:")
print(stdout, file=sys.stderr)
print("stderr:")
print(stderr, file=sys.stderr)
except:
import traceback;traceback.print_exc()
failures.append((key, module))
......
......@@ -30,6 +30,8 @@ USE_ZIPFILE_MODULE = sys.platform == 'win32'
STDLIB_VER = "2.7"
POSIX_EXE = 'pypy'
from pypy.tool.build_cffi_imports import (create_cffi_import_libraries,
MissingDependenciesError, cffi_build_scripts)
......@@ -71,7 +73,7 @@ def create_package(basedir, options, _fake=False):
basedir = py.path.local(basedir)
if not override_pypy_c:
basename = 'pypy-c'
basename = POSIX_EXE + '-c'
if sys.platform == 'win32':
basename += '.exe'
pypy_c = basedir.join('pypy', 'goal', basename)
......@@ -106,10 +108,13 @@ def create_package(basedir, options, _fake=False):
if (sys.platform != 'win32' and # handled below
not _fake and os.path.getsize(str(pypy_c)) < 500000):
# This pypy-c is very small, so it means it relies on libpypy_c.so.
# This 'pypy_c' is very small, so it means it relies on a so/dll
# If it would be bigger, it wouldn't. That's a hack.
libpypy_name = ('libpypy-c.so' if not sys.platform.startswith('darwin')
else 'libpypy-c.dylib')
if sys.platform.startswith('darwin'):
ext = 'dylib'
else:
ext = 'so'
libpypy_name = 'lib' + POSIX_EXE + '-c.' + ext
libpypy_c = pypy_c.new(basename=libpypy_name)
if not libpypy_c.check():
raise PyPyCNotFound('Expected pypy to be mostly in %r, but did '
......@@ -134,8 +139,9 @@ def create_package(basedir, options, _fake=False):
tgt = py.path.local(tgt)
binaries.append((pypyw, tgt.new(purebasename=tgt.purebasename + 'w').basename, None))
print("Picking %s" % str(pypyw))
# Can't rename a DLL: it is always called 'libpypy-c.dll'
win_extras = [('libpypy-c.dll', None), ('sqlite3.dll', lib_pypy)]
# Can't rename a DLL
win_extras = [('lib' + POSIX_EXE + '-c.dll', None),
('sqlite3.dll', lib_pypy)]
if not options.no_tk:
tkinter_dir = lib_pypy.join('_tkinter')
win_extras += [('tcl85.dll', tkinter_dir), ('tk85.dll', tkinter_dir)]
......@@ -155,9 +161,7 @@ def create_package(basedir, options, _fake=False):
print('Picking %s (and contents)' % libsdir)
shutil.copytree(str(libsdir), str(pypydir.join('libs')))
else:
print('"libs" dir with import library not found.')
print('You have to create %r' % (str(libsdir),))
print('and copy libpypy-c.lib in there, renamed to python27.lib')
raise RuntimError('"libs" dir with import library not found.')
# XXX users will complain that they cannot compile capi (cpyext)
# modules for windows, also embedding pypy (i.e. in cffi)
# will fail.
......@@ -223,6 +227,14 @@ def create_package(basedir, options, _fake=False):
else:
open(str(archive), 'wb').close()
os.chmod(str(archive), 0755)
#if not _fake and not sys.platform == 'win32':
# # create the pypy3 symlink
# old_dir = os.getcwd()
# os.chdir(str(bindir))
# try:
# os.symlink(POSIX_EXE, 'pypy3')
# finally:
# os.chdir(old_dir)
fix_permissions(pypydir)
old_dir = os.getcwd()
......@@ -292,9 +304,9 @@ def package(*args, **kwds):
setattr(ns, self.dest, option[2:4] != 'no')
if sys.platform == 'win32':
pypy_exe = 'pypy.exe'
pypy_exe = POSIX_EXE + '.exe'
else:
pypy_exe = 'pypy'
pypy_exe = POSIX_EXE
parser = argparse.ArgumentParser()
args = list(args)
if args:
......
import os
import py
from pypy import pypydir
from pypy.tool.release import package
......@@ -15,8 +15,8 @@ class TestPackaging:
cls.exe_name_in_archive = 'pypy-c.exe'
else:
basename = 'pypy-c'
cls.rename_pypy_c = 'pypy'
cls.exe_name_in_archive = 'bin/pypy'
cls.rename_pypy_c = package.POSIX_EXE
cls.exe_name_in_archive = os.path.join('bin', package.POSIX_EXE)
cls.pypy_c = py.path.local(pypydir).join('goal', basename)
def test_dir_structure(self, test='test'):
......
......@@ -601,6 +601,11 @@ class NumberStringParser:
assert i >= self.start
self.i = i
c = self.s[i]
if self.allow_underscores and c == '_':
i = self.i - 1
assert i >= 0
self.i = i
c = self.s[i]
digit = ord(c)
if '0' <= c <= '9':
digit -= ord('0')
......
......@@ -114,6 +114,7 @@ class CConfig:
WC_NO_BEST_FIT_CHARS STD_INPUT_HANDLE STD_OUTPUT_HANDLE
STD_ERROR_HANDLE HANDLE_FLAG_INHERIT FILE_TYPE_CHAR
LOAD_WITH_ALTERED_SEARCH_PATH
CP_ACP CP_UTF8 CP_UTF7 CP_OEMCP MB_ERR_INVALID_CHARS
"""
from rpython.translator.platform import host_factory
static_platform = host_factory()
......
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