Skip to content

Commit

Permalink
Remove dependency on pkg_resources (#307)
Browse files Browse the repository at this point in the history
The only reason we needed this was to look at the version metadata and
the installation location. We can do this with `importlib.metadata`
which is part of Python since 3.8 and is significantly faster to import
than `pkg_resources`.
  • Loading branch information
lkollar authored May 21, 2021
1 parent 4b05be8 commit 0c59594
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions auditwheel/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import os
import pathlib
import sys
import logging
import argparse
import pkg_resources
try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata # type: ignore
from typing import Optional

import auditwheel
from . import main_show
from . import main_addtag
from . import main_lddtree
Expand All @@ -16,9 +21,9 @@ def main() -> Optional[int]:
print('Error: This tool only supports Linux')
return 1

dist = pkg_resources.get_distribution('auditwheel')
location = pathlib.Path(auditwheel.__file__).parent.resolve()
version = 'auditwheel {} installed at {} (python {}.{})'.format(
dist.version, dist.location, *sys.version_info)
metadata.version("auditwheel"), location, *sys.version_info)

p = argparse.ArgumentParser(description='Cross-distro Python wheels.')
p.set_defaults(prog=os.path.basename(sys.argv[0]))
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyelftools>=0.24
importlib_metadata; python_version < "3.8"

0 comments on commit 0c59594

Please sign in to comment.