please
please copied to clipboard
Investigate if pex tool can better handle importlib_metadata.version calls
Having the dependency below:
python_wheel(name="prettytable",
outs=["prettytable", "prettytable-2.2.1.dist-info"],
hashes=["09fb2c7f93e4f93e0235f05ae199ac3f16da3a251b2cfa1c7108b34ede298fa3"],
licences=["BSD 3-Clause"],
version="2.2.1",
deps=[":wcwidth"])
And trying to import the library on a python script results in:
Traceback (most recent call last):
File "/opt/tm/tools/python/3.9.6/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/.../usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/.../third_party_versions/pypi_versions.pex/__main__.py", line 385, in <module>
File "/.../third_party_versions/pypi_versions.pex/__main__.py", line 377, in run
File "/.../third_party_versions/pypi_versions.pex/__main__.py", line 351, in interact
File "/.../third_party_versions/pypi_versions.pex/__main__.py", line 360, in main
File "/.../usr/lib/python3.9/runpy.py", line 213, in run_module
return _run_code(code, {}, init_globals, run_name, mod_spec)
File "/.../usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File ".../third_party_versions/pypi_versions.py", line 20, in <module>
from third_party.python3 import prettytable
File ".../third_party_versions/pypi_versions.pex/__main__.py", line 188, in load_module
File "/.../usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen zipimport>", line 259, in load_module
File "/.../third_party_versions/pypi_versions.pex/third_party/python3/prettytable/__init__.py", line 50, in <module>
File "/.../usr/lib/python3.9/importlib/metadata.py", line 551, in version
return distribution(distribution_name).version
File "/.../usr/lib/python3.9/importlib/metadata.py", line 524, in distribution
return Distribution.from_name(distribution_name)
File "/.../usr/lib/python3.9/importlib/metadata.py", line 187, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: prettytable
The offending statement in prettytable is __version__ = importlib_metadata.version(__name__).
The current workaround is to replace importlib_metadata.version(__name__) with the package version via a patch. Ideally, we wouldn't need to do this.
This issue has been automatically marked as stale because it has not had any recent activity in the past 90 days. It will be closed if no further activity occurs. If you require additional support, please reply to this message. Thank you for your contributions.