Skip to content

Commit 42262a8

Browse files
committed
Clean up patch
1 parent fa896d7 commit 42262a8

File tree

1 file changed

+39
-106
lines changed

1 file changed

+39
-106
lines changed

graalpython/lib-graalpython/patches/tensorflow/tensorflow-2.14.0.patch

Lines changed: 39 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,38 @@
1-
From 1abbffd2c9892a1f9d0b12b48345a3bf256fdbe8 Mon Sep 17 00:00:00 2001
1+
From 3e40415231d65c1dc8017f99790898523b659501 Mon Sep 17 00:00:00 2001
22
From: Mohaned Qunaibit <[email protected]>
3-
Date: Mon, 2 Oct 2023 01:09:28 +0300
3+
Date: Sun, 8 Oct 2023 15:53:04 +0300
44
Subject: [PATCH] patch tensorflow 2.14.0
55

66
---
7-
.tf_configure.bazelrc | 8 +
87
WORKSPACE | 7 +-
9-
graalpy_build.py | 252 ++++++++++++++++++
10-
graalpy_patch.py | 120 +++++++++
11-
pyproject.toml | 49 ++++
12-
requirements_lock_3_10.txt | 6 +-
8+
graalpy_build.py | 253 ++++++++++++++++++
9+
graalpy_patch.py | 105 ++++++++
10+
pyproject.toml | 50 ++++
1311
rules_python-0.23.1.patch | 182 +++++++++++++
1412
.../python/client/tf_session_wrapper.cc | 4 +-
1513
tensorflow/python/eager/pywrap_tfe_src.cc | 11 +-
1614
tensorflow/python/framework/dtypes.py | 2 +-
1715
.../python_api_dispatcher_wrapper.cc | 2 +-
18-
tensorflow/python/keras/engine/training.py | 1 +
19-
tensorflow/python/keras/saving/hdf5_format.py | 1 +
20-
tensorflow/python/keras/saving/save.py | 1 +
16+
tensorflow/python/keras/engine/training.py | 2 +-
17+
tensorflow/python/keras/saving/hdf5_format.py | 2 +-
18+
tensorflow/python/keras/saving/save.py | 2 +-
2119
.../tools/api/generator/create_python_api.py | 2 +-
2220
tensorflow/python/util/module_wrapper.py | 55 +++-
2321
tensorflow/tools/git/gen_git_source.py | 3 +-
2422
tensorflow/tools/pip_package/setup.py | 2 +-
2523
.../devel.usertools/squash_testlogs.py | 13 +-
2624
.../tools/toolchains/python/python_repo.bzl | 7 +-
2725
tensorflow/workspace2.bzl | 6 +-
28-
tf_build_backend.py | 55 ++++
26+
tf_build_backend.py | 57 ++++
2927
third_party/protobuf/protobuf.patch | 2 +-
3028
third_party/repo.bzl | 8 +-
31-
tox.ini | 10 +
32-
25 files changed, 782 insertions(+), 27 deletions(-)
33-
create mode 100644 .tf_configure.bazelrc
29+
22 files changed, 749 insertions(+), 28 deletions(-)
3430
create mode 100644 graalpy_build.py
3531
create mode 100644 graalpy_patch.py
3632
create mode 100644 pyproject.toml
3733
create mode 100644 rules_python-0.23.1.patch
3834
create mode 100644 tf_build_backend.py
39-
create mode 100644 tox.ini
4035

