mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 16:22:29 +03:00
Handle deprecation of pkg_resources
* Replace `pkg_resources` with `importlib_metadata` for `spacy info --url` * Remove requirements check from `spacy project` given the lack of alternatives
This commit is contained in:
parent
6aa6b86d49
commit
586ec16114
5
.github/azure-steps.yml
vendored
5
.github/azure-steps.yml
vendored
|
@ -59,6 +59,11 @@ steps:
|
||||||
displayName: 'Test download CLI'
|
displayName: 'Test download CLI'
|
||||||
condition: eq(variables['python_version'], '3.8')
|
condition: eq(variables['python_version'], '3.8')
|
||||||
|
|
||||||
|
- script: |
|
||||||
|
python -W error -m spacy info ca_core_news_sm --url
|
||||||
|
displayName: 'Test info --url CLI'
|
||||||
|
condition: eq(variables['python_version'], '3.8')
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
python -W error -c "import ca_core_news_sm; nlp = ca_core_news_sm.load(); doc=nlp('test')"
|
python -W error -c "import ca_core_news_sm; nlp = ca_core_news_sm.load(); doc=nlp('test')"
|
||||||
displayName: 'Test no warnings on load (#11713)'
|
displayName: 'Test no warnings on load (#11713)'
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from typing import Optional, Dict, Any, Union, List
|
from typing import Optional, Dict, Any, Union, List
|
||||||
import platform
|
import platform
|
||||||
import pkg_resources
|
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from wasabi import Printer, MarkdownRenderer
|
from wasabi import Printer, MarkdownRenderer
|
||||||
|
@ -10,6 +9,7 @@ from ._util import app, Arg, Opt, string_to_list
|
||||||
from .download import get_model_filename, get_latest_version
|
from .download import get_model_filename, get_latest_version
|
||||||
from .. import util
|
from .. import util
|
||||||
from .. import about
|
from .. import about
|
||||||
|
from ..compat import importlib_metadata
|
||||||
|
|
||||||
|
|
||||||
@app.command("info")
|
@app.command("info")
|
||||||
|
@ -137,10 +137,10 @@ def info_installed_model_url(model: str) -> Optional[str]:
|
||||||
dist-info available.
|
dist-info available.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
dist = pkg_resources.get_distribution(model)
|
dist = importlib_metadata.distribution(model)
|
||||||
data = json.loads(dist.get_metadata("direct_url.json"))
|
data = dist.read_text("direct_url.json")
|
||||||
return data["url"]
|
return data["url"]
|
||||||
except pkg_resources.DistributionNotFound:
|
except importlib_metadata.PackageNotFoundError:
|
||||||
# no such package
|
# no such package
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -2,7 +2,6 @@ from typing import Optional, List, Dict, Sequence, Any, Iterable, Tuple
|
||||||
import os.path
|
import os.path
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
from wasabi import msg
|
from wasabi import msg
|
||||||
from wasabi.util import locale_escape
|
from wasabi.util import locale_escape
|
||||||
import sys
|
import sys
|
||||||
|
@ -331,6 +330,12 @@ def _check_requirements(requirements: List[str]) -> Tuple[bool, bool]:
|
||||||
RETURNS (Tuple[bool, bool]): Whether (1) any packages couldn't be imported, (2) any packages with version conflicts
|
RETURNS (Tuple[bool, bool]): Whether (1) any packages couldn't be imported, (2) any packages with version conflicts
|
||||||
exist.
|
exist.
|
||||||
"""
|
"""
|
||||||
|
msg.warn("Requirements checks are being skipped.")
|
||||||
|
return False, False
|
||||||
|
|
||||||
|
|
||||||
|
def _check_requirements_pkg_resources(requirements: List[str]) -> Tuple[bool, bool]:
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
failed_pkgs_msgs: List[str] = []
|
failed_pkgs_msgs: List[str] = []
|
||||||
conflicting_pkgs_msgs: List[str] = []
|
conflicting_pkgs_msgs: List[str] = []
|
||||||
|
|
|
@ -1126,6 +1126,7 @@ def test_cli_find_threshold(capsys):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"reqs,output",
|
"reqs,output",
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user