mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-11 17:56:30 +03:00
Always compare lowercase package names
Otherwise, is_package will return False if model name contains uppercase characters. See this issue: https://support.prodi.gy/t/saving-a-trained-ner-model-as-a-loadable-modu le/46/6
This commit is contained in:
parent
153c2589d4
commit
8dbe49ecb8
|
@ -181,9 +181,10 @@ def is_package(name):
|
|||
name (unicode): Name of package.
|
||||
RETURNS (bool): True if installed package, False if not.
|
||||
"""
|
||||
name = name.lower() # compare package name against lowercase name
|
||||
packages = pkg_resources.working_set.by_key.keys()
|
||||
for package in packages:
|
||||
if package.replace('-', '_') == name:
|
||||
if package.lower().replace('-', '_') == name:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -194,6 +195,7 @@ def get_package_path(name):
|
|||
name (unicode): Package name.
|
||||
RETURNS (Path): Path to installed package.
|
||||
"""
|
||||
name = name.lower() # use lowercase version to be safe
|
||||
# Here we're importing the module just to find it. This is worryingly
|
||||
# indirect, but it's otherwise very difficult to find the package.
|
||||
pkg = importlib.import_module(name)
|
||||
|
|
Loading…
Reference in New Issue
Block a user