Skip to content

Commit 5be7254

Browse files
committed
[GR-13072] Initial support for running the scipy installation procedure
PullRequest: graalpython/350
2 parents 59c6c6c + 5ffbfa0 commit 5be7254

File tree

8 files changed

+118
-19
lines changed

8 files changed

+118
-19
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
#include "capi.h"
42+
43+
/*
44+
* (tfel): This file provides some of the required signalmodule C API.
45+
*/
46+
47+
int PyErr_CheckSignals() {
48+
// Our signal handlers run asynchrounsly on a JVM thread and any Python code
49+
// that is triggered should propagate it's exceptions
50+
// directly. PyErr_CheckSignals() in CPython only runs pending signal
51+
// handlers and returns. A return value of -1 indicates an exception, but we
52+
// assume that any exception would be raised in a different code path.
53+
return 0;
54+
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,18 @@ Object stat(String path, boolean followSymlinks) {
424424
} else if (f.isSymbolicLink()) {
425425
mode |= S_IFLNK;
426426
} else {
427-
// TODO: differentiate these
428-
mode |= S_IFSOCK | S_IFBLK | S_IFCHR | S_IFIFO;
427+
// TODO: remove the additional check for symlink once GR-13265 is fixed
428+
TruffleFile canonicalFile = null;
429+
try {
430+
canonicalFile = f.getCanonicalFile();
431+
} catch (IOException e) {
432+
}
433+
if (!f.getAbsoluteFile().equals(canonicalFile)) {
434+
mode |= S_IFLNK;
435+
} else {
436+
// TODO: differentiate these
437+
mode |= S_IFSOCK | S_IFBLK | S_IFCHR | S_IFIFO;
438+
}
429439
}
430440
try {
431441
mtime = fileTimeToSeconds(f.getLastModifiedTime(linkOptions));

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,21 +385,31 @@ abstract static class ContainsNode extends PythonBinaryBuiltinNode {
385385
@Child private SequenceStorageNodes.LenNode lenNode;
386386

387387
@Specialization
388-
@TruffleBoundary
389388
boolean contains(PBytes self, PBytes other,
390389
@Cached("create()") BytesNodes.FindNode findNode) {
391390
return findNode.execute(self, other, 0, getLength(self.getSequenceStorage())) != -1;
392391
}
393392

394393
@Specialization
395-
@TruffleBoundary
396394
boolean contains(PBytes self, PByteArray other,
397395
@Cached("create()") BytesNodes.FindNode findNode) {
398396
return findNode.execute(self, other, 0, getLength(self.getSequenceStorage())) != -1;
399397
}
400398

401-
@Specialization(guards = "!isBytes(other)")
402-
boolean contains(@SuppressWarnings("unused") PBytes self, Object other) {
399+
@Specialization
400+
boolean contains(PBytes self, int other,
401+
@Cached("create()") BytesNodes.FindNode findNode) {
402+
return findNode.execute(self, other, 0, getLength(self.getSequenceStorage())) != -1;
403+
}
404+
405+
@Specialization
406+
boolean contains(PBytes self, long other,
407+
@Cached("create()") BytesNodes.FindNode findNode) {
408+
return findNode.execute(self, other, 0, getLength(self.getSequenceStorage())) != -1;
409+
}
410+
411+
@Fallback
412+
boolean contains(@SuppressWarnings("unused") Object self, Object other) {
403413
throw raise(TypeError, "a bytes-like object is required, not '%p'", other);
404414
}
405415

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates.
33
* Copyright (c) 2013, Regents of the University of California
44
*
55
* All rights reserved.
@@ -956,7 +956,7 @@ public PList doSplit(String self, String sep, int maxsplit) {
956956

957957
@Specialization
958958
public PList doSplit(String self, @SuppressWarnings("unused") PNone sep, int maxsplit) {
959-
return splitfields(self, maxsplit + 1);
959+
return splitfields(self, maxsplit);
960960
}
961961

962962
@Fallback

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/EmptySequenceStorage.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2019, Oracle and/or its affiliates.
33
* Copyright (c) 2013, Regents of the University of California
44
*
55
* All rights reserved.
@@ -79,8 +79,10 @@ public int length() {
7979

8080
@Override
8181
public void setNewLength(int length) {
82-
CompilerDirectives.transferToInterpreter();
83-
throw PythonLanguage.getContextRef().get().getCore().raise(ValueError, "list length out of range");
82+
if (length != 0) {
83+
CompilerDirectives.transferToInterpreter();
84+
throw PythonLanguage.getContextRef().get().getCore().raise(ValueError, "list length out of range");
85+
}
8486
}
8587

8688
@Override

graalpython/lib-graalpython/modules/ginstall.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@ def system(cmd, msg=""):
5454

5555

5656
def known_packages():
57+
def PyYAML():
58+
install_from_pypi("PyYAML==3.13")
59+
60+
def six():
61+
install_from_pypi("six==1.12.0")
62+
63+
def Cython():
64+
install_from_pypi("Cython==0.29.2", ['--no-cython-compile'])
65+
5766
def setuptools():
58-
install_from_pypi("setuptools")
67+
install_from_pypi("setuptools==40.6.3")
5968

6069
def numpy():
6170
try:
@@ -318,7 +327,7 @@ def xit(msg, status=-1):
318327
exit(-1)
319328

320329

321-
def install_from_pypi(package):
330+
def install_from_pypi(package, extra_opts=[]):
322331
if "==" in package:
323332
package, _, version = package.rpartition("==")
324333
url = "https://pypi.org/pypi/%s/%s/json" % (package, version)
@@ -353,7 +362,7 @@ def install_from_pypi(package):
353362
else:
354363
xit("Unknown file type: %s" % filename)
355364

356-
status = os.system("cd %s/%s; %s setup.py install --user" % (tempdir, dirname, sys.executable))
365+
status = os.system("cd %s/%s; %s setup.py install --user %s" % (tempdir, dirname, sys.executable, " ".join(extra_opts)))
357366
if status != 0:
358367
xit("An error occurred trying to run `setup.py install --user'")
359368
else:

graalpython/lib-graalpython/posix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -53,7 +53,7 @@
5353

5454

5555
@__builtin__
56-
def stat(filename, follow_symlinks=False):
56+
def stat(filename, follow_symlinks=True):
5757
return stat_result(old_stat(filename, follow_symlinks=follow_symlinks))
5858

5959

graalpython/lib-graalpython/time.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -44,7 +44,7 @@ def make_struct_time():
4444
struct_time_type = make_named_tuple_class("struct_time", fields)
4545

4646
class struct_time(struct_time_type):
47-
47+
4848
def __new__(cls, iterable):
4949
def create_struct(iter, zone, gmtoff):
5050
result = tuple.__new__(cls, iter)
@@ -63,7 +63,7 @@ def create_struct(iter, zone, gmtoff):
6363
return create_struct(iterable[0:9], iterable[9], None)
6464
if count == 9:
6565
return create_struct(iterable, None, None)
66-
66+
6767

6868
def __repr__(self):
6969
text = "{}(".format(self.__class__.__name__)
@@ -91,3 +91,17 @@ def gmtime(seconds=None):
9191
@__builtin__
9292
def localtime(seconds=None):
9393
return struct_time(__truffle_localtime_tuple__(seconds))
94+
95+
96+
@__builtin__
97+
def asctime(t=None):
98+
"""
99+
asctime([tuple]) -> string
100+
101+
Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
102+
When the time tuple is not present, current time as returned by localtime()
103+
is used.
104+
"""
105+
if not t:
106+
t = localtime()
107+
return strftime("%a %b %d %H:%M:%S %Y", t)

0 commit comments

Comments
 (0)