From 4fd087572a1c597781fef8ca4fbcfebed825c0fb Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Thu, 28 May 2020 12:51:37 +0200 Subject: [PATCH] WIP: improve model version deps --- spacy/cli/package.py | 2 +- spacy/util.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spacy/cli/package.py b/spacy/cli/package.py index cf93c872f..15ae2033c 100644 --- a/spacy/cli/package.py +++ b/spacy/cli/package.py @@ -138,7 +138,7 @@ def list_files(data_dir): def list_requirements(meta): parent_package = meta.get('parent_package', 'spacy') - requirements = [parent_package + meta['spacy_version']] + requirements = [parent_package + '>=' + meta['spacy_version']] if 'setup_requires' in meta: requirements += meta['setup_requires'] if 'requirements' in meta: diff --git a/spacy/util.py b/spacy/util.py index b614c29c7..4e468ef9d 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -265,6 +265,15 @@ def is_compatible_model(meta): return True +def get_model_version_range(version): + """Generate a version range like >=1.2.3,<1.3.0 based on a given spaCy + version. Models are always compatible across patch versions but not + across minor or major versions. + """ + major, minor = split_version(version) + return f">={version},<{major}.{minor + 1}.0" + + def load_config(path, create_objects=False): """Load a Thinc-formatted config file, optionally filling in objects where the config references registry entries. See "Thinc config files" for details.