Skip to content

Commit 66e4479

Browse files
authored
Update requirements and scripts/generate_requirements.sh (#945)
This PR updates the dependencies in `requirements.in` and `setup.py` as follows: * Drop support for Python 3.9 (which was end-of-lifed last year) * Update the requirements to try to reduce them to the minimum This PR also updates `scripts/generate_requirements.sh` to remove some no-longer-needed post-processing of the `requirements.txt` file. The modified script still needs to have one special case, to avoid pinning the version of PyYAML. PyYAML is a transitive dependency that, in older Pythons, was installed via distutils and not pip. Pinning the version (as pip-compile would normally do) causes pip to try to uninstall any existing versions of pyyaml in the environment, and fail, because pip didn't install it in the first place. The most robust solution I've found is to avoid pinning the version. Previously this was accomplished in `scripts/generate_requirements.sh` by editing the output using `sed` (ugh – my bad). This update uses pip-compile's feature for "unsafe" packages to simply leave pyyaml out of `requirements.txt`.
1 parent 6867ca0 commit 66e4479

File tree

4 files changed

+161
-1698
lines changed

4 files changed

+161
-1698
lines changed

release/setup.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,17 @@ def finalize_options(self):
4848
REQUIRED_PACKAGES = [
4949
"cirq-core==1.3.0",
5050
"cirq-google==1.3.0",
51+
"numpy<2.0",
52+
"scipy~=1.15.3",
5153
"sympy==1.14",
5254
"tf-keras~=2.17.0",
53-
# The following are transitive dependencies that need to be constrained to
54-
# avoid incompatible versions or because some (e.g., contourpy 1.3.3)
55-
# require Python 3.11+ and we want to maintain Python 3.9 compatibility.
56-
# TODO: revisit after we reach compatibility with TensorFlow 2.19+.
57-
"contourpy<=1.3.2",
58-
"h5py==3.10.0",
59-
"importlib_metadata<5",
60-
"jax<=0.5",
61-
"matplotlib<3.10",
62-
"numpy<2.0",
63-
"scipy<=1.12.0",
64-
# The following makes it easier to get the right version on Colab. Once
65-
# TFQ works with the latest version of TF, this may become unnecessary.
66-
"protobuf==4.25.8",
55+
56+
# The reset of these constraints are on transitive dependencies to avoid
57+
# installation conflicts, which can happen if pip finds a newer version of a
58+
# package & that newer version requires, e.g., NumPy 2.x or Python 3.11+.
59+
# Ideally these can be removed once TFQ is compatible with recent TFs.
60+
"jax<0.5",
61+
"contourpy<1.3.3",
6762
]
6863

6964
# TF requirement is placed as an extras to avoid overwriting existing nightly TF
@@ -73,8 +68,6 @@ def finalize_options(self):
7368
EXTRA_PACKAGES["and-tensorflow"] = ["tensorflow>=2.17,<2.18"]
7469
# "extras" was used before 0.7.4. Prefer "and-tensorflow" in 0.7.4+.
7570
EXTRA_PACKAGES["extras"] = EXTRA_PACKAGES["and-tensorflow"]
76-
# Add an alias in case people type an underscore instead of a dash.
77-
EXTRA_PACKAGES["and_tensorflow"] = EXTRA_PACKAGES["and-tensorflow"]
7871

7972

8073
class BinaryDistribution(Distribution):
@@ -106,7 +99,7 @@ def has_ext_modules(self):
10699
author_email="tensorflow-quantum-team@google.com",
107100
url="https://github.com/tensorflow/quantum/",
108101
packages=find_packages(),
109-
python_requires='>=3.9',
102+
python_requires='>=3.10',
110103
install_requires=REQUIRED_PACKAGES,
111104
extras_require=EXTRA_PACKAGES,
112105
include_package_data=True,

requirements.in

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
# Core development requirements for TensorFlow Quantum. This file is processed
1717
# by pip-compile (from pip-tools) to produce requirements.txt using the script
1818
# scripts/generate_requirements.sh.
19+
1920
cirq-core~=1.3.0
2021
cirq-google~=1.3.0
22+
jax<0.5
23+
numpy<2.0
24+
scipy~=1.15.3
25+
sympy==1.14
2126
tensorflow>=2.17,<2.18
22-
keras==3.12.0
2327
tf-keras~=2.17.0
24-
setuptools==75.0.0
25-
wheel==0.46.2
26-
contourpy<=1.3.2
27-
networkx<=3.4.2
28-
scipy==1.15.3
2928

3029
# TODO: the next ones are not truly core requirements. A better place should be
3130
# found for them (long with others needed by scripts/*). They're here as a

0 commit comments

Comments
 (0)