Skip to content

Commit eccb988

Browse files
committed
[GR-73155] Add patch for torch-2.10
PullRequest: graalpython/4253
2 parents 059f0e5 + 84c1ca4 commit eccb988

3 files changed

Lines changed: 1202 additions & 1 deletion

File tree

graalpython/lib-graalpython/patches/metadata.toml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,11 @@ version = '>= 1.2.2'
819819
patch = 'setproctitle-1.2.2.patch'
820820
license = 'BSD-3-Clause'
821821

822+
[[setuptools.rules]]
823+
version = '>= 70.1.0'
824+
patch = 'setuptools.patch'
825+
license = 'MIT'
826+
822827
[[tensorflow.rules]]
823828
version = '== 2.15.0'
824829
patch = 'tensorflow-2.15.0.patch'
@@ -897,6 +902,12 @@ patch = 'torch-2.7.0.patch'
897902
license = 'BSD-3-Clause'
898903
dist-type = 'sdist'
899904

905+
[[torch.rules]]
906+
version = '== 2.10.0'
907+
patch = 'torch-2.10.0.patch'
908+
license = 'BSD-3-Clause'
909+
dist-type = 'sdist'
910+
900911
[[torch.add-sources]]
901912
version = '1.13.1'
902913
url = 'https://github.com/pytorch/pytorch/releases/download/v1.13.1/pytorch-v1.13.1.tar.gz'
@@ -913,8 +924,16 @@ url = 'https://github.com/pytorch/pytorch/releases/download/v2.4.1/pytorch-v2.4.
913924
version = '2.7.0'
914925
url = 'https://github.com/pytorch/pytorch/releases/download/v2.7.0/pytorch-v2.7.0.tar.gz'
915926

927+
[[torch.add-sources]]
928+
version = '2.10.0'
929+
url = 'https://github.com/pytorch/pytorch/releases/download/v2.10.0/pytorch-v2.10.0.tar.gz'
930+
931+
[[torchvision.add-sources]]
932+
version = '0.25.0'
933+
url = 'https://github.com/pytorch/vision/archive/refs/tags/v0.25.0.tar.gz'
934+
916935
[[torchvision.rules]]
917-
version = '== 0.22.0'
936+
version = '>= 0.22.0'
918937
patch = 'torchvision-0.22.0.patch'
919938
license = 'BSD-3-Clause'
920939

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/setuptools/_vendor/wheel/wheelfile.py b/setuptools/_vendor/wheel/wheelfile.py
2+
index 7b6fd71..6b58a2f 100644
3+
--- a/setuptools/_vendor/wheel/wheelfile.py
4+
+++ b/setuptools/_vendor/wheel/wheelfile.py
5+
@@ -184,7 +184,9 @@ class WheelFile(ZipFile):
6+
) -> None:
7+
with open(filename, "rb") as f:
8+
st = os.fstat(f.fileno())
9+
- data = f.read()
10+
+ data = []
11+
+ while chunk := f.read(4194304):
12+
+ data.append(chunk)
13+
14+
zinfo = ZipInfo(
15+
arcname or filename, date_time=get_zipinfo_datetime(st.st_mtime)
16+
@@ -209,7 +211,10 @@ class WheelFile(ZipFile):
17+
if isinstance(data, str):
18+
data = data.encode("utf-8")
19+
20+
- ZipFile.writestr(self, zinfo_or_arcname, data, compress_type)
21+
+ # GraalPy change
22+
+ if not isinstance(data, list):
23+
+ data = [data]
24+
+ self.writestr_list(zinfo_or_arcname, data, compress_type)
25+
fname = (
26+
zinfo_or_arcname.filename
27+
if isinstance(zinfo_or_arcname, ZipInfo)
28+
@@ -217,12 +222,52 @@ class WheelFile(ZipFile):
29+
)
30+
log.info("adding %r", fname)
31+
if fname != self.record_path:
32+
- hash_ = self._default_algorithm(data)
33+
+ hash_ = self._default_algorithm()
34+
+ for chunk in data:
35+
+ hash_.update(chunk)
36+
self._file_hashes[fname] = (
37+
hash_.name,
38+
urlsafe_b64encode(hash_.digest()).decode("ascii"),
39+
)
40+
- self._file_sizes[fname] = len(data)
41+
+ self._file_sizes[fname] = sum(map(len, data))
42+
+
43+
+ # GraalPy change: version that accepts data as a list of bytes chunks, to
44+
+ # avoid running into the 2GB limit for bytes object size
45+
+ def writestr_list(self, zinfo_or_arcname, data,
46+
+ compress_type=None, compresslevel=None):
47+
+ if not isinstance(zinfo_or_arcname, ZipInfo):
48+
+ zinfo = ZipInfo(filename=zinfo_or_arcname,
49+
+ date_time=time.localtime(time.time())[:6])
50+
+ zinfo.compress_type = self.compression
51+
+ zinfo._compresslevel = self.compresslevel
52+
+ if zinfo.filename[-1] == '/':
53+
+ zinfo.external_attr = 0o40775 << 16 # drwxrwxr-x
54+
+ zinfo.external_attr |= 0x10 # MS-DOS directory flag
55+
+ else:
56+
+ zinfo.external_attr = 0o600 << 16 # ?rw-------
57+
+ else:
58+
+ zinfo = zinfo_or_arcname
59+
+
60+
+ if not self.fp:
61+
+ raise ValueError(
62+
+ "Attempt to write to ZIP archive that was already closed")
63+
+ if self._writing:
64+
+ raise ValueError(
65+
+ "Can't write to ZIP archive while an open writing handle exists."
66+
+ )
67+
+
68+
+ if compress_type is not None:
69+
+ zinfo.compress_type = compress_type
70+
+
71+
+ if compresslevel is not None:
72+
+ zinfo._compresslevel = compresslevel
73+
+
74+
+ zinfo.file_size = sum(map(len, data)) # Uncompressed size
75+
+ with self._lock:
76+
+ with self.open(zinfo, mode='w') as dest:
77+
+ for chunk in data:
78+
+ dest.write(chunk)
79+
+
80+
81+
def close(self) -> None:
82+
# Write RECORD

0 commit comments

Comments
 (0)