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

Add Python 3.12 support #580

Merged
merged 3 commits into from
Feb 26, 2024
Merged

Add Python 3.12 support #580

merged 3 commits into from
Feb 26, 2024

Conversation

t-imamichi
Copy link
Collaborator

@t-imamichi t-imamichi commented Dec 11, 2023

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

@t-imamichi t-imamichi added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Dec 11, 2023
@coveralls
Copy link

coveralls commented Dec 11, 2023

Pull Request Test Coverage Report for Build 8044670802

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.029%

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

💛 - Coveralls

@dthuerck
Copy link
Contributor

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).

dthuerck
dthuerck previously approved these changes Dec 11, 2023
Copy link
Contributor

@dthuerck dthuerck left a comment

Choose a reason for hiding this comment

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

See comment above - works, but user experience might be better served with adding warnings.

@t-imamichi
Copy link
Collaborator Author

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.

@_optionals.HAS_CPLEX.require_in_instance
class CplexOptimizer(OptimizationAlgorithm):

@woodsp-ibm
Copy link
Member

woodsp-ibm commented Dec 11, 2023

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
Copy link
Collaborator Author

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

@woodsp-ibm woodsp-ibm added the on hold Can not fix yet label Feb 9, 2024
@t-imamichi t-imamichi changed the title Add constraint for cplex Add Python 3.12 support Feb 22, 2024
@t-imamichi
Copy link
Collaborator Author

t-imamichi commented Feb 22, 2024

@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
Copy link
Member

woodsp-ibm commented Feb 22, 2024

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
Copy link
Collaborator Author

Thanks. I added reno.

Copy link
Member

@woodsp-ibm woodsp-ibm left a comment

Choose a reason for hiding this comment

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

LGTM

@woodsp-ibm woodsp-ibm removed the on hold Can not fix yet label Feb 26, 2024
@woodsp-ibm woodsp-ibm merged commit a52d23d into qiskit-community:main Feb 26, 2024
16 checks passed
mergify bot pushed a commit that referenced this pull request Feb 26, 2024
* add constraint for cplex

* Add Python 3.12 support

* reno

(cherry picked from commit a52d23d)
mergify bot added a commit that referenced this pull request Feb 26, 2024
* add constraint for cplex

* Add Python 3.12 support

* reno

(cherry picked from commit a52d23d)

Co-authored-by: Takashi Imamichi <[email protected]>
@t-imamichi t-imamichi deleted the cplex branch February 27, 2024 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Python 3.12 support cannot import "BaseBackent" from "qiskit.providers"
4 participants