Skip to content

Constrain numpy version to be less than 2.x #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mhucka
Copy link
Member

@mhucka mhucka commented Apr 14, 2025

Although the latest release of Cirq is compatible with NumPy 2, other
dependencies for TFQ are not, and this leads to failures at run-time.
For now, tell pip not to install NumPy 2.

Although the latest release of Cirq is compatible with NumPy 2, other
dependencies for TFQ are not, and this leads to failures at run-time.
For now, tell `pip` not to install NumPy 2.
@mhucka mhucka marked this pull request as ready for review April 14, 2025 03:14
@mhucka mhucka requested a review from MichaelBroughton April 14, 2025 03:14
@mhucka mhucka enabled auto-merge (squash) April 18, 2025 21:18
@mhucka mhucka disabled auto-merge April 18, 2025 21:18
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause a breakage in the pip package too ? If so we might want to put this constraint there as well ?

@mhucka
Copy link
Member Author

mhucka commented Apr 22, 2025

Does this cause a breakage in the pip package too ? If so we might want to put this constraint there as well ?

You would think that would make sense, but unfortunately, it doesn't end up working. The reason is the sequence of commands. First,

pip install -r requirements.txt

then followed separately by

pip install -U cirq --pre

and while we could constrain the version of NumPy in the requirements file to be < 2.0, the second command (installing Cirq) will cause NumPy 2 to be brought in. Pip doesn't remember the constraints between invocations.

I think what needs to happen is to make TFQ work with Cirq 1.5, at which point, the version of Cirq defined in requirements.txt can be set to 1.5 (instead of 1.3 as it is now), and then the version of NumPy in requirements.txt can be limited to < 2.0. Having the requirements and packages be installed in one go will make pip satisfy the simultaneous constraints.

For now, changing the compatibility workflow to use the pip constraints feature will let the CI checks pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants