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

Remove dependency to pkg_resources #9691

Merged
merged 3 commits into from
Mar 1, 2023
Merged

Conversation

ikkoham
Copy link
Contributor

@ikkoham ikkoham commented Mar 1, 2023

Summary

Since pkg_resources.declare_namespace has been deprecated, our CI is failed.
I removed the dependency to pkg_resources.

Details and comments

CI message


==============================
Failed 1 tests - output below:
==============================

test.python.test_version.TestVersion.test_qiskit_version
--------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/Users/runner/work/1/s/test/python/test_version.py", line 25, in test_qiskit_version
    self.assertEqual(__version__, __qiskit_version__["qiskit-terra"])
                                  ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^

      File "/Users/runner/work/1/s/qiskit/version.py", line 168, in __getitem__
    self._load_versions()

      File "/Users/runner/work/1/s/qiskit/version.py", line 104, in _load_versions
    import pkg_resources

      File "/Users/runner/work/1/s/test-job/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3257, in <module>
    @_call_aside
     ^^^^^^^^^^^

      File "/Users/runner/work/1/s/test-job/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3232, in _call_aside
    f(*args, **kwargs)

      File "/Users/runner/work/1/s/test-job/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3283, in _initialize_master_working_set
    tuple(dist.activate(replace=False) for dist in working_set)

      File "/Users/runner/work/1/s/test-job/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3283, in <genexpr>
    tuple(dist.activate(replace=False) for dist in working_set)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/Users/runner/work/1/s/test-job/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2804, in activate
    declare_namespace(pkg)

      File "/Users/runner/work/1/s/test-job/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2298, in declare_namespace
    warnings.warn(msg, DeprecationWarning, stacklevel=2)

    DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages


@ikkoham ikkoham added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: None Do not include in changelog labels Mar 1, 2023
@ikkoham ikkoham requested a review from a team as a code owner March 1, 2023 07:24
@qiskit-bot
Copy link
Collaborator

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 the following people are requested to review this:

  • @Qiskit/terra-core

@ikkoham
Copy link
Contributor Author

ikkoham commented Mar 1, 2023

hmm importlib.metadata is >= Python 3.8

@coveralls
Copy link

coveralls commented Mar 1, 2023

Pull Request Test Coverage Report for Build 4302012175

  • 5 of 6 (83.33%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.02%) to 85.342%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/version.py 5 6 83.33%
Files with Coverage Reduction New Missed Lines %
src/sabre_swap/layer.rs 4 97.32%
Totals Coverage Status
Change from base Build 4296421416: 0.02%
Covered Lines: 67479
Relevant Lines: 79069

💛 - Coveralls

@ikkoham
Copy link
Contributor Author

ikkoham commented Mar 1, 2023

Copy link
Member

@1ucian0 1ucian0 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 quick reaction!

@1ucian0 1ucian0 merged commit b7a63c3 into Qiskit:main Mar 1, 2023
mergify bot pushed a commit that referenced this pull request Mar 1, 2023
mergify bot added a commit that referenced this pull request Mar 1, 2023
(cherry picked from commit b7a63c3)

Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
@ikkoham ikkoham deleted the pkg_resources branch March 1, 2023 13:33
@ikkoham ikkoham added the type: qa Issues and PRs that relate to testing and code quality label Mar 1, 2023
Comment on lines +105 to +108
if sys.version_info >= (3, 8):
from importlib.metadata import version
else:
from importlib_metadata import version
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, I think we can probably do this as a module level import. The pkg_resources import was done at runtime because it was exceedingly slow. I don't expect importlib.metadata to have this issue (but it would be worth checking to confirm) and I think it probably gets pulled in already via our plugin interfaces. That being said it doesn't actually matter in practice so it's not worth a follow up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I did not know the reason of lazy import here.

king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog stable backport potential The bug might be minimal and/or import enough to be port to stable type: qa Issues and PRs that relate to testing and code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants