Skip to content

Commit d7b367c

Browse files
committed
[GR-13347] Update to PyPy 6.0.0 and merge CPython 3.6.5 again
PullRequest: graalpython/361
2 parents 6e97420 + 92f41f3 commit d7b367c

File tree

4 files changed

+61
-8
lines changed

4 files changed

+61
-8
lines changed

graalpython/com.oracle.graal.python.cext/src/complexobject.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2019, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2017 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -7,7 +7,6 @@
77

88
PyTypeObject PyComplex_Type = PY_TRUFFLE_TYPE("complex", &PyType_Type, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, sizeof(PyComplexObject));
99

10-
static Py_complex c_1 = {1., 0.};
1110
static Py_complex c_error = {-1., 0.};
1211

1312
UPCALL_ID(PyComplex_AsCComplex);
@@ -22,6 +21,21 @@ Py_complex PyComplex_AsCComplex(PyObject *op) {
2221
return c_error;
2322
}
2423

24+
// Below is taken from CPython
25+
26+
/* Complex object implementation */
27+
28+
/* Borrows heavily from floatobject.c */
29+
30+
/* Submitted by Jim Hugunin */
31+
32+
#include "Python.h"
33+
#include "structmember.h"
34+
35+
/* elementary operations on complex numbers */
36+
37+
static Py_complex c_1 = {1., 0.};
38+
2539
Py_complex
2640
_Py_c_sum(Py_complex a, Py_complex b)
2741
{

graalpython/com.oracle.graal.python.cext/src/floatobject.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2019, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2017 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -38,6 +38,19 @@ PyObject* float_subtype_new(PyTypeObject *type, double x) {
3838
return newobj;
3939
}
4040

41+
// Below taken from CPython
42+
43+
/*----------------------------------------------------------------------------
44+
* _PyFloat_{Pack,Unpack}{2,4,8}. See floatobject.h.
45+
* To match the NPY_HALF_ROUND_TIES_TO_EVEN behavior in:
46+
* https://github.com/numpy/numpy/blob/master/numpy/core/src/npymath/halffloat.c
47+
* We use:
48+
* bits = (unsigned short)f; Note the truncation
49+
* if ((f - bits > 0.5) || (f - bits == 0.5 && bits % 2)) {
50+
* bits++;
51+
* }
52+
*/
53+
4154
int
4255
_PyFloat_Pack2(double x, unsigned char *p, int le)
4356
{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This directory exists so that 3rd party packages can be installed
2+
here. Read the source for site.py for more details.

mx.graalpython/mx_graalpython.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ def import_python_sources(args):
667667
mapping = {
668668
"_memoryview.c": "memoryobject.c",
669669
"_cpython_sre.c": "_sre.c",
670+
"_cpython_unicodedata.c": "unicodedata.c",
670671
}
672+
671673
parser = ArgumentParser(prog='mx python-src-import')
672674
parser.add_argument('--cpython', action='store', help='Path to CPython sources', required=True)
673675
parser.add_argument('--pypy', action='store', help='Path to PyPy sources', required=True)
@@ -722,9 +724,11 @@ def import_python_sources(args):
722724
""".format(mapping)
723725
raw_input("Got it?")
724726

725-
files = []
727+
cpy_files = []
728+
pypy_files = []
726729
with open(os.path.join(os.path.dirname(__file__), "copyrights", "overrides")) as f:
727-
files = [line.split(",")[0] for line in f.read().split("\n") if len(line.split(",")) > 1 and line.split(",")[1] == "python.copyright"]
730+
cpy_files = [line.split(",")[0] for line in f.read().split("\n") if len(line.split(",")) > 1 and line.split(",")[1] == "python.copyright"]
731+
pypy_files = [line.split(",")[0] for line in f.read().split("\n") if len(line.split(",")) > 1 and line.split(",")[1] == "pypy.copyright"]
728732

729733
# move to orphaned branch with sources
730734
if SUITE.vc.isDirty(SUITE.dir):
@@ -734,7 +738,28 @@ def import_python_sources(args):
734738
SUITE.vc.git_command(SUITE.dir, ["clean", "-fdx"])
735739
shutil.rmtree("graalpython")
736740

737-
for inlined_file in files:
741+
for inlined_file in pypy_files:
742+
original_file = None
743+
name = os.path.basename(inlined_file)
744+
name = mapping.get(name, name)
745+
if inlined_file.endswith(".py"):
746+
# these files don't need to be updated, they inline some unittest code only
747+
if name.startswith("test_") or name.endswith("_tests.py"):
748+
original_file = inlined_file
749+
else:
750+
for root, dirs, files in os.walk(pypy_sources):
751+
if os.path.basename(name) in files:
752+
original_file = os.path.join(root, name)
753+
try:
754+
os.makedirs(os.path.dirname(inlined_file))
755+
except:
756+
pass
757+
shutil.copy(original_file, inlined_file)
758+
break
759+
if original_file is None:
760+
mx.warn("Could not update %s - original file not found" % inlined_file)
761+
762+
for inlined_file in cpy_files:
738763
# C files are mostly just copied
739764
original_file = None
740765
name = os.path.basename(inlined_file)
@@ -757,8 +782,7 @@ def import_python_sources(args):
757782
mx.warn("Could not update %s - original file not found" % inlined_file)
758783

759784
# re-copy lib-python
760-
libdir = os.path.join(SUITE.dir, "graalpython/lib-python/3")
761-
shutil.copytree(os.path.join(pypy_sources, "lib-python", "3"), libdir)
785+
shutil.copytree(os.path.join(python_sources, "Lib"), _get_stdlib_home())
762786

763787
# commit and check back
764788
SUITE.vc.git_command(SUITE.dir, ["add", "."])

0 commit comments

Comments
 (0)