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

Replace pkg_resources with importlib_metadata #51

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jorenretel
Copy link

Hi,

first of all, thanks for this great library. I just ran into this warning all the time about pkg_resources being deprecated when in favour of importlib.metadata.

In this pull request I replaces pas_resources with importlib_metadata: https://docs.python.org/3/library/importlib.metadata.html , this is a back port for Importlib.metadata which is only in the standard library since python 3.8. By explicitly using importlib_metadata, older versions of python 3 are also still supported by NCLS. An alternative would be for NCLS to stop supporting python versions older than 3.8 and use the importlib.metadata from the standard library.

@jorenretel jorenretel changed the title Replace pkg_resources with Importliberalisierungen_metadata Replace pkg_resources with importlib_metadata Aug 22, 2023
@endrebak
Copy link
Collaborator

I'll have a look at this tomorrow, thanks :D

@sstrong99
Copy link

I'm getting an error that might be fixed by this PR:

...
  File "/usr/local/lib/python3.8/dist-packages/TFEA/rank.py", line 1370, in meta_profile_bg
    from ncls import NCLS
  File "/usr/local/lib/python3.8/dist-packages/ncls/__init__.py", line 2, in <module>
    import pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3254, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3237, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3266, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 575, in _build_master
    ws = cls()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 568, in __init__
    self.add_entry(entry)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 624, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1970, in find_distributions
    importer = get_importer(path_item)
  File "/usr/lib/python3.8/pkgutil.py", line 419, in get_importer
    importer = path_hook(path_item)
  File "<frozen importlib._bootstrap_external>", line 1594, in path_hook_for_FileFinder
  File "<frozen importlib._bootstrap_external>", line 1469, in __init__
  File "<frozen importlib._bootstrap_external>", line 177, in _path_isabs
AttributeError: 'PosixPath' object has no attribute 'startswith'

have you guys seen that before? and do you know if there's a workaround?

@jorenretel
Copy link
Author

Hi @sstrong99 ,

sorry for replying late on this. The problem you are having is not caused by NCLS, but by a bug in python: https://bugs.python.org/issue44061 . I think making a fresh and new python environment might solve your problem.

I think this PR might also solve the problem (but somewhat as a side effect).

@y9c
Copy link

y9c commented Jun 30, 2024

Same issues for python 3.12.

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.

4 participants