Merge pull request #11668 from adrianeboyd/chore/v2.3.8

Updates for python 3.10 and 3.11, set version to v2.3.8
This commit is contained in:
Adriane Boyd 2022-10-18 17:18:33 +02:00 committed by GitHub
commit 46234a5221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 90 additions and 142 deletions

View File

@ -7,3 +7,4 @@ include pyproject.toml
recursive-exclude spacy/lang *.json recursive-exclude spacy/lang *.json
recursive-include spacy/lang *.json.gz recursive-include spacy/lang *.json.gz
recursive-include licenses * recursive-include licenses *
recursive-exclude spacy *.cpp

View File

@ -21,7 +21,7 @@ jobs:
# defined in .flake8 and overwrites the selected codes. # defined in .flake8 and overwrites the selected codes.
- job: 'Validate' - job: 'Validate'
pool: pool:
vmImage: 'ubuntu-18.04' vmImage: 'ubuntu-latest'
steps: steps:
- task: UsePythonVersion@0 - task: UsePythonVersion@0
inputs: inputs:
@ -35,50 +35,37 @@ jobs:
dependsOn: 'Validate' dependsOn: 'Validate'
strategy: strategy:
matrix: matrix:
Python35Linux: # Test on one OS per python 3.6/3.7/3.8/3.9 to speed up CI
imageName: 'ubuntu-18.04'
python.version: '3.5'
os: linux
Python35Windows:
imageName: 'vs2017-win2016'
python.version: '3.5'
# Test on one OS per python 3.6/3.7/3.8 to speed up CI
Python36Linux: Python36Linux:
imageName: 'ubuntu-18.04' imageName: 'ubuntu-latest'
python.version: '3.6' python.version: '3.6'
# Python36Windows:
# imageName: 'vs2017-win2016'
# python.version: '3.6'
# Python36Mac:
# imageName: 'macos-10.14'
# python.version: '3.6'
# Python37Linux:
# imageName: 'ubuntu-18.04'
# python.version: '3.7'
Python37Windows: Python37Windows:
imageName: 'vs2017-win2016' imageName: 'windows-latest'
python.version: '3.7' python.version: '3.7'
# Python37Mac:
# imageName: 'macos-10.14'
# python.version: '3.7'
# Python38Linux:
# imageName: 'ubuntu-18.04'
# python.version: '3.8'
# Python38Windows:
# imageName: 'vs2017-win2016'
# python.version: '3.8'
Python38Mac: Python38Mac:
imageName: 'macos-10.14' imageName: 'macos-latest'
python.version: '3.8' python.version: '3.8'
Python39Linux: Python39Linux:
imageName: 'ubuntu-18.04' imageName: 'ubuntu-latest'
python.version: '3.9'
Python39Windows:
imageName: 'vs2017-win2016'
python.version: '3.9'
Python39Mac:
imageName: 'macos-10.14'
python.version: '3.9' python.version: '3.9'
Python310Linux:
imageName: 'ubuntu-latest'
python.version: '3.10'
Python310Windows:
imageName: 'windows-latest'
python.version: '3.10'
Python310Mac:
imageName: 'macos-latest'
python.version: '3.10'
Python311Linux:
imageName: 'ubuntu-latest'
python.version: '3.11.0-rc.2'
Python311Windows:
imageName: 'windows-latest'
python.version: '3.11.0-rc.2'
Python311Mac:
imageName: 'macos-latest'
python.version: '3.11.0-rc.2'
maxParallel: 4 maxParallel: 4
pool: pool:
vmImage: $(imageName) vmImage: $(imageName)
@ -88,17 +75,13 @@ jobs:
inputs: inputs:
versionSpec: '$(python.version)' versionSpec: '$(python.version)'
architecture: 'x64' architecture: 'x64'
allowUnstable: true
- script: python -m pip install -U pip setuptools - script: python -m pip install -U pip setuptools
displayName: 'Update pip' displayName: 'Update pip'
- script: pip install -r requirements.txt --prefer-binary
displayName: 'Install dependencies (python 3.5: prefer binary)'
condition: eq(variables['python.version'], '3.5')
- script: pip install -r requirements.txt - script: pip install -r requirements.txt
displayName: 'Install dependencies' displayName: 'Install dependencies'
condition: not(eq(variables['python.version'], '3.5'))
- script: | - script: |
python setup.py build_ext --inplace -j 2 python setup.py build_ext --inplace -j 2
@ -115,20 +98,13 @@ jobs:
pip uninstall -y -r installed.txt pip uninstall -y -r installed.txt
displayName: 'Uninstall all packages' displayName: 'Uninstall all packages'
- bash: |
SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1)
pip install dist/$SDIST --prefer-binary
displayName: 'Install from sdist (python 3.5: prefer binary)'
condition: eq(variables['python.version'], '3.5')
- bash: | - bash: |
SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1) SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1)
pip install dist/$SDIST pip install dist/$SDIST
displayName: 'Install from sdist' displayName: 'Install from sdist'
condition: not(eq(variables['python.version'], '3.5'))
- script: | - script: |
pip install -r requirements.txt --prefer-binary pip install -r requirements.txt
python -m pytest --pyargs spacy python -m pytest --pyargs spacy
displayName: 'Run tests' displayName: 'Run tests'
@ -136,4 +112,4 @@ jobs:
python -m spacy download en_core_web_sm python -m spacy download en_core_web_sm
python -c "import spacy; nlp=spacy.load('en_core_web_sm'); doc=nlp('test')" python -c "import spacy; nlp=spacy.load('en_core_web_sm'); doc=nlp('test')"
displayName: 'Test download CLI' displayName: 'Test download CLI'
condition: and(eq(variables['python.version'], '3.9'), eq(variables['imageName'], 'ubuntu-18.04')) condition: eq(variables['python.version'], '3.9')

