From af1b79a4af14a612d1ef1fb5596847a184fcd22a Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 7 Oct 2022 23:00:32 +0530 Subject: [PATCH 01/11] Migrate to pyproject.toml + cleanup --- codecov.yml => .github/codecov.yml | 0 .github/workflows/python-package.yml | 6 --- .pre-commit-config.yaml | 17 +++++++ MANIFEST.in | 0 docs/installation.rst | 2 +- mypy.ini | 4 -- pyproject.toml | 76 +++++++++++++++++++++++++++- pytest.ini | 8 --- setup.cfg | 3 -- setup.py | 59 --------------------- 10 files changed, 93 insertions(+), 82 deletions(-) rename codecov.yml => .github/codecov.yml (100%) delete mode 100644 MANIFEST.in delete mode 100644 mypy.ini delete mode 100644 pytest.ini delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/codecov.yml b/.github/codecov.yml similarity index 100% rename from codecov.yml rename to .github/codecov.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 2eeede91fe..9abb7c7866 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -83,9 +83,3 @@ jobs: #name: codecov-umbrella # optional #fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) - - name: Linting - shell: "bash -l {0}" - run: | - conda activate zarr-env - flake8 zarr - mypy zarr diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70ead97d0b..d62b10aa40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,6 @@ +ci: + autoupdate_commit_msg: "chore: update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" default_stages: [commit, push] default_language_version: python: python3.9 @@ -11,7 +14,21 @@ repos: ] exclude: ^(venv/|docs/) types: ['python'] + - repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + args: ["-L", "ba,ihs,kake,nd,noe,nwo,te"] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.3.0 hooks: - id: check-yaml + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.981 + hooks: + - id: mypy + files: zarr + args: [] + additional_dependencies: + - types-redis + - types-setuptools diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/installation.rst b/docs/installation.rst index 047dbe2bd2..a07c1c42e1 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -23,7 +23,7 @@ To work with Zarr source code in development, install from GitHub:: $ git clone --recursive https://github.com/zarr-developers/zarr-python.git $ cd zarr-python - $ python setup.py install + $ python -m pip install -e . To verify that Zarr has been fully installed, run the test suite:: diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 7c1be49cd6..0000000000 --- a/mypy.ini +++ /dev/null @@ -1,4 +0,0 @@ -[mypy] -python_version = 3.8 -ignore_missing_imports = True -follow_imports = silent diff --git a/pyproject.toml b/pyproject.toml index 2f21011953..097672a6c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,77 @@ [build-system] -requires = ["setuptools>=40.8.0", "wheel"] +requires = ["setuptools", "setuptools-scm", "wheel"] build-backend = "setuptools.build_meta" + + +[project] +name = "zarr" +description = "An implementation of chunked, compressed, N-dimensional arrays for Python" +readme = { file = "README.md", content-type = "text/markdown" } +maintainers = [ {name = "Alistair Miles", email = "alimanfoo@googlemail.com"} ] +requires-python = ">=3.8" +dependencies = [ + 'asciitree', + 'numpy>=1.7', + 'fasteners', + 'numcodecs>=0.10.0', +] +dynamic = [ + "version", +] +classifiers = [ + 'Development Status :: 6 - Mature', + '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.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', +] + +[project.optional-dependencies] +jupyter = [ + 'notebook', + 'ipytree', +] + +[project.urls] +"Bug Tracker" = "https://github.com/zarr-developers/zarr-python/issues" +Changelog = "https://zarr.readthedocs.io/en/stable/release.html" +Discussions = "https://github.com/zarr-developers/zarr-python/discussions" +Documentation = "https://zarr.readthedocs.io/" +Homepage = "https://github.com/zarr-developers/zarr-python" + + +[tool.setuptools] +packages = ["zarr", "zarr._storage", "zarr.tests"] + +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "dirty-tag" +write_to = "zarr/version.py" + +[tool.mypy] +python_version = "3.8" +ignore_missing_imports = true +follow_imports = "silent" + +[tool.pytest.ini_options] +doctest_optionflags = [ + "NORMALIZE_WHITESPACE", + "ELLIPSIS", + "IGNORE_EXCEPTION_DETAIL", +] +addopts = [ + "--durations=10", +] +filterwarnings = [ + "error:::zarr.*", + "ignore:Not all N5 implementations support blosc compression.*:RuntimeWarning", + "ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning", + "ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning", +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 966b5ad931..0000000000 --- a/pytest.ini +++ /dev/null @@ -1,8 +0,0 @@ -[pytest] -doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL -addopts = --durations=10 -filterwarnings = - error:::zarr.* - ignore:Not all N5 implementations support blosc compression.*:RuntimeWarning - ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning - ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 28e25ed827..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[codespell] -skip = ./.git -ignore-words-list = ba, ihs, kake, nd, noe, nwo, te diff --git a/setup.py b/setup.py deleted file mode 100644 index 9f005ecd39..0000000000 --- a/setup.py +++ /dev/null @@ -1,59 +0,0 @@ -from setuptools import setup - -DESCRIPTION = 'An implementation of chunked, compressed, ' \ - 'N-dimensional arrays for Python.' - -with open('README.md') as f: - LONG_DESCRIPTION = f.read() - -dependencies = [ - 'asciitree', - 'numpy>=1.7', - 'fasteners', - 'numcodecs>=0.10.0', -] - -setup( - name='zarr', - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - long_description_content_type='text/markdown', - use_scm_version={ - 'version_scheme': 'guess-next-dev', - 'local_scheme': 'dirty-tag', - 'write_to': 'zarr/version.py', - }, - setup_requires=[ - 'setuptools>=38.6.0', - 'setuptools-scm>1.5.4', - ], - extras_require={ - 'jupyter': [ - 'notebook', - 'ipytree>=0.2.2', - 'ipywidgets>=8.0.0', - ], - }, - python_requires='>=3.8, <4', - install_requires=dependencies, - package_dir={'': '.'}, - packages=['zarr', 'zarr._storage', 'zarr.tests'], - classifiers=[ - 'Development Status :: 6 - Mature', - '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.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - ], - maintainer='Alistair Miles', - maintainer_email='alimanfoo@googlemail.com', - url='https://github.com/zarr-developers/zarr-python', - license='MIT', -) From c1f488d247d6f051c4634c756ed6970b3e22a1cf Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 7 Oct 2022 23:30:53 +0530 Subject: [PATCH 02/11] Remove more instances of python setup.py ... --- release.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release.txt b/release.txt index 4d7f099019..39c7b3eff7 100644 --- a/release.txt +++ b/release.txt @@ -3,5 +3,6 @@ tox echo $version git tag -a v$version -m v$version git push --tags -python setup.py register sdist +python -m pip install build +python -m build twine upload dist/zarr-${version}.tar.gz From be962cc8a0b47d5c0fe242d89b799bc43d39903c Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Sat, 8 Oct 2022 00:08:21 +0530 Subject: [PATCH 03/11] release.rst entry --- docs/release.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/release.rst b/docs/release.rst index b511c6a1b4..87c89fa11c 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -23,6 +23,12 @@ Release notes data. By :user:`Richard Shaw ` :issue:`843`. +Maintenance +~~~~~~~~~~~ + +* Migrate to ``pyproject.toml`` and remove redundant infrastructure. + By :user:`Saransh Chopra ` :issue:`1158`. + .. _release_2.13.2: 2.13.2 From 12a4fd93d9ca9ba699772ecd25e6745d04043088 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 10 Oct 2022 20:16:48 +0530 Subject: [PATCH 04/11] Move changes to unreleased section --- docs/release.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/release.rst b/docs/release.rst index 87c89fa11c..ea746999e1 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -6,14 +6,20 @@ Release notes # to document your changes. On releases it will be # re-indented so that it does not show up in the notes. - .. _unreleased: +.. _unreleased: - Unreleased - ---------- +Unreleased +---------- .. # .. warning:: # Pre-release! Use :command:`pip install --pre zarr` to evaluate this release. +Maintenance +~~~~~~~~~~~ + +* Migrate to ``pyproject.toml`` and remove redundant infrastructure. + By :user:`Saransh Chopra ` :issue:`1158`. + .. _release_2.13.3: 2.13.3 @@ -23,12 +29,6 @@ Release notes data. By :user:`Richard Shaw ` :issue:`843`. -Maintenance -~~~~~~~~~~~ - -* Migrate to ``pyproject.toml`` and remove redundant infrastructure. - By :user:`Saransh Chopra ` :issue:`1158`. - .. _release_2.13.2: 2.13.2 From 739775ca9d11b57a54cff6916104f8f6c7f139f2 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Tue, 11 Oct 2022 20:01:08 +0530 Subject: [PATCH 05/11] Remove pre-commit checks from workflows --- .github/workflows/Pre-commit-hooks.yml | 34 -------------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/Pre-commit-hooks.yml diff --git a/.github/workflows/Pre-commit-hooks.yml b/.github/workflows/Pre-commit-hooks.yml deleted file mode 100644 index e219b75e69..0000000000 --- a/.github/workflows/Pre-commit-hooks.yml +++ /dev/null @@ -1,34 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: pre-commit - -# Controls when the workflow will run -on: - # Triggers the workflow pull request events but only for the main branch - pull_request: - push: - branches: [main] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # Using Ubuntu image with latest tag - pre-commit: - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - uses: actions/checkout@v3 - #setting up Python v3.0.0 - - uses: actions/setup-python@v4.2.0 - with: - python-version: '3.9' - #using pre-commit latest i.e v2.0.3 - - uses: pre-commit/action@v3.0.0 - #Running pre-commit for all files - - name: Pre-Commit-Run - run: | - pip install pre-commit - pre-commit run --all-files From aa85bcb4bad3c78ed03e8e331087bb0794289832 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 12 Oct 2022 19:34:24 +0530 Subject: [PATCH 06/11] Update `jupyter` dependencies Co-authored-by: jakirkham --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 097672a6c0..82bf803063 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,8 @@ classifiers = [ [project.optional-dependencies] jupyter = [ 'notebook', - 'ipytree', + 'ipytree>=0.2.2', + 'ipywidgets>=8.0.0', ] [project.urls] From 0664212270ff670b5872df704ee457f9e155b86d Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 12 Oct 2022 19:46:55 +0530 Subject: [PATCH 07/11] Lower pin setuptools --- pyproject.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 82bf803063..8da5e6b994 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools", "setuptools-scm", "wheel"] +requires = ["setuptools>=40.8.0", "setuptools-scm", "wheel"] build-backend = "setuptools.build_meta" @@ -7,7 +7,9 @@ build-backend = "setuptools.build_meta" name = "zarr" description = "An implementation of chunked, compressed, N-dimensional arrays for Python" readme = { file = "README.md", content-type = "text/markdown" } -maintainers = [ {name = "Alistair Miles", email = "alimanfoo@googlemail.com"} ] +maintainers = [ + { name = "Alistair Miles", email = "alimanfoo@googlemail.com" } +] requires-python = ">=3.8" dependencies = [ 'asciitree', From 1347ce5b1c8a5414cde5cefdfc3b84e2c368895d Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Sat, 15 Oct 2022 15:40:47 +0530 Subject: [PATCH 08/11] Document installing `build` Co-authored-by: jakirkham --- release.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.txt b/release.txt index 39c7b3eff7..e649c4ed4e 100644 --- a/release.txt +++ b/release.txt @@ -3,6 +3,6 @@ tox echo $version git tag -a v$version -m v$version git push --tags -python -m pip install build +# Install `build` if not present with `python -m pip install build` or similar python -m build twine upload dist/zarr-${version}.tar.gz From 056a1947f48744f52fb579a74b96efea50f2f4c7 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Sat, 15 Oct 2022 17:45:55 +0530 Subject: [PATCH 09/11] Add docs for twine and pre-commit --- .gitignore | 3 +++ docs/contributing.rst | 27 +++++++++++++++++++++++---- release.txt | 3 +++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f2f7edc348..535cf2b169 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,9 @@ zarr/version.py # emacs *~ +# VSCode +.vscode/ + # test data #*.zarr #*.zip diff --git a/docs/contributing.rst b/docs/contributing.rst index cfb24b50af..64e61abacb 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -179,14 +179,33 @@ also collected automatically via the Codecov service, and total coverage over all builds must be 100% (although individual builds may be lower due to Python 2/3 or other differences). -Code standards -~~~~~~~~~~~~~~ +Code standards - using pre-commit +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All code must conform to the PEP8 standard. Regarding line length, lines up to 100 characters are allowed, although please try to keep under 90 wherever possible. -Conformance can be checked by running:: - $ python -m flake8 --max-line-length=100 zarr +``Zarr`` uses a set of ``pre-commit`` hooks and the ``pre-commit`` bot to format, +type-check, and prettify the codebase. ``pre-commit`` can be installed locally by +running:: + + $ python -m pip install pre-commit + +The hooks can be installed locally by running:: + + $ pre-commit install + +This would run the checks every time a commit is created locally. These checks will also run +on every commit pushed to an open PR, resulting in some automatic styling fixes by the +``pre-commit`` bot. The checks will by default only run on the files modified by a commit, +but the checks can be triggered for all the files by running:: + + $ pre-commit run --all-files + +If you would like to skip the failing checks and push the code for further discussion, use +the ``--no-verify`` option with ``git commit``. + + Test coverage ~~~~~~~~~~~~~ diff --git a/release.txt b/release.txt index e649c4ed4e..ff114f6dba 100644 --- a/release.txt +++ b/release.txt @@ -4,5 +4,8 @@ echo $version git tag -a v$version -m v$version git push --tags # Install `build` if not present with `python -m pip install build` or similar +# for building Zarr python -m build +# Install `twine` if not present with `python -m pip install twine` or similar +# for publishing Zarr to PyPI twine upload dist/zarr-${version}.tar.gz From 0a394ac238a73f273c2306d7496aa2eaed385219 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Sat, 15 Oct 2022 19:03:38 +0200 Subject: [PATCH 10/11] Add pre-commit badge to readme. --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba393e6141..3576d0c30e 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,19 @@ Build Status - license + build status + + Pre-commit Status + + + pre-commit status + + + + Coverage From 45cd3dcc4261abc9d534251a517b7a8f71401a85 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Sat, 15 Oct 2022 19:19:55 +0200 Subject: [PATCH 11/11] add .readthedocs.yaml --- .readthedocs.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000000..42fc08bca2 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,15 @@ +version: 2 + +build: + os: ubuntu-20.04 + tools: + python: "3.9" + +sphinx: + configuration: docs/conf.py + +python: + install: + - requirements: requirements_rtfd.txt + - method: pip + path: .