diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 9acf355c..00000000 --- a/.coveragerc +++ /dev/null @@ -1,5 +0,0 @@ - -[report] -exclude_lines = - pragma: no cover - pragma: ${PY_MAJOR_VERSION} no cover diff --git a/.flake8 b/.flake8 index 7da1f960..e6b17013 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,14 @@ [flake8] max-line-length = 100 +exclude = + .git, + .github, + .pytest_cache, + adhoc, + build, + c-blosc, + dist, + docs, + fixture, + notebooks, + numcodecs.egg-info, diff --git a/.github/workflows/ci-linux.yaml b/.github/workflows/ci-linux.yaml index b3457ff7..4bde7e8f 100644 --- a/.github/workflows/ci-linux.yaml +++ b/.github/workflows/ci-linux.yaml @@ -24,23 +24,16 @@ jobs: - name: Install numcodecs run: | - python -m pip install -U pip -r requirements_test.txt -r requirements.txt - python -m pip install -v -e . + python -m pip install -v -e .[test,msgpack,zfpy] - name: List installed packages run: python -m pip list - - name: Run tests - run: pytest -v --cov=numcodecs --cov-report xml --doctest-modules --doctest-glob=*.pyx numcodecs - - name: Flake8 - run: flake8 numcodecs + run: flake8 - - name: Build Docs - run: | - pip install -r requirements_rtfd.txt - cd docs - sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html + - name: Run tests + run: pytest -v - uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/ci-osx.yaml b/.github/workflows/ci-osx.yaml index f822f9a7..1cd2e81f 100644 --- a/.github/workflows/ci-osx.yaml +++ b/.github/workflows/ci-osx.yaml @@ -37,7 +37,6 @@ jobs: conda create -n env python=${{matrix.python-version}} wheel pip compilers 'clang>=12.0.1' conda activate env which pip - pip install -r requirements_test.txt -r requirements.txt conda env export - name: Show info about `env` environment @@ -50,14 +49,13 @@ jobs: run: | conda activate env export CC=clang - python -m pip install -U pip -r requirements_test.txt -r requirements.txt - python -m pip install -v -e . + python -m pip install -v -e .[test,msgpack,zfpy] - name: Run tests shell: "bash -l {0}" run: | conda activate env - pytest -v --cov=numcodecs --cov-report xml numcodecs + pytest -v - uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/ci-windows.yaml b/.github/workflows/ci-windows.yaml index 56660600..115f72d8 100644 --- a/.github/workflows/ci-windows.yaml +++ b/.github/workflows/ci-windows.yaml @@ -30,7 +30,6 @@ jobs: conda create -n env python=${{matrix.python-version}} wheel pip compilers conda activate env which pip - pip install -r requirements_test.txt -r requirements.txt conda env export - name: Install numcodecs @@ -38,14 +37,13 @@ jobs: run: | conda activate env export CC=clang - python -m pip install -U pip -r requirements_test.txt -r requirements.txt - python -m pip install -v -e . + python -m pip install -v -e .[test,msgpack,zfpy] - name: Run tests shell: "bash -l {0}" run: | conda activate env - pytest -v --cov=numcodecs --cov-report xml numcodecs + pytest -v - uses: codecov/codecov-action@v3 with: diff --git a/.pyup.yml b/.pyup.yml index 625e82c0..30182e6b 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -2,17 +2,3 @@ # see https://pyup.io/docs/configuration/ for all available options schedule: every month - -requirements: - - requirements.txt: - pin: False - update: False - - requirements_test.txt: - pin: False - update: False - - requirements_rtfd.txt: - pin: False - update: False - - requirements_dev.txt: - pin: True - update: all diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b700223a..984ffc46 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -13,6 +13,7 @@ sphinx: python: install: - - requirements: requirements_rtfd.txt - method: pip path: . + extra_requirements: + - docs diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/build.cmd b/build.cmd deleted file mode 100644 index ef92badb..00000000 --- a/build.cmd +++ /dev/null @@ -1,47 +0,0 @@ -:: To build extensions for 64 bit Python 3, we need to configure environment -:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: -:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1) -:: -:: To build extensions for 64 bit Python 2, we need to configure environment -:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of: -:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0) -:: -:: 32 bit builds do not require specific environment configurations. -:: -:: Note: this script needs to be run with the /E:ON and /V:ON flags for the -:: cmd interpreter, at least for (SDK v7.0) -:: -:: More details at: -:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows -:: http://stackoverflow.com/a/13751649/163740 -:: -:: Author: Olivier Grisel -:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ -@ECHO OFF - -SET COMMAND_TO_RUN=%* -SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows - -SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%" -IF %MAJOR_PYTHON_VERSION% == "2" ( - SET WINDOWS_SDK_VERSION="v7.0" -) ELSE IF %MAJOR_PYTHON_VERSION% == "3" ( - SET WINDOWS_SDK_VERSION="v7.1" -) ELSE ( - ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%" - EXIT 1 -) - -IF "%DISTUTILS_USE_SDK%"=="1" ( - ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture - SET DISTUTILS_USE_SDK=1 - SET MSSdk=1 - "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION% - "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release - ECHO Executing: %COMMAND_TO_RUN% - call %COMMAND_TO_RUN% || EXIT 1 -) ELSE ( - ECHO Using default MSVC build environment - ECHO Executing: %COMMAND_TO_RUN% - call %COMMAND_TO_RUN% || EXIT 1 -) diff --git a/docs/contributing.rst b/docs/contributing.rst index 8e71fa10..4d79b477 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -99,16 +99,11 @@ the repository, you can do something like the following:: $ mkdir -p ~/pyenv/numcodecs-dev $ virtualenv --no-site-packages --python=/usr/bin/python3.9 ~/pyenv/numcodecs-dev $ source ~/pyenv/numcodecs-dev/bin/activate - $ pip install -r requirements_dev.txt - $ python setup.py build_ext --inplace + $ pip install -e .[docs,test,msgpack,zfpy] To verify that your development environment is working, you can run the unit tests:: - $ pytest -v numcodecs - -To install numcodecs globally in editable mode run:: - - $ python -m pip install -e . + $ pytest -v Creating a branch ~~~~~~~~~~~~~~~~~ @@ -147,11 +142,7 @@ Running the test suite NumCodecs includes a suite of unit tests, as well as doctests included in function and class docstrings. The simplest way to run the unit tests is to invoke:: - $ pytest -v numcodecs - -To also run the doctests within docstrings, run:: - - $ pytest -v --doctest-modules numcodecs + $ pytest -v NumCodecs currently supports Python 6-3.9, so the above command must succeed before code can be accepted into the main code base. @@ -167,14 +158,14 @@ All code must conform to the PEP8 standard. Regarding line length, lines up to 1 characters are allowed, although please try to keep under 90 wherever possible. Conformance can be checked by running:: - $ flake8 --max-line-length=100 numcodecs + $ flake8 Test coverage ~~~~~~~~~~~~~ NumCodecs maintains 100% test coverage under the latest Python stable release (currently Python 3.9). Both unit tests and docstring doctests are included when computing -coverage. Running ``pytest -v --cov=numcodecs`` will automatically run the test suite with coverage +coverage. Running ``pytest -v`` will automatically run the test suite with coverage and produce a coverage report. This should be 100% before code can be accepted into the main code base. diff --git a/docs/release.rst b/docs/release.rst index 38308fc5..0205433f 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -53,6 +53,9 @@ Maintenance * Add tests for all registry classes. By :user:`Josh Moore `, :issue:`349`. +* Finish ``pyproject.toml`` migration. + By :user:`John Kirkham ` :issue:`382`. + * Drop tox. By :user:`John Kirkham `, :issue:`384`. diff --git a/numcodecs/astype.py b/numcodecs/astype.py index 0c4280e1..2d040df7 100644 --- a/numcodecs/astype.py +++ b/numcodecs/astype.py @@ -28,10 +28,10 @@ class AsType(Codec): >>> x = np.arange(100, 120, 2, dtype=np.int8) >>> x array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118], dtype=int8) - >>> f = numcodecs.AsType(encode_dtype=x.dtype, decode_dtype=np.int64) + >>> f = numcodecs.AsType(encode_dtype=x.dtype, decode_dtype=np.int16) >>> y = f.decode(x) >>> y - array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118]) + array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118], dtype=int16) >>> z = f.encode(y) >>> z array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118], dtype=int8) diff --git a/numcodecs/delta.py b/numcodecs/delta.py index b7bead5e..f43b9b50 100644 --- a/numcodecs/delta.py +++ b/numcodecs/delta.py @@ -28,14 +28,14 @@ class Delta(Codec): -------- >>> import numcodecs >>> import numpy as np - >>> x = np.arange(100, 120, 2, dtype='i8') - >>> codec = numcodecs.Delta(dtype='i8', astype='i1') + >>> x = np.arange(100, 120, 2, dtype='i2') + >>> codec = numcodecs.Delta(dtype='i2', astype='i1') >>> y = codec.encode(x) >>> y array([100, 2, 2, 2, 2, 2, 2, 2, 2, 2], dtype=int8) >>> z = codec.decode(y) >>> z - array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118]) + array([100, 102, 104, 106, 108, 110, 112, 114, 116, 118], dtype=int16) """ diff --git a/numcodecs/vlen.pyx b/numcodecs/vlen.pyx index 7923c3a7..a1ff0e26 100644 --- a/numcodecs/vlen.pyx +++ b/numcodecs/vlen.pyx @@ -310,11 +310,14 @@ class VLenArray(Codec): -------- >>> import numcodecs >>> import numpy as np - >>> x = np.array([[1, 3, 5], [4], [7, 9]], dtype='object') - >>> codec = numcodecs.VLenArray('>> x1 = np.array([1, 3, 5], dtype=np.int16) + >>> x2 = np.array([4], dtype=np.int16) + >>> x3 = np.array([7, 9], dtype=np.int16) + >>> x = np.array([x1, x2, x3], dtype='object') + >>> codec = numcodecs.VLenArray('>> codec.decode(codec.encode(x)) - array([array([1, 3, 5], dtype=int32), array([4], dtype=int32), - array([7, 9], dtype=int32)], dtype=object) + array([array([1, 3, 5], dtype=int16), array([4], dtype=int16), + array([7, 9], dtype=int16)], dtype=object) See Also -------- diff --git a/pyproject.toml b/pyproject.toml index 1a3f73ca..b7c5a621 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,111 @@ [build-system] -requires = ["setuptools>=40.8.0", "setuptools_scm[toml]>=6.2", "Cython", "py-cpuinfo"] -build-backend = "setuptools.build_meta:__legacy__" +requires = [ + "setuptools>=64", + "setuptools-scm[toml]>=6.2", + "Cython", + "py-cpuinfo" +] +build-backend = "setuptools.build_meta" + +[project] +name = "numcodecs" +description = """ +A Python package providing buffer compression and transformation codecs for use +in data storage and communication applications. +""" +readme = "README.rst" +dependencies = [ + "entrypoints", + "numpy>=1.7", + "typing-extensions>=3.7.4" +] +requires-python = ">=3.7" +dynamic = [ + "version", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Topic :: Software Development :: Libraries :: Python Modules", + "Operating System :: Unix", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", +] +maintainers = [ + { name = "Alistair Miles", email = "alimanfoo@googlemail.com" }, +] +license = { text = "MIT" } + +[project.urls] +"Bug Tracker" = "https://github.com/zarr-developers/numcodecs/issues" +Changelog = "https://numcodecs.readthedocs.io/en/stable/release.html" +Documentation = "https://numcodecs.readthedocs.io/" +Homepage = "https://github.com/zarr-developers/numcodecs" + +[project.optional-dependencies] +docs = [ + "sphinx", + "sphinx-issues", + "numpydoc", + "mock", +] +test = [ + "coverage", + "flake8", + "pytest", + "pytest-cov", +] +msgpack = [ + "msgpack", +] +zfpy = [ + "zfpy>=1.0.0", +] + +[tool.setuptools] +license-files = ["LICENSE.txt"] +package-dir = {"" = "."} +packages = ["numcodecs", "numcodecs.tests"] +zip-safe = false + +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "dirty-tag" +write_to = "numcodecs/version.py" [tool.codespell] skip = "./.git,fixture" ignore-words-list = "ba, compiletime, hist, nd, unparseable" + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "pragma: ${PY_MAJOR_VERSION} no cover", +] + +[tool.pytest.ini_options] +addopts = "--cov=numcodecs --cov-report xml --doctest-modules --doctest-glob=*.pyx" +doctest_optionflags = [ + "NORMALIZE_WHITESPACE", + "ELLIPSIS", + "IGNORE_EXCEPTION_DETAIL", +] +testpaths = [ + "numcodecs", +] +norecursedirs = [ + ".git", + ".github", + ".pytest_cache", + "adhoc", + "build", + "c-blosc", + "docs", + "fixture", + "notebooks", + "numcodecs.egg-info", +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 10f311e9..00000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index eb34a7f8..00000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -cython -entrypoints -numpy -msgpack -pytest -zfpy -typing-extensions diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index a44addb4..00000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,7 +0,0 @@ -Cython==0.29.30 -entrypoints==0.4 -msgpack==1.0.2 -numpy==1.22.0 -zfpy==1.0.0 -typing-extensions>=3.7.4 -py-cpuinfo==9.0.0 diff --git a/requirements_rtfd.txt b/requirements_rtfd.txt deleted file mode 100644 index 430add4c..00000000 --- a/requirements_rtfd.txt +++ /dev/null @@ -1,12 +0,0 @@ -setuptools -setuptools_scm -sphinx -sphinx-issues -numpydoc -mock -numpy -cython -entrypoints -zfpy==1.0.0 -typing-extensions -py-cpuinfo==9.0.0 diff --git a/requirements_test.txt b/requirements_test.txt deleted file mode 100644 index 9345f17c..00000000 --- a/requirements_test.txt +++ /dev/null @@ -1,7 +0,0 @@ -coverage -coveralls -flake8 -pytest -pytest-cov -setuptools -setuptools-scm diff --git a/setup.py b/setup.py index ed2c2383..cf950f40 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,11 @@ -from glob import glob import os -from setuptools import setup, Extension -import cpuinfo import sys -from distutils.command.build_ext import build_ext -from distutils.errors import CCompilerError, DistutilsExecError, \ - DistutilsPlatformError -from Cython.Build import cythonize +from glob import glob + +import cpuinfo +from Cython.Distutils.build_ext import new_build_ext as build_ext +from setuptools import Extension, setup +from setuptools.errors import CCompilerError, ExecError, PlatformError # determine CPU support for SSE2 and AVX2 cpu_info = cpuinfo.get_cpu_info() @@ -110,8 +109,6 @@ def blosc_extension(): ), ] - extensions = cythonize(extensions) - return extensions @@ -146,8 +143,6 @@ def zstd_extension(): ), ] - extensions = cythonize(extensions) - return extensions @@ -175,8 +170,6 @@ def lz4_extension(): ), ] - extensions = cythonize(extensions) - return extensions @@ -202,8 +195,6 @@ def vlen_extension(): ), ] - extensions = cythonize(extensions) - return extensions @@ -221,8 +212,6 @@ def compat_extension(): extra_compile_args=extra_compile_args), ] - extensions = cythonize(extensions) - return extensions @@ -240,16 +229,14 @@ def shuffle_extension(): extra_compile_args=extra_compile_args), ] - extensions = cythonize(extensions) - return extensions if sys.platform == 'win32': - ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, + ext_errors = (CCompilerError, ExecError, PlatformError, IOError, ValueError) else: - ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError) + ext_errors = (CCompilerError, ExecError, PlatformError) class BuildFailed(Exception): @@ -262,7 +249,7 @@ class ve_build_ext(build_ext): def run(self): try: build_ext.run(self) - except DistutilsPlatformError as e: + except PlatformError as e: error(e) raise BuildFailed() @@ -274,14 +261,6 @@ def build_extension(self, ext): raise BuildFailed() -DESCRIPTION = ("A Python package providing buffer compression and " - "transformation codecs for use in data storage and " - "communication applications.") - -with open('README.rst') as f: - LONG_DESCRIPTION = f.read() - - def run_setup(with_extensions): if with_extensions: @@ -294,55 +273,8 @@ def run_setup(with_extensions): cmdclass = {} setup( - name='numcodecs', - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - use_scm_version={ - 'version_scheme': 'guess-next-dev', - 'local_scheme': 'dirty-tag', - 'write_to': 'numcodecs/version.py' - }, - setup_requires=[ - 'setuptools>18.0', - 'setuptools-scm>1.5.4', - 'Cython', - ], - install_requires=[ - 'entrypoints', - 'numpy>=1.7', - 'typing-extensions>=3.7.4', - ], - extras_require={ - 'msgpack': ["msgpack"], - }, ext_modules=ext_modules, cmdclass=cmdclass, - package_dir={"": "."}, - python_requires=">=3.7, <4", - packages=["numcodecs", "numcodecs.tests"], - classifiers=[ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Topic :: Software Development :: Libraries :: Python Modules", - "Operating System :: Unix", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], - author='Alistair Miles', - author_email='alimanfoo@googlemail.com', - maintainer='Alistair Miles', - maintainer_email='alimanfoo@googlemail.com', - url='https://github.com/zarr-developers/numcodecs', - license='MIT', - zip_safe=False, )