View File

@ -1,5 +1,9 @@
# build version constraints for use with wheelwright + multibuild # build version constraints for use with wheelwright + multibuild
numpy==1.15.0; python_version<='3.7' numpy==1.15.0; python_version<='3.7' and platform_machine!='aarch64'
numpy==1.17.3; python_version=='3.8' numpy==1.19.2; python_version<='3.7' and platform_machine=='aarch64'
numpy==1.17.3; python_version=='3.8' and platform_machine!='aarch64'
numpy==1.19.2; python_version=='3.8' and platform_machine=='aarch64'
numpy==1.19.3; python_version=='3.9' numpy==1.19.3; python_version=='3.9'
numpy; python_version>='3.10' numpy==1.21.3; python_version=='3.10'
numpy==1.23.2; python_version=='3.11'
numpy; python_version>='3.12'

View File

@ -1,7 +1,7 @@
[build-system] [build-system]
requires = [ requires = [
"setuptools", "setuptools",
"cython>=0.25", "cython>=0.25,<3.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",
"murmurhash>=0.28.0,<1.1.0", "murmurhash>=0.28.0,<1.1.0",

View File

@ -17,8 +17,8 @@ tqdm>=4.38.0,<5.0.0
pyrsistent<0.17.0 pyrsistent<0.17.0
jsonschema>=2.6.0,<3.1.0 jsonschema>=2.6.0,<3.1.0
# Development dependencies # Development dependencies
cython>=0.25 cython>=0.25,<3.0
pytest>=4.6.5 pytest>=4.6.5
pytest-timeout>=1.3.0,<2.0.0 pytest-timeout>=1.3.0,<2.0.0
mock>=2.0.0,<3.0.0 mock>=2.0.0,<3.0.0
flake8>=3.5.0,<3.6.0 flake8>=3.5.0,<6.0.0

View File

@ -24,6 +24,8 @@ classifiers =
Programming Language :: Python :: 3.7 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.11
Topic :: Scientific/Engineering Topic :: Scientific/Engineering
[options] [options]
@ -33,7 +35,7 @@ scripts =
bin/spacy bin/spacy
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.* python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
setup_requires = setup_requires =
cython>=0.25 cython>=0.25,<3.0
numpy>=1.15.0 numpy>=1.15.0
# We also need our Cython packages here to compile against # We also need our Cython packages here to compile against
cymem>=2.0.2,<2.1.0 cymem>=2.0.2,<2.1.0

131
setup.py
View File

@ -1,16 +1,17 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function from __future__ import print_function
import io
import os import os
import subprocess import subprocess
import sys import sys
import contextlib
import numpy import numpy
from pathlib import Path
from distutils.command.build_ext import build_ext from distutils.command.build_ext import build_ext
from distutils.sysconfig import get_python_inc from distutils.sysconfig import get_python_inc
import distutils.util import distutils.util
from distutils import ccompiler, msvccompiler from distutils import ccompiler, msvccompiler
from setuptools import Extension, setup, find_packages from setuptools import Extension, setup, find_packages
from Cython.Build import cythonize
from Cython.Compiler import Options
def is_new_osx(): def is_new_osx():
@ -28,6 +29,10 @@ def is_new_osx():
return False return False
# Preserve `__doc__` on functions and classes
# http://docs.cython.org/en/latest/src/userguide/source_files_and_compilation.html#compiler-options
Options.docstrings = True
PACKAGES = find_packages() PACKAGES = find_packages()
@ -74,6 +79,12 @@ COMPILE_OPTIONS = {
LINK_OPTIONS = {"msvc": [], "mingw32": [], "other": []} LINK_OPTIONS = {"msvc": [], "mingw32": [], "other": []}
COMPILER_DIRECTIVES = {
"language_level": -3,
"embedsignature": True,
"annotation_typing": False,
}
if is_new_osx(): if is_new_osx():
# On Mac, use libc++ because Apple deprecated use of # On Mac, use libc++ because Apple deprecated use of
@ -105,20 +116,6 @@ class build_ext_subclass(build_ext, build_ext_options):
build_ext.build_extensions(self) build_ext.build_extensions(self)
def generate_cython(root, source):
print("Cythonizing sources")
p = subprocess.call(
[sys.executable, os.path.join(root, "bin", "cythonize.py"), source],
env=os.environ,
)
if p != 0:
raise RuntimeError("Running cythonize failed")
def is_source_release(path):
return os.path.exists(os.path.join(path, "PKG-INFO"))
# Include the git version in the build (adapted from NumPy) # Include the git version in the build (adapted from NumPy)
# Copyright (c) 2005-2020, NumPy Developers. # Copyright (c) 2005-2020, NumPy Developers.
# BSD 3-Clause license, see licenses/3rd_party_licenses.txt # BSD 3-Clause license, see licenses/3rd_party_licenses.txt
@ -169,83 +166,51 @@ GIT_VERSION = "%(git_version)s"
def clean(path): def clean(path):
for name in MOD_NAMES: for path in path.glob("**/*"):
name = name.replace(".", "/") if path.is_file() and path.suffix in (".so", ".cpp"):
for ext in [".so", ".html", ".cpp", ".c"]: print(f"Deleting {path.name}")
file_path = os.path.join(path, name + ext) path.unlink()
if os.path.exists(file_path):
os.unlink(file_path)
@contextlib.contextmanager
def chdir(new_dir):
old_dir = os.getcwd()
try:
os.chdir(new_dir)
sys.path.insert(0, new_dir)
yield
finally:
del sys.path[0]
os.chdir(old_dir)
def setup_package(): def setup_package():
write_git_info_py() write_git_info_py()
root = os.path.abspath(os.path.dirname(__file__)) root = Path(__file__).parent
if hasattr(sys, "argv") and len(sys.argv) > 1 and sys.argv[1] == "clean": if hasattr(sys, "argv") and len(sys.argv) > 1 and sys.argv[1] == "clean":
return clean(root) return clean(root / "spacy")
with chdir(root): with (root / "spacy" / "about.py").open("r") as f:
with io.open(os.path.join(root, "spacy", "about.py"), encoding="utf8") as f: about = {}
about = {} exec(f.read(), about)
exec(f.read(), about)
include_dirs = [ include_dirs = [
numpy.get_include(), get_python_inc(plat_specific=True),
get_python_inc(plat_specific=True), numpy.get_include(),
os.path.join(root, "include"), str(root / "include"),
] ]
if (
ccompiler.new_compiler().compiler_type == "msvc"
and msvccompiler.get_build_version() == 9
):
include_dirs.append(str(root / "include" / "msvc9"))
ext_modules = []
for name in MOD_NAMES:
mod_path = name.replace(".", "/") + ".pyx"
ext = Extension(name, [mod_path], language="c++")
ext_modules.append(ext)
print("Cythonizing sources")
ext_modules = cythonize(ext_modules, compiler_directives=COMPILER_DIRECTIVES)
if ( setup(
ccompiler.new_compiler().compiler_type == "msvc" name="spacy",
and msvccompiler.get_build_version() == 9 packages=PACKAGES,
): version=about["__version__"],
include_dirs.append(os.path.join(root, "include", "msvc9")) ext_modules=ext_modules,
cmdclass={"build_ext": build_ext_subclass},
ext_modules = [] include_dirs=include_dirs,
for mod_name in MOD_NAMES: package_data={"": ["*.pyx", "*.pxd", "*.pxi", "*.cpp"]},
mod_path = mod_name.replace(".", "/") + ".cpp" )
extra_link_args = []
# ???
# Imported from patch from @mikepb
# See Issue #267. Running blind here...
if sys.platform == "darwin":
dylib_path = [".." for _ in range(mod_name.count("."))]
dylib_path = "/".join(dylib_path)
dylib_path = "@loader_path/%s/spacy/platform/darwin/lib" % dylib_path
extra_link_args.append("-Wl,-rpath,%s" % dylib_path)
ext_modules.append(
Extension(
mod_name,
[mod_path],
language="c++",
include_dirs=include_dirs,
extra_link_args=extra_link_args,
)
)
if not is_source_release(root):
generate_cython(root, "spacy")
setup(
name="spacy",
packages=PACKAGES,
version=about["__version__"],
ext_modules=ext_modules,
cmdclass={"build_ext": build_ext_subclass},
)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -1,6 +1,6 @@
# fmt: off # fmt: off
__title__ = "spacy" __title__ = "spacy"
__version__ = "2.3.7" __version__ = "2.3.8"
__release__ = True __release__ = True
__download_url__ = "https://github.com/explosion/spacy-models/releases/download" __download_url__ = "https://github.com/explosion/spacy-models/releases/download"
__compatibility__ = "https://raw.githubusercontent.com/explosion/spacy-models/master/compatibility.json" __compatibility__ = "https://raw.githubusercontent.com/explosion/spacy-models/master/compatibility.json"