From 41093bdd1de1f386557c7ef3178650dc430412cc Mon Sep 17 00:00:00 2001 From: mhucka Date: Mon, 15 Dec 2025 03:34:30 +0000 Subject: [PATCH 1/7] Add additional version constraints to requirements file This adds additional version constraints on dependencies that are necessary to generate a requirements.txt file that works with TensorFlow 2.16.2 and tf-keras. --- requirements.in | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/requirements.in b/requirements.in index 92c987272..c168b8827 100644 --- a/requirements.in +++ b/requirements.in @@ -18,14 +18,18 @@ # scripts/generate_requirements.sh. cirq-core~=1.3.0 cirq-google~=1.3.0 +numpy<2.0 tensorflow>=2.16,<2.17 tf-keras~=2.16.0 +scipy<=1.12.0 +sympy==1.14 -# TODO: the next ones are not truly core requirements. A better place should be -# found for them (long with others needed by scripts/*). They're here as a -# stop-gap measure until then. -yapf==0.43.0 -pylint==3.3.3 -nbformat==5.1.3 -nbclient==0.6.5 -tensorflow-docs +# This needs to match what TensorFlow uses to avoid problems with distutils. +setuptools==68.2.2 + +# The rest are transitive dependencies that need to be constrained either +# because pip may try to install incompatible versions, or the higher versions +# require Python 3.11+ and we want to maintain Python 3.10 compatibility. +jax<=0.5 +contourpy<=1.3.2; python_version < "3.11" +networkx<=3.4; python_version < "3.11" From b967ebac26397cf7647dfc016104fe21ff6fd08e Mon Sep 17 00:00:00 2001 From: mhucka Date: Mon, 15 Dec 2025 03:48:37 +0000 Subject: [PATCH 2/7] Remove python_version constraints The python_version actually means the constraint only applies to that Python version. We need the packages installed no matter the Python version; we just need the constraint on Python < 3.11. It's simpler and still works to not add the python_version, so let's just remove them. --- requirements.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.in b/requirements.in index c168b8827..18e52d8f7 100644 --- a/requirements.in +++ b/requirements.in @@ -31,5 +31,5 @@ setuptools==68.2.2 # because pip may try to install incompatible versions, or the higher versions # require Python 3.11+ and we want to maintain Python 3.10 compatibility. jax<=0.5 -contourpy<=1.3.2; python_version < "3.11" -networkx<=3.4; python_version < "3.11" +contourpy<=1.3.2 +networkx<=3.4 From 911dd9df969871373f65e48f1652c47297b99355 Mon Sep 17 00:00:00 2001 From: mhucka Date: Mon, 15 Dec 2025 03:35:05 +0000 Subject: [PATCH 3/7] Update requirements.txt based on requiremets.in This is the output of running pip-compile on requirements.in. --- requirements.txt | 141 +++++++++++++++-------------------------------- 1 file changed, 44 insertions(+), 97 deletions(-) diff --git a/requirements.txt b/requirements.txt index ac86eb121..c427bfcab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,27 +1,17 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --allow-unsafe --no-strip-extras +# ./scripts/generate_requirements.sh # - -absl-py==2.1.0 +absl-py==2.3.1 # via # keras # tensorboard # tensorflow - # tensorflow-docs -astor==0.8.1 - # via tensorflow-docs -astroid==3.3.11 - # via pylint astunparse==1.6.3 # via tensorflow -attrs==25.4.0 - # via - # jsonschema - # referencing -cachetools==6.2.2 +cachetools==6.2.3 # via google-auth certifi==2025.11.12 # via requests @@ -34,18 +24,18 @@ cirq-core==1.3.0 cirq-google==1.3.0 # via -r requirements.in contourpy==1.3.2 - # via matplotlib + # via + # -r requirements.in + # matplotlib cycler==0.12.1 # via matplotlib -dill==0.4.0 - # via pylint duet==0.2.9 # via cirq-core flatbuffers==25.9.23 # via tensorflow -fonttools==4.60.1 +fonttools==4.61.1 # via matplotlib -gast==0.6.0 +gast==0.7.0 # via tensorflow google-api-core[grpc]==2.28.1 # via cirq-google @@ -57,13 +47,13 @@ googleapis-common-protos==1.72.0 # via # google-api-core # grpcio-status -grpcio==1.60.2 +grpcio==1.76.0 # via # google-api-core # grpcio-status # tensorboard # tensorflow -grpcio-status==1.60.2 +grpcio-status==1.62.3 # via google-api-core h5py==3.15.1 # via @@ -71,22 +61,10 @@ h5py==3.15.1 # tensorflow idna==3.11 # via requests -ipython-genutils==0.2.0 - # via nbformat -isort==5.13.2 - # via pylint -jinja2==3.1.6 - # via tensorflow-docs -jsonschema==4.25.1 - # via nbformat -jsonschema-specifications==2025.9.1 - # via jsonschema -jupyter-client==8.6.3 - # via nbclient -jupyter-core==5.9.1 - # via - # jupyter-client - # nbformat +jax==0.4.34 + # via -r requirements.in +jaxlib==0.4.34 + # via jax keras==3.12.0 # via tensorflow kiwisolver==1.4.9 @@ -98,39 +76,33 @@ markdown==3.10 markdown-it-py==4.0.0 # via rich markupsafe==3.0.3 - # via - # jinja2 - # werkzeug -matplotlib==3.10.7 + # via werkzeug +matplotlib==3.10.8 # via cirq-core -mccabe==0.7.0 - # via pylint mdurl==0.1.2 # via markdown-it-py ml-dtypes==0.3.2 # via + # jax + # jaxlib # keras # tensorflow mpmath==1.3.0 # via sympy namex==0.1.0 # via keras -nbclient==0.6.5 - # via -r requirements.in -nbformat==5.1.3 +networkx==3.4 # via # -r requirements.in - # nbclient - # tensorflow-docs -nest-asyncio==1.6.0 - # via nbclient -networkx==3.4.2 - # via cirq-core + # cirq-core numpy==1.26.4 # via + # -r requirements.in # cirq-core # contourpy # h5py + # jax + # jaxlib # keras # matplotlib # ml-dtypes @@ -139,7 +111,9 @@ numpy==1.26.4 # tensorboard # tensorflow opt-einsum==3.4.0 - # via tensorflow + # via + # jax + # tensorflow optree==0.18.0 # via keras packaging==25.0 @@ -147,15 +121,11 @@ packaging==25.0 # keras # matplotlib # tensorflow + # wheel pandas==2.3.3 # via cirq-core pillow==12.0.0 # via matplotlib -platformdirs==4.5.0 - # via - # jupyter-core - # pylint - # yapf proto-plus==1.26.1 # via # cirq-google @@ -169,7 +139,6 @@ protobuf==4.25.8 # proto-plus # tensorboard # tensorflow - # tensorflow-docs pyasn1==0.6.1 # via # pyasn1-modules @@ -178,39 +147,28 @@ pyasn1-modules==0.4.2 # via google-auth pygments==2.19.2 # via rich -pylint==3.3.3 - # via -r requirements.in pyparsing==3.2.5 # via matplotlib python-dateutil==2.9.0.post0 # via - # jupyter-client # matplotlib # pandas pytz==2025.2 # via pandas -pyyaml - # via tensorflow-docs -pyzmq==27.1.0 - # via jupyter-client -referencing==0.37.0 - # via - # jsonschema - # jsonschema-specifications requests==2.32.5 # via # google-api-core # tensorflow rich==14.2.0 # via keras -rpds-py==0.29.0 - # via - # jsonschema - # referencing rsa==4.9.1 # via google-auth -scipy==1.15.3 - # via cirq-core +scipy==1.12.0 + # via + # -r requirements.in + # cirq-core + # jax + # jaxlib six==1.17.0 # via # astunparse @@ -221,7 +179,9 @@ six==1.17.0 sortedcontainers==2.4.0 # via cirq-core sympy==1.14.0 - # via cirq-core + # via + # -r requirements.in + # cirq-core tensorboard==2.16.2 # via tensorflow tensorboard-data-server==0.7.2 @@ -230,47 +190,34 @@ tensorflow==2.16.2 # via # -r requirements.in # tf-keras -tensorflow-docs==2025.2.19.33219 - # via -r requirements.in tensorflow-io-gcs-filesystem==0.37.1 # via tensorflow termcolor==3.2.0 # via tensorflow tf-keras==2.16.0 # via -r requirements.in -tomlkit==0.13.3 - # via pylint -tornado==6.5.2 - # via jupyter-client tqdm==4.67.1 # via cirq-core -traitlets==5.14.3 - # via - # jupyter-client - # jupyter-core - # nbclient - # nbformat typing-extensions==4.15.0 # via # cirq-core + # grpcio # optree - # referencing # tensorflow -tzdata==2025.2 +tzdata==2025.3 # via pandas -urllib3==2.5.0 +urllib3==2.6.2 # via requests -werkzeug==3.1.3 +werkzeug==3.1.4 # via tensorboard -wheel==0.45.1 +wheel==0.46.1 # via astunparse -wrapt==1.17.3 +wrapt==2.0.1 # via tensorflow -yapf==0.43.0 - # via -r requirements.in # The following packages are considered to be unsafe in a requirements file: setuptools==68.2.2 # via + # -r requirements.in # tensorboard # tensorflow From ca41ab5ff175b96a35d0e419aaf9cd7942d2436b Mon Sep 17 00:00:00 2001 From: mhucka Date: Tue, 23 Dec 2025 23:45:18 +0000 Subject: [PATCH 4/7] Update requirements.in to work for Python 3.9 This adds more constraints so that the result works on Python 3.9. --- requirements.in | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/requirements.in b/requirements.in index 18e52d8f7..10774615a 100644 --- a/requirements.in +++ b/requirements.in @@ -24,12 +24,19 @@ tf-keras~=2.16.0 scipy<=1.12.0 sympy==1.14 -# This needs to match what TensorFlow uses to avoid problems with distutils. -setuptools==68.2.2 +# This version is needed to build & work with Python 3.9. +setuptools==58.1.0 # The rest are transitive dependencies that need to be constrained either # because pip may try to install incompatible versions, or the higher versions -# require Python 3.11+ and we want to maintain Python 3.10 compatibility. -jax<=0.5 -contourpy<=1.3.2 -networkx<=3.4 +# require Python 3.10+ and we want to maintain Python 3.9 compatibility. +contourpy<=1.3.0 +h5py==3.10.0 +importlib_metadata<5 +jax<0.4.24 +jaxlib<0.4.24 +matplotlib<3.10 +networkx<3.3 +pillow<=11.0 +protobuf==4.25.8 +wrapt<2 From 90a13c14d61a2d25bf6c9feaffa77de9130e72e5 Mon Sep 17 00:00:00 2001 From: mhucka Date: Tue, 23 Dec 2025 23:46:13 +0000 Subject: [PATCH 5/7] Improve scripts/generate_requirements.txt --- scripts/generate_requirements.sh | 43 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/scripts/generate_requirements.sh b/scripts/generate_requirements.sh index 8868273e7..fc73dd357 100755 --- a/scripts/generate_requirements.sh +++ b/scripts/generate_requirements.sh @@ -15,29 +15,36 @@ # ============================================================================== # Summary: produce requirements.txt using pip-compile & munging the result. -# Usage: ./generate_requirements.sh +# Usage: ./scripts/generate_requirements.sh -set -eu +set -eo pipefail -# Find the top of the local TFQ git tree. Do it early in case this fails. -thisdir=$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd -P) -repo_dir=$(git -C "${thisdir}" rev-parse --show-toplevel 2>/dev/null || \ - echo "${thisdir}/..") +# Go to the top of the local TFQ git tree. Do it early in case this fails. +thisdir=$(CDPATH="" cd -- "$(dirname -- "${0}")" && pwd -P) +repo_dir=$(git -C "${thisdir}" rev-parse --show-toplevel 2>/dev/null) +cd "${repo_dir}" -echo "Running pip-compile in ${repo_dir} …" -pip-compile -q --no-strip-extras --allow-unsafe +if ! pip show -qq pip-tools; then + echo "Error: 'pip-compile' not found. Please install 'pip-tools'." >&2 + exit 1 +fi -declare -a inplace_edit=(-i) -if [[ "$(uname -s)" == "Darwin" ]]; then - # macOS uses BSD sed, which requires a suffix for -i. - inplace_edit+=('') +# Don't force the use of a constraint file, but use it if exists. +declare -a constraint=() +pins_file="$(realpath --relative-to=. "${repo_dir}/requirements-pins.txt")" +if [[ -e "${pins_file}" ]]; then + constraint+=(--constraint "${pins_file}") fi -echo "Adjusting output of pip-compile …" -sed "${inplace_edit[@]}" \ - -e '/^--index-url/d' \ - -e '/^--extra-index-url/d' \ - -e 's/^pyyaml==.*/pyyaml/' \ - requirements.txt +# Tell pip-compile to reference this script in the requirements.txt header. +export CUSTOM_COMPILE_COMMAND="${0}" + +echo "Running pip-compile in ${repo_dir} …" +pip-compile -q \ + --rebuild \ + --allow-unsafe \ + --no-strip-extras \ + --no-emit-index-url \ + "${constraint[@]}" echo "Done." From 605b5e55921479034d7393e5b066e070f621d011 Mon Sep 17 00:00:00 2001 From: mhucka Date: Tue, 23 Dec 2025 23:46:35 +0000 Subject: [PATCH 6/7] Update requirements.txt based on latest requirements.in This version works with Python 3.9. --- requirements.txt | 82 +++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/requirements.txt b/requirements.txt index c427bfcab..975fedf43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.9 # by the following command: # # ./scripts/generate_requirements.sh @@ -11,7 +11,7 @@ absl-py==2.3.1 # tensorflow astunparse==1.6.3 # via tensorflow -cachetools==6.2.3 +cachetools==6.2.4 # via google-auth certifi==2025.11.12 # via requests @@ -23,7 +23,7 @@ cirq-core==1.3.0 # cirq-google cirq-google==1.3.0 # via -r requirements.in -contourpy==1.3.2 +contourpy==1.3.0 # via # -r requirements.in # matplotlib @@ -31,15 +31,17 @@ cycler==0.12.1 # via matplotlib duet==0.2.9 # via cirq-core -flatbuffers==25.9.23 +flatbuffers==25.12.19 # via tensorflow -fonttools==4.61.1 - # via matplotlib +fonttools==4.60.2 + # via + # -c requirements-pins.txt + # matplotlib gast==0.7.0 # via tensorflow google-api-core[grpc]==2.28.1 # via cirq-google -google-auth==2.43.0 +google-auth==2.45.0 # via google-api-core google-pasta==0.2.0 # via tensorflow @@ -55,30 +57,40 @@ grpcio==1.76.0 # tensorflow grpcio-status==1.62.3 # via google-api-core -h5py==3.15.1 +h5py==3.10.0 # via + # -r requirements.in # keras # tensorflow idna==3.11 # via requests -jax==0.4.34 +importlib-metadata==4.13.0 + # via + # -r requirements.in + # jax + # markdown +importlib-resources==6.5.2 + # via matplotlib +jax==0.4.23 + # via -r requirements.in +jaxlib==0.4.23 # via -r requirements.in -jaxlib==0.4.34 - # via jax -keras==3.12.0 +keras==3.10.0 # via tensorflow -kiwisolver==1.4.9 +kiwisolver==1.4.7 # via matplotlib libclang==18.1.1 # via tensorflow -markdown==3.10 +markdown==3.9 # via tensorboard -markdown-it-py==4.0.0 +markdown-it-py==3.0.0 # via rich markupsafe==3.0.3 # via werkzeug -matplotlib==3.10.8 - # via cirq-core +matplotlib==3.9.4 + # via + # -r requirements.in + # cirq-core mdurl==0.1.2 # via markdown-it-py ml-dtypes==0.3.2 @@ -91,7 +103,7 @@ mpmath==1.3.0 # via sympy namex==0.1.0 # via keras -networkx==3.4 +networkx==3.2.1 # via # -r requirements.in # cirq-core @@ -121,17 +133,19 @@ packaging==25.0 # keras # matplotlib # tensorflow - # wheel pandas==2.3.3 # via cirq-core -pillow==12.0.0 - # via matplotlib -proto-plus==1.26.1 +pillow==11.0.0 + # via + # -r requirements.in + # matplotlib +proto-plus==1.27.0 # via # cirq-google # google-api-core protobuf==4.25.8 # via + # -r requirements.in # cirq-google # google-api-core # googleapis-common-protos @@ -192,7 +206,7 @@ tensorflow==2.16.2 # tf-keras tensorflow-io-gcs-filesystem==0.37.1 # via tensorflow -termcolor==3.2.0 +termcolor==3.1.0 # via tensorflow tf-keras==2.16.0 # via -r requirements.in @@ -207,16 +221,26 @@ typing-extensions==4.15.0 tzdata==2025.3 # via pandas urllib3==2.6.2 - # via requests + # via + # -c requirements-pins.txt + # requests werkzeug==3.1.4 - # via tensorboard -wheel==0.46.1 + # via + # -c requirements-pins.txt + # tensorboard +wheel==0.45.1 # via astunparse -wrapt==2.0.1 - # via tensorflow +wrapt==1.17.3 + # via + # -r requirements.in + # tensorflow +zipp==3.23.0 + # via + # importlib-metadata + # importlib-resources # The following packages are considered to be unsafe in a requirements file: -setuptools==68.2.2 +setuptools==58.1.0 # via # -r requirements.in # tensorboard From 2e5188fed91c0303674545607cd1dbf71a9d26dc Mon Sep 17 00:00:00 2001 From: mhucka Date: Thu, 15 Jan 2026 22:06:01 +0000 Subject: [PATCH 7/7] Undo the "set -eu" change because it's not needed After other changes in this script, using `set -eo pipefail` turns out to be unnecessary. Let's go back to what was there before to slightly reduce the noise in the diff. --- scripts/generate_requirements.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_requirements.sh b/scripts/generate_requirements.sh index fc73dd357..6212f1d74 100755 --- a/scripts/generate_requirements.sh +++ b/scripts/generate_requirements.sh @@ -17,7 +17,7 @@ # Summary: produce requirements.txt using pip-compile & munging the result. # Usage: ./scripts/generate_requirements.sh -set -eo pipefail +set -eu # Go to the top of the local TFQ git tree. Do it early in case this fails. thisdir=$(CDPATH="" cd -- "$(dirname -- "${0}")" && pwd -P)