diff --git a/spacy/cli/info.py b/spacy/cli/info.py index 2b7fcfacb..c6b1b7631 100644 --- a/spacy/cli/info.py +++ b/spacy/cli/info.py @@ -12,7 +12,7 @@ from .. import util def info(model=None, markdown=False): if model: data_path = util.get_data_path() - data = util.parse_package_meta(data_path, model, require=True) + data = util.parse_package_meta(data_path / model, require=True) model_path = Path(__file__).parent / data_path / model if model_path.resolve() != model_path: data['link'] = path2str(model_path) diff --git a/spacy/util.py b/spacy/util.py index 0790cc869..e7f52fda0 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -142,20 +142,17 @@ def get_model_package_path(package_name): # Python's installation and import rules are very complicated. pkg = importlib.import_module(package_name) package_path = Path(pkg.__file__).parent.parent - meta = parse_package_meta(package_path, package_name) + meta = parse_package_meta(package_path / package_name) model_name = '%s-%s' % (package_name, meta['version']) return package_path / package_name / model_name -def parse_package_meta(package_path, package, require=True): +def parse_package_meta(package_path, require=True): """ Check if a meta.json exists in a package and return its contents as a dictionary. If require is set to True, raise an error if no meta.json found. """ - # TODO: Allow passing in full model path and only require one argument - # instead of path and package name. This lets us avoid passing in an awkward - # empty string in spacy.load() if user supplies full model path. - location = package_path / package / 'meta.json' + location = package_path / 'meta.json' if location.is_file(): return read_json(location) elif require: