From 8b30b579571d2af259f14d360877b7563065cf6d Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Mon, 7 Oct 2019 13:26:03 +0200 Subject: [PATCH] Revert "Only import pkg_resources where it's needed" This reverts commit 5ed8c03afac098e6b676e1da44486b7f7dc30f73. --- spacy/cli/download.py | 3 +-- spacy/cli/validate.py | 3 +-- spacy/util.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/spacy/cli/download.py b/spacy/cli/download.py index c57e2364b..64ab03a75 100644 --- a/spacy/cli/download.py +++ b/spacy/cli/download.py @@ -6,6 +6,7 @@ import requests import os import subprocess import sys +import pkg_resources from wasabi import Printer from .link import link @@ -86,8 +87,6 @@ def download(model, direct=False, *pip_args): def require_package(name): try: - import pkg_resources - pkg_resources.working_set.require(name) return True except: # noqa: E722 diff --git a/spacy/cli/validate.py b/spacy/cli/validate.py index 38f8d2313..f608ccd7f 100644 --- a/spacy/cli/validate.py +++ b/spacy/cli/validate.py @@ -1,6 +1,7 @@ # coding: utf8 from __future__ import unicode_literals, print_function +import pkg_resources from pathlib import Path import sys import requests @@ -108,8 +109,6 @@ def get_model_links(compat): def get_model_pkgs(compat, all_models): - import pkg_resources - pkgs = {} for pkg_name, pkg_data in pkg_resources.working_set.by_key.items(): package = pkg_name.replace("-", "_") diff --git a/spacy/util.py b/spacy/util.py index 103fe35b5..730f29f64 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals, print_function import os +import pkg_resources import importlib import re from pathlib import Path @@ -252,8 +253,6 @@ def is_package(name): name (unicode): Name of package. RETURNS (bool): True if installed package, False if not. """ - import pkg_resources - name = name.lower() # compare package name against lowercase name packages = pkg_resources.working_set.by_key.keys() for package in packages: