Skip to content

Commit a59656e

Browse files
committed
[GR-13074] Install setuptools from source
PullRequest: graalpython/332
2 parents 7e15bd1 + c078969 commit a59656e

File tree

11 files changed

+71
-21
lines changed

11 files changed

+71
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ public Object next(Object iterator, PNone defaultObject,
12781278
return next.execute(iterator);
12791279
} catch (PException e) {
12801280
e.expectAttributeError(errorProfile);
1281-
throw raise(TypeError, "'%p' object is not an iterator", iterator);
1281+
throw raise(TypeError, e.getExceptionObject(), "'%p' object is not an iterator", iterator);
12821282
}
12831283
}
12841284

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/zipimporter/ZipImporterBuiltins.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,15 @@ public PBytes doit(PZipImporter self, String pathname) {
328328
ZipFile zip = new ZipFile(archive);
329329
ZipEntry entry = zip.getEntry(key);
330330
InputStream in = zip.getInputStream(entry);
331-
byte[] bytes = new byte[(int) fileSize];
332-
in.read(bytes);
331+
int byteSize = (int) fileSize;
332+
if (byteSize != fileSize) {
333+
throw raise(PythonErrorType.ZipImportError, "zipimport: cannot read archive members large than 2GB");
334+
}
335+
byte[] bytes = new byte[byteSize];
336+
int bytesRead = 0;
337+
while (bytesRead < byteSize) {
338+
bytesRead += in.read(bytes, bytesRead, byteSize - bytesRead);
339+
}
333340
in.close();
334341
return factory().createBytes(bytes);
335342
} catch (IOException e) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PNodeWithContext.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.oracle.graal.python.builtins.objects.exception.PBaseException;
4646
import com.oracle.graal.python.builtins.objects.type.LazyPythonClass;
4747
import com.oracle.graal.python.builtins.objects.type.PythonClass;
48+
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
4849
import com.oracle.graal.python.runtime.PythonContext;
4950
import com.oracle.graal.python.runtime.PythonCore;
5051
import com.oracle.graal.python.runtime.exception.PException;
@@ -62,6 +63,7 @@
6263