41-
diff --git a/.tf_configure.bazelrc b/.tf_configure.bazelrc
42-
new file mode 100644
43-
index 00000000000..b2add9620ca
44-
--- /dev/null
45-
+++ b/.tf_configure.bazelrc
46-
@@ -0,0 +1,8 @@
47-
+build:opt --copt=-Wno-sign-compare
48-
+build:opt --host_copt=-Wno-sign-compare
49-
+test --flaky_test_attempts=3
50-
+test --test_size_filters=small,medium
51-
+test:v1 --test_tag_filters=-benchmark-test,-no_oss,-gpu,-oss_serial
52-
+test:v1 --build_tag_filters=-benchmark-test,-no_oss,-gpu
53-
+test:v2 --test_tag_filters=-benchmark-test,-no_oss,-gpu,-oss_serial,-v1only
54-
+test:v2 --build_tag_filters=-benchmark-test,-no_oss,-gpu,-v1only
5536
diff --git a/WORKSPACE b/WORKSPACE
5637
index fb3af8a2bea..44ddffba73c 100644
5738
--- a/WORKSPACE
@@ -86,10 +67,10 @@ index fb3af8a2bea..44ddffba73c 100644
8667
load("@pypi//:requirements.bzl", "install_deps")
8768
diff --git a/graalpy_build.py b/graalpy_build.py
8869
new file mode 100644
89-
index 00000000000..b98870582c4
70+
index 00000000000..3da98203ff8
9071
--- /dev/null
9172
+++ b/graalpy_build.py
92-
@@ -0,0 +1,252 @@
73+
@@ -0,0 +1,253 @@
9374
+
9475
+import subprocess
9576
+import os
@@ -281,6 +262,7 @@ index 00000000000..b98870582c4
281262
+ if os.environ.get('PYTHONNOUSERSITE', '0') == '1':
282263
+ add_isolated_sites(os.environ, lib_dirs)
283264
+
265+
+ # Site-packages are mostly needed for `rules_python`'s builtin packages
284266
+ VENV_SITE_PACKAGES = os.pathsep.join(lib_dirs)
285267
+
286268
+ if not args.no_all:
@@ -345,10 +327,10 @@ index 00000000000..b98870582c4
345327
\ No newline at end of file
346328
diff --git a/graalpy_patch.py b/graalpy_patch.py
347329
new file mode 100644
348-
index 00000000000..a4330468cc8
330+
index 00000000000..728d8a8863a
349331
--- /dev/null
350332
+++ b/graalpy_patch.py
351-
@@ -0,0 +1,120 @@
333+
@@ -0,0 +1,105 @@
352334
+try:
353335
+ import __graalpython__
354336
+except:
@@ -357,22 +339,11 @@ index 00000000000..a4330468cc8
357339
+
358340
+
359341
+import sys
342+
+import os
360343
+
361344
+if sys.prefix == sys.base_prefix:
362345
+ raise SystemError('Running in virtualenv is required!')
363346
+
364-
+
365-
+# ATTENTION: GraalPy uses existence of this module to verify that it is
366-
+# running a patched pip in pip_hook.py
367-
+import os
368-
+import re
369-
+from pathlib import Path
370-
+from urllib.parse import urlparse
371-
+
372-
+from pip._vendor import tomli
373-
+from pip._vendor.packaging.specifiers import SpecifierSet
374-
+from pip._vendor.packaging.version import VERSION_PATTERN
375-
+
376347
+PATCHES_BASE_DIR = os.path.join(__graalpython__.core_home, "patches")
377348
+
378349
+patch_dict = {
@@ -456,26 +427,23 @@ index 00000000000..a4330468cc8
456427
+ import autopatch_capi
457428
+ autopatch_capi.auto_patch_tree(location)
458429
+
459-
+def print_entry(strip_prefix):
460-
+ print('"%s": ""' % strip_prefix)
461-
+
462-
+
430+
+# There are couple of parts that have been taken from the pip installer patch
463431
+def main():
464432
+ target_dir = sys.argv[1]
465433
+ target_strip_prefix = sys.argv[2]
466434
+ find_patch(target_dir, target_strip_prefix)
467435
+ autopatch(target_dir)
468-
+ # print_entry(target_strip_prefix)
469436
+
470437
+if __name__ == '__main__':
471438
+ main()
472439
diff --git a/pyproject.toml b/pyproject.toml
473440
new file mode 100644
474-
index 00000000000..0a08c9d062a
441+
index 00000000000..841b726f3fe
475442
--- /dev/null
476443
+++ b/pyproject.toml
477-
@@ -0,0 +1,49 @@
444+
@@ -0,0 +1,50 @@
478445
+[build-system]
446+
+# These requirements are needed to cached wheels during bazel build.
479447
+requires = [
480448
+ "setuptools",
481449
+ "packaging",
@@ -524,30 +492,6 @@ index 00000000000..0a08c9d062a
524492
+]
525493
+build-backend = "tf_build_backend"
526494
+backend-path = ["."]
527-
diff --git a/requirements_lock_3_10.txt b/requirements_lock_3_10.txt
528-
index 55b56f40b32..d2d3303a33d 100644
529-
--- a/requirements_lock_3_10.txt
530-
+++ b/requirements_lock_3_10.txt
531-
@@ -97,7 +97,8 @@ google-auth-oauthlib==1.0.0 \
532-
--hash=sha256:95880ca704928c300f48194d1770cf5b1462835b6e49db61445a520f793fd5fb \
533-
--hash=sha256:e375064964820b47221a7e1b7ee1fd77051b6323c3f9e3e19785f78ab67ecfc5
534-
# via tensorboard
535-
-grpcio==1.57.0 \
536-
+grpcio==1.56.2 \
537-
+ --hash=sha256:0ff789ae7d8ddd76d2ac02e7d13bfef6fc4928ac01e1dcaa182be51b6bcc0aaa \
538-
--hash=sha256:00258cbe3f5188629828363ae8ff78477ce976a6f63fb2bb5e90088396faa82e \
539-
--hash=sha256:092fa155b945015754bdf988be47793c377b52b88d546e45c6a9f9579ac7f7b6 \
540-
--hash=sha256:0f80bf37f09e1caba6a8063e56e2b87fa335add314cf2b78ebf7cb45aa7e3d06 \
541-
@@ -146,7 +147,8 @@ grpcio==1.57.0 \
542-
# via
543-
# -r ./requirements.in
544-
# tensorboard
545-
-h5py==3.9.0 \
546-
+h5py==2.10.0 \
547-
+ --hash=sha256:84412798925dc870ffd7107f045d7659e60f5d46d1c70c700375248bf6bf512d \
548-
--hash=sha256:12aa556d540f11a2cae53ea7cfb94017353bd271fb3962e1296b342f6550d1b8 \
549-
--hash=sha256:23e74b878bbe1653ab34ca49b83cac85529cd0b36b9d625516c5830cc5ca2eac \
550-
--hash=sha256:36408f8c62f50007d14e000f9f3acf77e103b9e932c114cbe52a3089e50ebf94 \
551495
diff --git a/rules_python-0.23.1.patch b/rules_python-0.23.1.patch
552496
new file mode 100644
553497
index 00000000000..cb8c98b661b
@@ -821,41 +765,44 @@ index d3f688578a7..071fadb1e45 100644
821765
throw py::type_error("`*py_classes` must be a tuple of types.");
822766
}
823767
diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py
824-
index 1e94ca45aef..004c9ad5b49 100644
768+
index 1e94ca45aef..8adcb4f99c0 100644
825769
--- a/tensorflow/python/keras/engine/training.py
826770
+++ b/tensorflow/python/keras/engine/training.py
827-
@@ -83,6 +83,7 @@ from tensorflow.tools.docs import doc_controls
771+
@@ -83,7 +83,7 @@ from tensorflow.tools.docs import doc_controls
828772

829773
# pylint: disable=g-import-not-at-top
830774
try:
831-
+ raise ImportError
832-
import h5py
775+
- import h5py
776+
+ raise ImportError; import h5py
833777
except ImportError:
834778
h5py = None
779+
# pylint: enable=g-import-not-at-top
835780
diff --git a/tensorflow/python/keras/saving/hdf5_format.py b/tensorflow/python/keras/saving/hdf5_format.py
836-
index 1f6bbc43320..a0085d001cc 100644
781+
index 1f6bbc43320..61edd5143b9 100644
837782
--- a/tensorflow/python/keras/saving/hdf5_format.py
838783
+++ b/tensorflow/python/keras/saving/hdf5_format.py
839-
@@ -34,6 +34,7 @@ from tensorflow.python.platform import tf_logging as logging
784+
@@ -34,7 +34,7 @@ from tensorflow.python.platform import tf_logging as logging
840785

841786
# pylint: disable=g-import-not-at-top
842787
try:
843-
+ raise ImportError
844-
import h5py
788+
- import h5py
789+
+ raise ImportError; import h5py
845790
HDF5_OBJECT_HEADER_LIMIT = 64512
846791
except ImportError:
792+
h5py = None
847793
diff --git a/tensorflow/python/keras/saving/save.py b/tensorflow/python/keras/saving/save.py
848-
index eee859233e5..4bdddc307a5 100644
794+
index eee859233e5..eee6eb3093c 100644
849795
--- a/tensorflow/python/keras/saving/save.py
850796
+++ b/tensorflow/python/keras/saving/save.py
851-
@@ -25,6 +25,7 @@ from tensorflow.python.keras.utils.io_utils import path_to_string
797+
@@ -25,7 +25,7 @@ from tensorflow.python.keras.utils.io_utils import path_to_string
852798

