mirror of https://github.com/pypa/pip
Use module.__file__
This commit is contained in:
parent
021eddcb70
commit
76257e4b65
|
@ -87,8 +87,12 @@ def get_vendor_version_from_module(module_name):
|
|||
|
||||
if not version:
|
||||
# Try to find version in debundled module info
|
||||
# The type for module.__file__ is Optional[str] in
|
||||
# Python 2, and str in Python 3. The type: ignore is
|
||||
# added to account for Python 2, instead of a cast
|
||||
# and should be removed once we drop Python 2 support
|
||||
pkg_set = pkg_resources.WorkingSet(
|
||||
[os.path.dirname(getattr(module, '__file__', None))]
|
||||
[os.path.dirname(module.__file__)] # type: ignore
|
||||
)
|
||||
package = pkg_set.find(pkg_resources.Requirement.parse(module_name))
|
||||
version = getattr(package, 'version', None)
|
||||
|
|
Loading…
Reference in New Issue