6364
public abstract class PNodeWithContext extends Node {
6465
@Child private PythonObjectFactory factory;
66+
@Child private WriteAttributeToObjectNode writeCause;
6567
@CompilationFinal private ContextReference<PythonContext> contextRef;
6668

6769
protected final PythonObjectFactory factory() {
@@ -88,6 +90,17 @@ public PException raise(LazyPythonClass exceptionType) {
8890
throw raise(factory().createBaseException(exceptionType));
8991
}
9092

93+
public final PException raise(PythonBuiltinClassType type, PBaseException cause, String format, Object... arguments) {
94+
assert format != null;
95+
PBaseException baseException = factory().createBaseException(type, format, arguments);
96+
if (writeCause == null) {
97+
CompilerDirectives.transferToInterpreterAndInvalidate();
98+
writeCause = insert(WriteAttributeToObjectNode.create());
99+
}
100+
writeCause.execute(baseException, SpecialAttributeNames.__CAUSE__, cause);
101+
throw raise(baseException);
102+
}
103+
91104
public final PException raise(PythonBuiltinClassType type, String format, Object... arguments) {
92105
assert format != null;
93106
throw raise(factory().createBaseException(type, format, arguments));

graalpython/lib-graalpython/bytearray.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ def strip(self, what=None):
4747

4848

4949
bytearray.strip = strip
50+
bytearray.rfind = bytes.rfind

graalpython/lib-graalpython/itertools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ class starmap():
8080
"""
8181
def __init__(self, fun, iterable):
8282
self.fun = fun
83-
self.iterable = iterable
83+
self.iterable = iter(iterable)
8484

8585
def __iter__(self):
8686
return self
8787

8888
def __next__(self):
8989
obj = next(self.iterable)
90-
return self.fun(obj)
90+
return self.fun(*obj)
9191

9292

9393
class islice(object):

graalpython/lib-graalpython/sys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def make_implementation_info():
4545
return SimpleNamespace(
4646
name="graalpython",
4747
cache_tag="graalpython",
48-
version_info=version_info_type(version_info),
48+
version=version_info_type(version_info),
4949
_multiarch=__gmultiarch
5050
)
5151
implementation = make_implementation_info()
5252
del make_implementation_info
5353
del __gmultiarch
54-
version_info = implementation.version_info
54+
version_info = implementation.version
5555

5656

5757
def make_flags_class():

graalpython/lib-graalpython/zipimport.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@
3939

4040
import sys
4141
sys.path_hooks.append(zipimporter)
42+
43+
44+
zipimporter.create_module = lambda self, spec: None
45+
zipimporter.exec_module = lambda self, module: exec(self.get_code(module.__name__), module.__dict__)

graalpython/lib-python/3/distutils/command/install.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
INSTALL_SCHEMES = {
3131
'unix_prefix': {
32-
'purelib': '$base/lib/python$py_version_short/site-packages',
33-
'platlib': '$platbase/lib/python$py_version_short/site-packages',
32+
'purelib': '$base/lib-python/$py_version_major/site-packages',
33+
'platlib': '$platbase/lib-python/$py_version_major/site-packages',
3434
'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
3535
'scripts': '$base/bin',
3636
'data' : '$base',
@@ -291,6 +291,7 @@ def finalize_options(self):
291291
'dist_version': self.distribution.get_version(),
292292
'dist_fullname': self.distribution.get_fullname(),
293293
'py_version': py_version,
294+
'py_version_major': '%d' % sys.version_info[0],
294295
'py_version_short': '%d.%d' % sys.version_info[:2],
295296
'py_version_nodot': '%d%d' % sys.version_info[:2],
296297
'sys_prefix': prefix,

graalpython/lib-python/3/site-packages/.keep

Whitespace-only changes.

graalpython/site-packages/Makefile

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
.PHONY: clean install
22

3-
SHELL = /bin/bash
4-
SITE_PATH = ../lib-python/3/site-packages
5-
SETUPTOOLS_VERSION = 40.4.3
63

7-
default: install
4+
SETUPTOOLS_VERSION = 40.6.3
5+
PYTHON_VERSION = 3.7
6+
7+
SETUPTOOLS_DIR = setuptools-${SETUPTOOLS_VERSION}
8+
IN_SETUPTOOLS_DIR = cd ${SETUPTOOLS_DIR} &&
9+
SITE_PATH = ../lib-python/3/site-packages/
10+
811

9-
install: ${SITE_PATH} ${SITE_PATH}/setuptools.pth
12+
QUIETLY$(MX_VERBOSE) = @
13+
OPT_QUIET$(MX_VERBOSE) = --quiet
14+
OPT_VERBOSE =
1015

11-
${SITE_PATH}:
12-
mkdir -p ${SITE_PATH}
16+
ifeq ($(MX_VERBOSE),y)
17+
OPT_VERBOSE = -v
18+
endif
19+
20+
21+
default: install
1322

14-
${SITE_PATH}/setuptools.pth:
15-
PYTHONPATH=${SITE_PATH} python3 -m easy_install --always-copy --exclude-scripts --always-unzip --install-dir ${SITE_PATH} setuptools==${SETUPTOOLS_VERSION}
16-
find ${SITE_PATH} -name "*.pyc" -exec rm "{}" ";"
17-
rm -rf ${SITE_PATH}/__pycache__
23+
install:
24+
$(QUIETLY) mx $(OPT_VERBOSE) python3 -m zipfile -e ${SETUPTOOLS_ZIP} .
25+
$(QUIETLY) ${IN_SETUPTOOLS_DIR} mx $(OPT_VERBOSE) python3 bootstrap.py
26+
$(QUIETLY) ${IN_SETUPTOOLS_DIR} mx $(OPT_VERBOSE) python3 setup.py $(OPT_QUIET) install
1827

1928
clean:
20-
rm -rf ${SITE_PATH}
29+
$(QUIETLY) rm -rf ${SETUPTOOLS_DIR}
30+
$(QUIETLY) rm -rf ${SITE_PATH}/*

0 commit comments

Comments
 (0)