qiskit-community / qiskit-optimization

Quantum Optimization
https://qiskit-community.github.io/qiskit-optimization/
Apache License 2.0
213 stars 134 forks source link

Add Python 3.12 support #580

Closed t-imamichi closed 3 months ago

t-imamichi commented 6 months ago

Summary

Closes #590

Add Python 3.12 support. But since CPLEX does not support Python 3.12 (see pypi), we need to add constraint to 'cplex' extra dependency. Windows and mac are still tested with Python 3.11 because cplex are not available for 3.12.

Fixes #577

Details and comments

Latest cplex 22.1.1.1 image

coveralls commented 6 months ago

Pull Request Test Coverage Report for Build 8044670802

Details


Totals Coverage Status
Change from base Build 7982775151: 0.0%
Covered Lines: 4511
Relevant Lines: 4849

💛 - Coveralls
dthuerck commented 6 months ago

Works as intended - on 3.12 , cplex is not installed. On 3.10, all is good. However, shouldn't we either write this down either in the README or, even better, give a warning to users of Python 3.12. As it is now, the package happily installs (without cplex) but then gives the same error as in #577.

One idea would be, e.g., to guard the cplex imports with a warning if users are on 3.12 (as long as there is no updated cplex package).

t-imamichi commented 6 months ago

If cplex does not exists, we already display a warning message with @_optionals.HAS_CPLEX. It might be nice to elaborate the message to mention that cplex is not available for python 3.12 at this moment. https://github.com/qiskit-community/qiskit-optimization/blob/36ad1a13984403e77a5308fc38d61ee1a1a1637d/qiskit_optimization/algorithms/cplex_optimizer.py#L28-L29

woodsp-ibm commented 6 months ago

Arguably qiskit-optimization does not support 3.12 yet. Qiskit 0.45.1 added 3.12 support. I added support to qiskit algorithms qiskit-community/qiskit-algorithms#108 such that when this is released the apps, like Optimization here, could be updated to inlcude 3.12 as well.

It might make more sense to do this in a PR which adds 3.12 support and CI jobs etc. once algorithms is released. And then do an update (bug fix) release.

t-imamichi commented 6 months ago

Yes, it makes sense to include this PR's change as part of a separate PR to add support for Python 3.12.

t-imamichi commented 3 months ago

@woodsp-ibm I added Python 3.12 support and CI (only Ubuntu + 3.12 due to lack of cplex). Could you take a look at it?

woodsp-ibm commented 3 months ago

As we are adding 3.12 to the list of supported versions in setup can we add a reno like I did in ML for the 3.12 support, see qiskit-community/qiskit-machine-learning#774 (its the same basic text as what I did in Nature and Algorithms for the same thing!)

t-imamichi commented 3 months ago

Thanks. I added reno.