mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 15:16:41 +00:00
Stop using pkg_resources
This commit is contained in:
parent
7c878b9b94
commit
fbbf1cf98a
@ -1,8 +1,7 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import locale, os, platform, subprocess, sys, traceback
|
import locale, os, platform, subprocess, sys, traceback
|
||||||
|
from importlib.metadata import version, PackageNotFoundError
|
||||||
|
|
||||||
|
|
||||||
def foldlines(s, numlines=None):
|
def foldlines(s, numlines=None):
|
||||||
@ -72,17 +71,10 @@ def print_as_ver():
|
|||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
||||||
|
|
||||||
def print_setuptools_ver():
|
def print_setuptools_ver():
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
print("setuptools:", version("setuptools"))
|
||||||
out = str(pkg_resources.require("setuptools"))
|
except PackageNotFoundError:
|
||||||
print("setuptools:", foldlines(out))
|
|
||||||
except (ImportError, EnvironmentError):
|
|
||||||
sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of setuptools. Exception follows\n")
|
|
||||||
traceback.print_exc(file=sys.stderr)
|
|
||||||
sys.stderr.flush()
|
|
||||||
except pkg_resources.DistributionNotFound:
|
|
||||||
print('setuptools: DistributionNotFound')
|
print('setuptools: DistributionNotFound')
|
||||||
|
|
||||||
|
|
||||||
@ -91,14 +83,8 @@ def print_py_pkg_ver(pkgname, modulename=None):
|
|||||||
modulename = pkgname
|
modulename = pkgname
|
||||||
print()
|
print()
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
print(pkgname + ': ' + version(pkgname))
|
||||||
out = str(pkg_resources.require(pkgname))
|
except PackageNotFoundError:
|
||||||
print(pkgname + ': ' + foldlines(out))
|
|
||||||
except (ImportError, EnvironmentError):
|
|
||||||
sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
|
|
||||||
traceback.print_exc(file=sys.stderr)
|
|
||||||
sys.stderr.flush()
|
|
||||||
except pkg_resources.DistributionNotFound:
|
|
||||||
print(pkgname + ': DistributionNotFound')
|
print(pkgname + ': DistributionNotFound')
|
||||||
try:
|
try:
|
||||||
__import__(modulename)
|
__import__(modulename)
|
||||||
|
Loading…
Reference in New Issue
Block a user