Skip to content

Commit

Permalink
Merge pull request #5605 from yarikoptic/bf-pygithub-version-etc
Browse files Browse the repository at this point in the history
ENH: external_versions - add lookup table for github -> pygithub
  • Loading branch information
yarikoptic committed Apr 27, 2021
2 parents 9e1af30 + c992d99 commit b7eaa4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion datalad/support/external_versions.py
Expand Up @@ -152,6 +152,11 @@ class ExternalVersions(object):
'cmd:system-ssh': _get_system_ssh_version,
'cmd:7z': _get_system_7z_version,
}
# ad-hoc hardcoded map for relevant Python packages which do not provide
# __version__ and are shipped by a differently named pypi package
_PYTHON_PACKAGES = { # Python package -> distribution package
'github': 'pygithub',
}
_INTERESTING = (
'annexremote',
'appdirs',
Expand Down Expand Up @@ -189,9 +194,10 @@ def _deduce_version(klass, value):

# try pkg_resources
if version is None and hasattr(value, '__name__'):
pkg_name = klass._PYTHON_PACKAGES.get(value.__name__, value.__name__)
try:
import pkg_resources
version = pkg_resources.get_distribution(value.__name__).version
version = pkg_resources.get_distribution(pkg_name).version
except Exception:
pass

Expand Down
2 changes: 1 addition & 1 deletion datalad/support/tests/test_external_versions.py
Expand Up @@ -119,7 +119,7 @@ def test_external_versions_popular_packages():
ev = ExternalVersions()

for modname in ('scipy', 'numpy', 'mvpa2', 'sklearn', 'statsmodels', 'pandas',
'matplotlib', 'psychopy'):
'matplotlib', 'psychopy', 'github'):
yield _test_external, ev, modname

# more of a smoke test
Expand Down

0 comments on commit b7eaa4b

Please sign in to comment.