mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 01:48:04 +03:00 
			
		
		
		
	Merge pull request #12371 from rmitsch/sync/master-into-v4
Sync `v4` with latest from `master`
This commit is contained in:
		
						commit
						8ca71f9591
					
				
							
								
								
									
										5
									
								
								.github/azure-steps.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/azure-steps.yml
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -69,6 +69,11 @@ steps:
 | 
			
		|||
#    displayName: 'Test skip re-download (#12188)'
 | 
			
		||||
#    condition: eq(variables['python_version'], '3.8')
 | 
			
		||||
 | 
			
		||||
#  - script: |
 | 
			
		||||
#      python -W error -m spacy info ca_core_news_sm | grep -q download_url
 | 
			
		||||
#    displayName: 'Test download_url in info CLI'
 | 
			
		||||
#    condition: eq(variables['python_version'] '3.8')
 | 
			
		||||
 | 
			
		||||
  - script: |
 | 
			
		||||
      python -m spacy convert extra/example_data/ner_example_data/ner-token-per-line-conll2003.json .
 | 
			
		||||
    displayName: 'Test convert CLI'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
from typing import Optional, Dict, Any, Union, List
 | 
			
		||||
import platform
 | 
			
		||||
import pkg_resources
 | 
			
		||||
import json
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from wasabi import Printer, MarkdownRenderer
 | 
			
		||||
import srsly
 | 
			
		||||
import importlib.metadata
 | 
			
		||||
 | 
			
		||||
from ._util import app, Arg, Opt, string_to_list
 | 
			
		||||
from .download import get_model_filename, get_latest_version
 | 
			
		||||
| 
						 | 
				
			
			@ -137,14 +137,13 @@ def info_installed_model_url(model: str) -> Optional[str]:
 | 
			
		|||
    dist-info available.
 | 
			
		||||
    """
 | 
			
		||||
    try:
 | 
			
		||||
        dist = pkg_resources.get_distribution(model)
 | 
			
		||||
        data = json.loads(dist.get_metadata("direct_url.json"))
 | 
			
		||||
        dist = importlib.metadata.distribution(model)
 | 
			
		||||
        text = dist.read_text("direct_url.json")
 | 
			
		||||
        if isinstance(text, str):
 | 
			
		||||
            data = json.loads(text)
 | 
			
		||||
            return data["url"]
 | 
			
		||||
    except pkg_resources.DistributionNotFound:
 | 
			
		||||
        # no such package
 | 
			
		||||
        return None
 | 
			
		||||
    except Exception:
 | 
			
		||||
        # something else, like no file or invalid JSON
 | 
			
		||||
        pass
 | 
			
		||||
    return None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,6 @@ from typing import Optional, List, Dict, Sequence, Any, Iterable, Tuple
 | 
			
		|||
import os.path
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
import pkg_resources
 | 
			
		||||
from wasabi import msg
 | 
			
		||||
from wasabi.util import locale_escape
 | 
			
		||||
import sys
 | 
			
		||||
| 
						 | 
				
			
			@ -331,6 +330,7 @@ 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
 | 
			
		||||
        exist.
 | 
			
		||||
    """
 | 
			
		||||
    import pkg_resources
 | 
			
		||||
 | 
			
		||||
    failed_pkgs_msgs: List[str] = []
 | 
			
		||||
    conflicting_pkgs_msgs: List[str] = []
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,6 @@ import os
 | 
			
		|||
import math
 | 
			
		||||
from collections import Counter
 | 
			
		||||
from typing import Tuple, List, Dict, Any
 | 
			
		||||
import pkg_resources
 | 
			
		||||
import time
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1126,6 +1125,7 @@ def test_cli_find_threshold(capsys):
 | 
			
		|||
                )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
 | 
			
		||||
@pytest.mark.parametrize(
 | 
			
		||||
    "reqs,output",
 | 
			
		||||
    [
 | 
			
		||||
| 
						 | 
				
			
			@ -1158,6 +1158,8 @@ def test_cli_find_threshold(capsys):
 | 
			
		|||
    ],
 | 
			
		||||
)
 | 
			
		||||
def test_project_check_requirements(reqs, output):
 | 
			
		||||
    import pkg_resources
 | 
			
		||||
 | 
			
		||||
    # excessive guard against unlikely package name
 | 
			
		||||
    try:
 | 
			
		||||
        pkg_resources.require("spacyunknowndoesnotexist12345")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user