Skip to content
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

Support Python 3.12 #6516

Merged
merged 10 commits into from May 9, 2024
Merged

Conversation

pavoljuhas
Copy link
Collaborator

@pavoljuhas pavoljuhas commented Mar 21, 2024

  • Fix attribute error in engine_test.py::test_create_context
  • Adjust package presence assertion in test_isolated_env_cloning
  • Bump up to virtualenv>=20.23, filelock~=3.1, pylatex~=1.4
  • Bump up to grpcio-tools~=1.59.0 and recompile protos
  • Relax qiskit-aer requirement to qiskit-aer~=0.12.0. Allow qiskit-aer-0.12.0
    which has source archive on PyPI and can be installed for Python 3.12.
  • Bump up to quimb~=1.7 which installs correctly with Python 3.12
    Remove quimb-only dependencies from our requirements, let
    quimb sort out its dependencies itself.
  • CI - add pytest jobs with Python 3.12
  • Skip mysteriously failing test of Contract-a-Grid-Circuit.ipynb

Fixes #6460

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.79%. Comparing base (bfba965) to head (65bfddf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6516   +/-   ##
=======================================
  Coverage   97.79%   97.79%           
=======================================
  Files        1124     1124           
  Lines       95705    95707    +2     
=======================================
+ Hits        93595    93597    +2     
  Misses       2110     2110           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added Stale and removed Stale labels Apr 21, 2024
@CirqBot CirqBot added the size: S 10< lines changed <50 label May 5, 2024
@migueltorrescosta
Copy link
Contributor

Thank you @pavoljuhas for working on making Cirq Python 3.12 compatible. I see that some packages were bumped in order for tests to pass. Is there a policy for updating Cirq dependencies? For example,

  • I use poetry to manage my packages, which makes updating to the latest version feasible by the command poetry update.
  • Dependabot and Renovate do this too, as bot contributors to the repo ( i.e. they create their own PRs whenever an update is possible )

Older versions failed to create venv from already virtual Python 3.12.
Also allow never filelock versions needed by virtualenv.
For Python 3.12 the new environment may not have setuptools and wheel.
pylatex-1.4.2 is the first version compatible with Python 3.12.
Needed for compatibility with Python 3.12
Executed  dev_tools/build-protos.sh
Allow qiskit-aer-0.12.0 which has source distribution on PyPI and thus
can be installed for Python 3.12.  The later qiskit-aer-0.12.X releases
are provided as binary wheels only without a variant for Python 3.12.
Remove quimb dependencies from our requirements specifications
as we do not import them directly in Cirq.
Keep `opt_einsum` requirement which is an optional quimb dependency.
Otherwise let quimb sort out its dependencies.
@pavoljuhas pavoljuhas marked this pull request as ready for review May 9, 2024 00:24
@pavoljuhas pavoljuhas requested review from wcourtney, vtomole, cduck, verult and a team as code owners May 9, 2024 00:24
@pavoljuhas
Copy link
Collaborator Author

Thank you @pavoljuhas for working on making Cirq Python 3.12 compatible. I see that some packages were bumped in order for tests to pass. Is there a policy for updating Cirq dependencies? For example,

  • I use poetry to manage my packages, which makes updating to the latest version feasible by the command poetry update.
  • Dependabot and Renovate do this too, as bot contributors to the repo ( i.e. they create their own PRs whenever an update is possible )

Thank you for your comment. In general we try to follow the NEP-29 version policy for Python and NumPy. As for other packages, we seek to use loose version specifications, e.g., somepackage~=1.2 to freeze the major version but match recent minor releases which in theory should have compatible APIs. Cirq is often used as a library that should be installable with other projects so we do not want to restrict its dependency specifications more than needed. If there is a breaking change for some third-party release, we add an upper bound for the last working version. These rules have a tendency to get outdated, which is a part of the process that could be improved.
We revisit dependencies at the release time or when there is a need for major-version upgrade of some package.

In regards to the poetry, the poetry update creates a lock file with exact versions of all direct and transitive dependencies at the time of execution - which is useful for reproducible installations. The lock files are resolved from package version constrains in pyproject.toml which need manual updates so that part of labor seems to be the same.

It would be nice to get notifications when our requirement specs exclude the latest stable releases.
We are glad to consider suggestions if you (or others) know of such tool.

Copy link
Collaborator

@NoureldinYosri NoureldinYosri left a comment

Choose a reason for hiding this comment

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

thanks for the great job @pavoljuhas

@migueltorrescosta
Copy link
Contributor

Thank you for the thorough answer @pavoljuhas. My suggested approach would be either Dependabot or Renovate, as they generate small PRs which only update the relevant versions, making it easier to approve/reject version bumps. Usually it's nice to limit these to major versions, otherwise we get flooded with these PRs, and as maintainers there are more important things you can focus on :) I'd recommend:

  1. Creating an issue to automatise version updates through Dependabot / Renovate / maybe even snyk for vulnerability detection, so that maintainers don't have to spend time on it when needed. It is not urgent, so it would probably sit in the backlog until someone wants to take this work, as it should.
  2. Merging this PR as is. It is independent of the above

Do you want me to create the issue?

@pavoljuhas pavoljuhas merged commit 46eab2d into quantumlib:main May 9, 2024
34 checks passed
@pavoljuhas pavoljuhas deleted the support-python-3.12 branch May 9, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Python 3.12
4 participants