mirror of
https://github.com/explosion/spaCy.git
synced 2025-05-29 18:23:06 +03:00
Drop python 3.6/3.7, remove unneeded compat (#12187)
* Drop python 3.6/3.7, remove unneeded compat * Remove unused import * Minimal python 3.8+ docs updates
This commit is contained in:
parent
1678a98449
commit
ec45f704b1
|
@ -3,7 +3,7 @@ repos:
|
||||||
rev: 22.3.0
|
rev: 22.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3.7
|
language_version: python3.8
|
||||||
additional_dependencies: ['click==8.0.4']
|
additional_dependencies: ['click==8.0.4']
|
||||||
- repo: https://github.com/pycqa/flake8
|
- repo: https://github.com/pycqa/flake8
|
||||||
rev: 5.0.4
|
rev: 5.0.4
|
||||||
|
|
|
@ -271,7 +271,7 @@ except: # noqa: E722
|
||||||
|
|
||||||
### Python conventions
|
### Python conventions
|
||||||
|
|
||||||
All Python code must be written **compatible with Python 3.6+**. More detailed
|
All Python code must be written **compatible with Python 3.8+**. More detailed
|
||||||
code conventions can be found in the [developer docs](https://github.com/explosion/spaCy/blob/master/extra/DEVELOPER_DOCS/Code%20Conventions.md).
|
code conventions can be found in the [developer docs](https://github.com/explosion/spaCy/blob/master/extra/DEVELOPER_DOCS/Code%20Conventions.md).
|
||||||
|
|
||||||
#### I/O and handling paths
|
#### I/O and handling paths
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ override SPACY_EXTRAS = spacy-lookups-data==1.0.2 jieba spacy-pkuseg==0.0.28 sud
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef PYVER
|
ifndef PYVER
|
||||||
override PYVER = 3.6
|
override PYVER = 3.8
|
||||||
endif
|
endif
|
||||||
|
|
||||||
VENV := ./env$(PYVER)
|
VENV := ./env$(PYVER)
|
||||||
|
|
|
@ -105,7 +105,7 @@ For detailed installation instructions, see the
|
||||||
|
|
||||||
- **Operating system**: macOS / OS X · Linux · Windows (Cygwin, MinGW, Visual
|
- **Operating system**: macOS / OS X · Linux · Windows (Cygwin, MinGW, Visual
|
||||||
Studio)
|
Studio)
|
||||||
- **Python version**: Python 3.6+ (only 64 bit)
|
- **Python version**: Python 3.8+ (only 64 bit)
|
||||||
- **Package managers**: [pip] · [conda] (via `conda-forge`)
|
- **Package managers**: [pip] · [conda] (via `conda-forge`)
|
||||||
|
|
||||||
[pip]: https://pypi.org/project/spacy/
|
[pip]: https://pypi.org/project/spacy/
|
||||||
|
|
|
@ -39,7 +39,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: "3.7"
|
versionSpec: "3.8"
|
||||||
- script: |
|
- script: |
|
||||||
pip install black==22.3.0
|
pip install black==22.3.0
|
||||||
python -m black spacy --check
|
python -m black spacy --check
|
||||||
|
@ -54,24 +54,6 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# We're only running one platform per Python version to speed up builds
|
# We're only running one platform per Python version to speed up builds
|
||||||
Python36Linux:
|
|
||||||
imageName: "ubuntu-20.04"
|
|
||||||
python.version: "3.6"
|
|
||||||
# Python36Windows:
|
|
||||||
# imageName: "windows-latest"
|
|
||||||
# python.version: "3.6"
|
|
||||||
# Python36Mac:
|
|
||||||
# imageName: "macos-latest"
|
|
||||||
# python.version: "3.6"
|
|
||||||
# Python37Linux:
|
|
||||||
# imageName: "ubuntu-20.04"
|
|
||||||
# python.version: "3.7"
|
|
||||||
Python37Windows:
|
|
||||||
imageName: "windows-latest"
|
|
||||||
python.version: "3.7"
|
|
||||||
# Python37Mac:
|
|
||||||
# imageName: "macos-latest"
|
|
||||||
# python.version: "3.7"
|
|
||||||
# Python38Linux:
|
# Python38Linux:
|
||||||
# imageName: "ubuntu-latest"
|
# imageName: "ubuntu-latest"
|
||||||
# python.version: "3.8"
|
# python.version: "3.8"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Our libraries
|
# Our libraries
|
||||||
spacy-legacy>=3.0.11,<3.1.0
|
spacy-legacy>=4.0.0.dev0,<4.1.0
|
||||||
spacy-loggers>=1.0.0,<2.0.0
|
spacy-loggers>=1.0.0,<2.0.0
|
||||||
cymem>=2.0.2,<2.1.0
|
cymem>=2.0.2,<2.1.0
|
||||||
preshed>=3.0.2,<3.1.0
|
preshed>=3.0.2,<3.1.0
|
||||||
|
@ -22,7 +22,6 @@ langcodes>=3.2.0,<4.0.0
|
||||||
# Official Python utilities
|
# Official Python utilities
|
||||||
setuptools
|
setuptools
|
||||||
packaging>=20.0
|
packaging>=20.0
|
||||||
typing_extensions>=3.7.4.1,<4.5.0; python_version < "3.8"
|
|
||||||
# Development dependencies
|
# Development dependencies
|
||||||
pre-commit>=2.13.0
|
pre-commit>=2.13.0
|
||||||
cython>=0.25,<3.0
|
cython>=0.25,<3.0
|
||||||
|
@ -31,8 +30,7 @@ pytest-timeout>=1.3.0,<2.0.0
|
||||||
mock>=2.0.0,<3.0.0
|
mock>=2.0.0,<3.0.0
|
||||||
flake8>=3.8.0,<6.0.0
|
flake8>=3.8.0,<6.0.0
|
||||||
hypothesis>=3.27.0,<7.0.0
|
hypothesis>=3.27.0,<7.0.0
|
||||||
mypy>=0.990,<0.1000; platform_machine != "aarch64" and python_version >= "3.7"
|
mypy>=0.990,<0.1000; platform_machine != "aarch64"
|
||||||
types-dataclasses>=0.1.3; python_version < "3.7"
|
|
||||||
types-mock>=0.1.1
|
types-mock>=0.1.1
|
||||||
types-setuptools>=57.0.0
|
types-setuptools>=57.0.0
|
||||||
types-requests
|
types-requests
|
||||||
|
|
|
@ -17,8 +17,6 @@ classifiers =
|
||||||
Operating System :: Microsoft :: Windows
|
Operating System :: Microsoft :: Windows
|
||||||
Programming Language :: Cython
|
Programming Language :: Cython
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Programming Language :: Python :: 3.6
|
|
||||||
Programming Language :: Python :: 3.7
|
|
||||||
Programming Language :: Python :: 3.8
|
Programming Language :: Python :: 3.8
|
||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
Programming Language :: Python :: 3.10
|
Programming Language :: Python :: 3.10
|
||||||
|
@ -31,10 +29,10 @@ project_urls =
|
||||||
[options]
|
[options]
|
||||||
zip_safe = false
|
zip_safe = false
|
||||||
include_package_data = true
|
include_package_data = true
|
||||||
python_requires = >=3.6
|
python_requires = >=3.8
|
||||||
install_requires =
|
install_requires =
|
||||||
# Our libraries
|
# Our libraries
|
||||||
spacy-legacy>=3.0.11,<3.1.0
|
spacy-legacy>=4.0.0.dev0,<4.1.0
|
||||||
spacy-loggers>=1.0.0,<2.0.0
|
spacy-loggers>=1.0.0,<2.0.0
|
||||||
murmurhash>=0.28.0,<1.1.0
|
murmurhash>=0.28.0,<1.1.0
|
||||||
cymem>=2.0.2,<2.1.0
|
cymem>=2.0.2,<2.1.0
|
||||||
|
@ -55,7 +53,6 @@ install_requires =
|
||||||
# Official Python utilities
|
# Official Python utilities
|
||||||
setuptools
|
setuptools
|
||||||
packaging>=20.0
|
packaging>=20.0
|
||||||
typing_extensions>=3.7.4.1,<4.5.0; python_version < "3.8"
|
|
||||||
langcodes>=3.2.0,<4.0.0
|
langcodes>=3.2.0,<4.0.0
|
||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Dict, Any, Union, List, Optional, Tuple, Iterable
|
from typing import Dict, Any, Union, List, Optional, Tuple, Iterable, Literal
|
||||||
from typing import TYPE_CHECKING, overload
|
from typing import TYPE_CHECKING, overload
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -16,7 +16,6 @@ from thinc.util import gpu_is_available
|
||||||
from configparser import InterpolationError
|
from configparser import InterpolationError
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ..compat import Literal
|
|
||||||
from ..schemas import ProjectConfigSchema, validate
|
from ..schemas import ProjectConfigSchema, validate
|
||||||
from ..util import import_file, run_command, make_tempdir, registry, logger
|
from ..util import import_file, run_command, make_tempdir, registry, logger
|
||||||
from ..util import is_compatible_version, SimpleFrozenDict, ENV_VARS
|
from ..util import is_compatible_version, SimpleFrozenDict, ENV_VARS
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union
|
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union
|
||||||
from typing import cast, overload
|
from typing import Literal, cast, overload
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import sys
|
import sys
|
||||||
|
@ -21,7 +21,6 @@ from ..pipeline._edit_tree_internals.edit_trees import EditTrees
|
||||||
from ..morphology import Morphology
|
from ..morphology import Morphology
|
||||||
from ..language import Language
|
from ..language import Language
|
||||||
from ..util import registry, resolve_dot_names
|
from ..util import registry, resolve_dot_names
|
||||||
from ..compat import Literal
|
|
||||||
from ..vectors import Mode as VectorsMode
|
from ..vectors import Mode as VectorsMode
|
||||||
from .. import util
|
from .. import util
|
||||||
|
|
||||||
|
|
|
@ -22,19 +22,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
cupy = None
|
cupy = None
|
||||||
|
|
||||||
if sys.version_info[:2] >= (3, 8): # Python 3.8+
|
|
||||||
from typing import Literal, Protocol, runtime_checkable
|
|
||||||
else:
|
|
||||||
from typing_extensions import Literal, Protocol, runtime_checkable # noqa: F401
|
|
||||||
|
|
||||||
# Important note: The importlib_metadata "backport" includes functionality
|
|
||||||
# that's not part of the built-in importlib.metadata. We should treat this
|
|
||||||
# import like the built-in and only use what's available there.
|
|
||||||
try: # Python 3.8+
|
|
||||||
import importlib.metadata as importlib_metadata
|
|
||||||
except ImportError:
|
|
||||||
from catalogue import _importlib_metadata as importlib_metadata # type: ignore[no-redef] # noqa: F401
|
|
||||||
|
|
||||||
from thinc.api import Optimizer # noqa: F401
|
from thinc.api import Optimizer # noqa: F401
|
||||||
|
|
||||||
pickle = pickle
|
pickle = pickle
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
from typing import Literal
|
||||||
import warnings
|
import warnings
|
||||||
from .compat import Literal
|
|
||||||
|
|
||||||
|
|
||||||
class ErrorsWithCodes(type):
|
class ErrorsWithCodes(type):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Iterator, Optional, Any, Dict, Callable, Iterable
|
from typing import Iterator, Optional, Any, Dict, Callable, Iterable, Literal
|
||||||
from typing import Union, Tuple, List, Set, Pattern, Sequence
|
from typing import Union, Tuple, List, Set, Pattern, Sequence
|
||||||
from typing import NoReturn, TYPE_CHECKING, TypeVar, cast, overload
|
from typing import NoReturn, TYPE_CHECKING, TypeVar, cast, overload
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ from .git_info import GIT_VERSION
|
||||||
from . import util
|
from . import util
|
||||||
from . import about
|
from . import about
|
||||||
from .lookups import load_lookups
|
from .lookups import load_lookups
|
||||||
from .compat import Literal
|
|
||||||
|
|
||||||
|
|
||||||
PipeCallable = Callable[[Doc], Doc]
|
PipeCallable = Callable[[Doc], Doc]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from typing import Any, List, Dict, Tuple, Optional, Callable, Union
|
from typing import Any, List, Dict, Tuple, Optional, Callable, Union, Literal
|
||||||
from typing import Iterator, Iterable, overload
|
from typing import Iterator, Iterable, overload
|
||||||
from ..compat import Literal
|
|
||||||
from ..vocab import Vocab
|
from ..vocab import Vocab
|
||||||
from ..tokens import Doc, Span
|
from ..tokens import Doc, Span
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from typing import List, Tuple, Union, Optional, Callable, Any, Dict, overload
|
from typing import List, Tuple, Union, Optional, Callable, Any, Dict, Literal
|
||||||
from ..compat import Literal
|
from typing import overload
|
||||||
from .matcher import Matcher
|
from .matcher import Matcher
|
||||||
from ..vocab import Vocab
|
from ..vocab import Vocab
|
||||||
from ..tokens import Doc, Span
|
from ..tokens import Doc, Span
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
from typing import Optional, List, Tuple, Any
|
from typing import Optional, List, Tuple, Any, Literal
|
||||||
from thinc.types import Floats2d
|
from thinc.types import Floats2d
|
||||||
from thinc.api import Model
|
from thinc.api import Model
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from ...errors import Errors, Warnings
|
from ...errors import Errors, Warnings
|
||||||
from ...compat import Literal
|
|
||||||
from ...util import registry
|
from ...util import registry
|
||||||
from ..tb_framework import TransitionModel
|
from ..tb_framework import TransitionModel
|
||||||
from ...tokens.doc import Doc
|
from ...tokens.doc import Doc
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
from typing import List, Dict, Callable, Tuple, Optional, Iterable, Any, cast
|
from typing import List, Dict, Callable, Tuple, Optional, Iterable, Any, cast
|
||||||
from typing import Union
|
from typing import Union, Protocol, runtime_checkable
|
||||||
from thinc.api import Config, Model, get_current_ops, set_dropout_rate, Ops
|
from thinc.api import Config, Model, get_current_ops, set_dropout_rate, Ops
|
||||||
from thinc.api import Optimizer
|
from thinc.api import Optimizer
|
||||||
from thinc.types import Ragged, Ints2d, Floats2d
|
from thinc.types import Ragged, Ints2d, Floats2d
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
from ..compat import Protocol, runtime_checkable
|
|
||||||
from ..scorer import Scorer
|
from ..scorer import Scorer
|
||||||
from ..language import Language
|
from ..language import Language
|
||||||
from .trainable_pipe import TrainablePipe
|
from .trainable_pipe import TrainablePipe
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from typing import Dict, List, Union, Optional, Any, Callable, Type, Tuple
|
from typing import Dict, List, Union, Optional, Any, Callable, Type, Tuple
|
||||||
from typing import Iterable, TypeVar, TYPE_CHECKING
|
from typing import Iterable, TypeVar, Literal, TYPE_CHECKING
|
||||||
from .compat import Literal
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from pydantic import BaseModel, Field, ValidationError, validator, create_model
|
from pydantic import BaseModel, Field, ValidationError, validator, create_model
|
||||||
from pydantic import StrictStr, StrictInt, StrictFloat, StrictBool, ConstrainedStr
|
from pydantic import StrictStr, StrictInt, StrictFloat, StrictBool, ConstrainedStr
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING, Protocol, runtime_checkable
|
||||||
from typing import Optional, Any, Iterable, Dict, Callable, Sequence, List
|
from typing import Optional, Any, Iterable, Dict, Callable, Sequence, List
|
||||||
from .compat import Protocol, runtime_checkable
|
|
||||||
|
|
||||||
from thinc.api import Optimizer, Model
|
from thinc.api import Optimizer, Model
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ from typing import Iterator, Pattern, Generator, TYPE_CHECKING
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
import os
|
import os
|
||||||
import importlib
|
import importlib
|
||||||
|
import importlib.metadata
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -40,7 +41,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
from .symbols import ORTH
|
from .symbols import ORTH
|
||||||
from .compat import cupy, CudaStream, is_windows, importlib_metadata
|
from .compat import cupy, CudaStream, is_windows
|
||||||
from .errors import Errors, Warnings
|
from .errors import Errors, Warnings
|
||||||
from . import about
|
from . import about
|
||||||
|
|
||||||
|
@ -706,8 +707,8 @@ def get_package_version(name: str) -> Optional[str]:
|
||||||
RETURNS (str / None): The version or None if package not installed.
|
RETURNS (str / None): The version or None if package not installed.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return importlib_metadata.version(name) # type: ignore[attr-defined]
|
return importlib.metadata.version(name) # type: ignore[attr-defined]
|
||||||
except importlib_metadata.PackageNotFoundError: # type: ignore[attr-defined]
|
except importlib.metadata.PackageNotFoundError: # type: ignore[attr-defined]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -895,7 +896,7 @@ def is_package(name: str) -> bool:
|
||||||
RETURNS (bool): True if installed package, False if not.
|
RETURNS (bool): True if installed package, False if not.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
importlib_metadata.distribution(name) # type: ignore[attr-defined]
|
importlib.metadata.distribution(name) # type: ignore[attr-defined]
|
||||||
return True
|
return True
|
||||||
except: # noqa: E722
|
except: # noqa: E722
|
||||||
return False
|
return False
|
||||||
|
@ -1718,7 +1719,7 @@ def packages_distributions() -> Dict[str, List[str]]:
|
||||||
it's not available in the builtin importlib.metadata.
|
it's not available in the builtin importlib.metadata.
|
||||||
"""
|
"""
|
||||||
pkg_to_dist = defaultdict(list)
|
pkg_to_dist = defaultdict(list)
|
||||||
for dist in importlib_metadata.distributions():
|
for dist in importlib.metadata.distributions():
|
||||||
for pkg in (dist.read_text("top_level.txt") or "").split():
|
for pkg in (dist.read_text("top_level.txt") or "").split():
|
||||||
pkg_to_dist[pkg].append(dist.metadata["Name"])
|
pkg_to_dist[pkg].append(dist.metadata["Name"])
|
||||||
return dict(pkg_to_dist)
|
return dict(pkg_to_dist)
|
||||||
|
|
|
@ -20,7 +20,7 @@ menu:
|
||||||
|
|
||||||
## Installation instructions {id="installation"}
|
## Installation instructions {id="installation"}
|
||||||
|
|
||||||
spaCy is compatible with **64-bit CPython 3.6+** and runs on **Unix/Linux**,
|
spaCy is compatible with **64-bit CPython 3.8+** and runs on **Unix/Linux**,
|
||||||
**macOS/OS X** and **Windows**. The latest spaCy releases are available over
|
**macOS/OS X** and **Windows**. The latest spaCy releases are available over
|
||||||
[pip](https://pypi.python.org/pypi/spacy) and
|
[pip](https://pypi.python.org/pypi/spacy) and
|
||||||
[conda](https://anaconda.org/conda-forge/spacy).
|
[conda](https://anaconda.org/conda-forge/spacy).
|
||||||
|
@ -290,7 +290,7 @@ You can configure the build process with the following environment variables:
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `SPACY_EXTRAS` | Additional Python packages to install alongside spaCy with optional version specifications. Should be a string that can be passed to `pip install`. See [`Makefile`](%%GITHUB_SPACY/Makefile) for defaults. |
|
| `SPACY_EXTRAS` | Additional Python packages to install alongside spaCy with optional version specifications. Should be a string that can be passed to `pip install`. See [`Makefile`](%%GITHUB_SPACY/Makefile) for defaults. |
|
||||||
| `PYVER` | The Python version to build against. This version needs to be available on your build and runtime machines. Defaults to `3.6`. |
|
| `PYVER` | The Python version to build against. This version needs to be available on your build and runtime machines. Defaults to `3.8`. |
|
||||||
| `WHEELHOUSE` | Directory to store the wheel files during compilation. Defaults to `./wheelhouse`. |
|
| `WHEELHOUSE` | Directory to store the wheel files during compilation. Defaults to `./wheelhouse`. |
|
||||||
|
|
||||||
### Run tests {id="run-tests"}
|
### Run tests {id="run-tests"}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user