853799
# pylint: disable=g-import-not-at-top
854800
try:
855-
+ raise ImportError
856-
import h5py
801+
- import h5py
802+
+ raise ImportError; import h5py
857803
except ImportError:
858804
h5py = None
805+
# pylint: enable=g-import-not-at-top
859806
diff --git a/tensorflow/python/tools/api/generator/create_python_api.py b/tensorflow/python/tools/api/generator/create_python_api.py
860807
index 742cc879d0e..cdc65b36473 100644
861808
--- a/tensorflow/python/tools/api/generator/create_python_api.py
@@ -1049,10 +996,10 @@ index 7e9faa558a4..d4ace12a6a6 100644
1049996
# LINT.IfChange
1050997
diff --git a/tf_build_backend.py b/tf_build_backend.py
1051998
new file mode 100644
1052-
index 00000000000..57118801ae9
999+
index 00000000000..7da2ad7c9ee
10531000
--- /dev/null
10541001
+++ b/tf_build_backend.py
1055-
@@ -0,0 +1,55 @@
1002+
@@ -0,0 +1,57 @@
10561003
+import os
10571004
+import re
10581005
+import sys
@@ -1069,6 +1016,8 @@ index 00000000000..57118801ae9
10691016
+SUB_VENV_PYTHON = SUB_VENV_BIN / 'python3'
10701017
+
10711018
+def setup_venv():
1019+
+ # During the installation process `pip` isn't available to use,
1020+
+ # So, we create a new environment to have access for fresh `pip` during bazel build.
10721021
+ if not os.path.isdir(SUB_VENV_PATH):
10731022
+ venv.create(SUB_VENV_PATH, with_pip=True)
10741023
+ print('Using virtual env in:\n\t' + str(SUB_VENV_PATH))
@@ -1155,22 +1104,6 @@ index 226f8799392..6d7b830eb2b 100644
11551104
"mirror.tensorflow.org",
11561105
"mirror.bazel.build",
11571106
"storage.googleapis.com",
1158-
diff --git a/tox.ini b/tox.ini
1159-
new file mode 100644
1160-
index 00000000000..cb73413d28d
1161-
--- /dev/null
1162-
+++ b/tox.ini
1163-
@@ -0,0 +1,10 @@
1164-
+[tox]
1165-
+isolated_build = true
1166-
+[testenv]
1167-
+commands =
1168-
+ graalpylibtest: python3 graalpy_build.py --j 16 --max-memory 32 --test
1169-
+ !graalpylibtest: bazel test -j 16 --config=opt -k //tensorflow/python/...
1170-
+deps = pytest
1171-
+ mock
1172-
+ !graalpylibtest: -rtensorflow/tools/ci_build/release/requirements_ubuntu.txt
1173-
+ !graalpylibtest: -rtensorflow/tools/ci_build/release/requirements_common.txt
11741107
--
11751108
2.25.1
11761109

0 commit comments

Comments
 (0)