-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Added support for querying version information in the Qiskit C API. #14423
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
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
Archit Chadalawada seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this, I think the approach you're using here is a bit more complicated than it needs to be. Couldn't we just define a couple of pub constants in the cext rust code and then tell cbindgen to include them in the header? If so then we can just use the cargo env variables to populate the version numbers appropriately.
Oh also you appear to have authored commits with a different email address not associated with your github account. You'll either need to associate that email account to your github account, or edit the commits on your branch to reset the author metadata to use the correct email address and force push that updated history to your PR's branch on your fork. We won't be able to merge a PR if the CLA bot isn't all green. |
Okay, I am working on it. 👍 |
83273cd
to
bec775e
Compare
I have updated the code as well as force pushed the correct author information. Summary
Details and commentsThe approach used includes the following changes:
This enables the Please let me know if this approach is okay. |
I'm not super sure about this approach, since we effectively end up with some version number committed in I was hoping we could have a solution where we could dynamically add the version numbers to the header, but after scouting the cbindgen docs I couldn't find anything suitable that allows to extend e.g. the I'm wondering whether at this point it wouldn't just be easier to hardcode the version number? Or a compromise, if we want to stick with the cargo-generated version, we could maybe have a placeholder comment in the |
Sure @Cryoris . Actually, the So, If you try testing this by removing the version numbers from the Please let me know in case I am missing something. |
We discussed offline with @mtreinish and came to the conclusion that it's probably simpler to just hardcode the version number, without any additional cbindgen logic. That is partially motivated by #14430, which we'll likely change to sooner than later, which drops cbindgen anyways. Could you update the code accordingly? 🙂 |
Okay @Cryoris. I have updated the code to use the hard-coded version information directly without any additional logic related to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, this generally looks good to me now. I left some small comments below.
Thank you so much! 🙂 I have made the suggested changes @Cryoris. |
@velocityraptor7085 the history of this PR includes some commits that don't belong here (e.g. beeb97c). Would you mind rebasing to remove these or just clean the history?
It's often considered good practice because some tools expect the last line to be a linebreak (see e.g. https://stackoverflow.com/questions/2287967/why-is-it-recommended-to-have-empty-line-in-the-end-of-a-source-file) Another note: you don't have to keep updating your branch with the |
de970b0
to
0a8178f
Compare
Also, let us know if you need help cleaning up the history. |
Co-authored-by: Julien Gacon <gaconju@gmail.com>
de970b0
to
1b885ee
Compare
Thanks a lot. I just made the changes. Let me know if the changes are good to go. |
Pull Request Test Coverage Report for Build 15350808054Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this, I think it mostly looks good. Just one small inline question. Besides that can you add a release note to document the addition to the C API. The documentation around this is here: https://github.com/Qiskit/qiskit/blob/main/CONTRIBUTING.md#release-notes
Okay I'll have a look and add a release note 👍 |
@mtreinish Please let me know if the changes are appropriate. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some comments on the release notes, thanks for adding them.
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Thanks a lot for your help @mtreinish ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM now thanks for the updates. I left a small comment inline about a missing copyright header. I'll apply that and then approve this for merge.
…iskit#14423) * Added support for querying version information in the Qiskit C API. * Added support for querying version information in the Qiskit C API. * Added support for querying version information in the Qiskit C API. * Added support for querying version information in the Qiskit C API. * Added support for querying version information in the Qiskit C API. * Added support for querying version information in the Qiskit C API. * Added support for querying version information in the Qiskit C API. * Updated cbindgen.toml with version numbers for the Qiskit C API * Update crates/cext/cbindgen.toml Co-authored-by: Julien Gacon <gaconju@gmail.com> * Updated cbindgen.toml with version numbers for the Qiskit C API * updated Makefile * updated Makefile * Removed printf statement in the test file * Added release note for C API version support * Update releasenotes/notes/c-api-version-support-55b018bf9552db1f.yaml Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Update releasenotes/notes/c-api-version-support-55b018bf9552db1f.yaml Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Add missing license header to the test file --------- Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Summary
Details and comments
The approach used includes the following changes:
version.h
in the directorycrates/cext
having macros for the version information.version.h
macros in theqiskit.h
file generated for the C API calls (added through thecbindgen.toml
file withincrates/cext
).version.h
file by reading theVERSION.txt
file (within theqiskit
subdirectory) by thebuild.rs
code via regex matching and replacement at compile time (for this an additional build dependencyregex = "1"
was added to theCargo.toml
file in thecext
crate). The removes the need to update the header for every new release.cargo fmt
and passed thetox -elint
test.test_version_info.c
file in the test/c directory.