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

Consolidate packaging functions into framework.package_deps #1429

Merged
merged 4 commits into from
Mar 26, 2024

Conversation

wshanks
Copy link
Collaborator

@wshanks wshanks commented Mar 21, 2024

Queries and tests of installed package versions were spread across a few different modules. Here they are combined into one module (package_deps.py) as suggested in
#1427.

Queries and tests of installed package versions were spread across a few
different modules. Here they are combined into one module
(`package_deps.py`) as suggested in
qiskit-community#1427.
@wshanks wshanks requested a review from coruscating March 21, 2024 17:08
Copy link
Collaborator

@coruscating coruscating left a comment

Choose a reason for hiding this comment

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

Thanks, looks good. Just left some minor notes.

qiskit_experiments/framework/package_deps.py Outdated Show resolved Hide resolved
If ``package`` is not installed.
"""
installed_version = Version(metadata_version(package))
return installed_version > Version(f"{version}.dev0")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is nice! It seems like it can't handle some unusual version strings but I don't think we would encounter any of them. Perhaps we could catch any potential errors here just to be safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see the potential problem, but what should we do after catching an error? Here we are only set up to return a boolean and if we can't parse then we can't say either way. I could add some custom parsing but that leads to the debate you linked to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

One idea -- PEP440 is pretty old. Anything we are likely to care about should be following it by now. So if we get a version that doesn't parse, we can assume it is old and return False.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that! And emit a warning about the version string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me know if the new commit looks good.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The new code looks good. Should the greater than sign be greater than and equal to though? Right now 0.5.0.dev1 is considered to be at least 0.5.0 but 0.5.0.dev0 is not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, good, point. I will fix that and add the PR to the merge queue unless you notice something else 🙂

@wshanks wshanks enabled auto-merge March 26, 2024 19:42
@wshanks wshanks added this pull request to the merge queue Mar 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 26, 2024
@coruscating coruscating added this pull request to the merge queue Mar 26, 2024
Merged via the queue into qiskit-community:main with commit cf6222d Mar 26, 2024
11 checks passed
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