Skip to content

Commit 4362bb4

Browse files
Saransh-cppjakirkhamjoshmoore
authored
Migrate to pyproject.toml + cleanup (#1158)
* Migrate to pyproject.toml + cleanup * Remove more instances of python setup.py ... * release.rst entry * Move changes to unreleased section * Remove pre-commit checks from workflows * Update `jupyter` dependencies Co-authored-by: jakirkham <[email protected]> * Lower pin setuptools * Document installing `build` Co-authored-by: jakirkham <[email protected]> * Add docs for twine and pre-commit * Add pre-commit badge to readme. * add .readthedocs.yaml Co-authored-by: jakirkham <[email protected]> Co-authored-by: Josh Moore <[email protected]>
1 parent 2c52b17 commit 4362bb4

17 files changed

+161
-125
lines changed
File renamed without changes.

.github/workflows/Pre-commit-hooks.yml

-34
This file was deleted.

.github/workflows/python-package.yml

-6
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,3 @@ jobs:
8383
#name: codecov-umbrella # optional
8484
#fail_ci_if_error: true # optional (default = false)
8585
verbose: true # optional (default = false)
86-
- name: Linting
87-
shell: "bash -l {0}"
88-
run: |
89-
conda activate zarr-env
90-
flake8 zarr
91-
mypy zarr

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ zarr/version.py
6767
# emacs
6868
*~
6969

70+
# VSCode
71+
.vscode/
72+
7073
# test data
7174
#*.zarr
7275
#*.zip

.pre-commit-config.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
ci:
2+
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autofix_commit_msg: "style: pre-commit fixes"
14
default_stages: [commit, push]
25
default_language_version:
36
python: python3.9
@@ -11,7 +14,21 @@ repos:
1114
]
1215
exclude: ^(venv/|docs/)
1316
types: ['python']
17+
- repo: https://github.com/codespell-project/codespell
18+
rev: v2.1.0
19+
hooks:
20+
- id: codespell
21+
args: ["-L", "ba,ihs,kake,nd,noe,nwo,te"]
1422
- repo: https://github.com/pre-commit/pre-commit-hooks
1523
rev: v2.3.0
1624
hooks:
1725
- id: check-yaml
26+
- repo: https://github.com/pre-commit/mirrors-mypy
27+
rev: v0.981
28+
hooks:
29+
- id: mypy
30+
files: zarr
31+
args: []
32+
additional_dependencies:
33+
- types-redis
34+
- types-setuptools

.readthedocs.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-20.04
5+
tools:
6+
python: "3.9"
7+
8+
sphinx:
9+
configuration: docs/conf.py
10+
11+
python:
12+
install:
13+
- requirements: requirements_rtfd.txt
14+
- method: pip
15+
path: .

MANIFEST.in

Whitespace-only changes.

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@
4040
<td>Build Status</td>
4141
<td>
4242
<a href="https://github.com/zarr-developers/zarr-python/blob/main/.github/workflows/python-package.yml">
43-
<img src="https://github.com/zarr-developers/zarr-python/actions/workflows/python-package.yml/badge.svg" alt="license" />
43+
<img src="https://github.com/zarr-developers/zarr-python/actions/workflows/python-package.yml/badge.svg" alt="build status" />
4444
</a>
4545
</td>
4646
</tr>
47+
<tr>
48+
<td>Pre-commit Status</td>
49+
<td>
50+
<a href=""https://github.com/zarr-developers/zarr-python/blob/main/.pre-commit-config.yaml">
51+
<img src="https://results.pre-commit.ci/badge/github/zarr-developers/zarr-python/main.svg" alt="pre-commit status" />
52+
</a>
53+
</td>
54+
</tr>
55+
4756
<tr>
4857
<td>Coverage</td>
4958
<td>

docs/contributing.rst

+23-4
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,33 @@ also collected automatically via the Codecov service, and total
179179
coverage over all builds must be 100% (although individual builds
180180
may be lower due to Python 2/3 or other differences).
181181

182-
Code standards
183-
~~~~~~~~~~~~~~
182+
Code standards - using pre-commit
183+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
184184

185185
All code must conform to the PEP8 standard. Regarding line length, lines up to 100
186186
characters are allowed, although please try to keep under 90 wherever possible.
187-
Conformance can be checked by running::
188187

189-
$ python -m flake8 --max-line-length=100 zarr
188+
``Zarr`` uses a set of ``pre-commit`` hooks and the ``pre-commit`` bot to format,
189+
type-check, and prettify the codebase. ``pre-commit`` can be installed locally by
190+
running::
191+
192+
$ python -m pip install pre-commit
193+
194+
The hooks can be installed locally by running::
195+
196+
$ pre-commit install
197+
198+
This would run the checks every time a commit is created locally. These checks will also run
199+
on every commit pushed to an open PR, resulting in some automatic styling fixes by the
200+
``pre-commit`` bot. The checks will by default only run on the files modified by a commit,
201+
but the checks can be triggered for all the files by running::
202+
203+
$ pre-commit run --all-files
204+
205+
If you would like to skip the failing checks and push the code for further discussion, use
206+
the ``--no-verify`` option with ``git commit``.
207+
208+
190209

191210
Test coverage
192211
~~~~~~~~~~~~~

docs/installation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To work with Zarr source code in development, install from GitHub::
2323

2424
$ git clone --recursive https://github.com/zarr-developers/zarr-python.git
2525
$ cd zarr-python
26-
$ python setup.py install
26+
$ python -m pip install -e .
2727

2828
To verify that Zarr has been fully installed, run the test suite::
2929

docs/release.rst

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ Release notes
66
# to document your changes. On releases it will be
77
# re-indented so that it does not show up in the notes.
88
9-
.. _unreleased:
9+
.. _unreleased:
1010

11-
Unreleased
12-
----------
11+
Unreleased
12+
----------
1313
..
1414
# .. warning::
1515
# Pre-release! Use :command:`pip install --pre zarr` to evaluate this release.
1616
17+
Maintenance
18+
~~~~~~~~~~~
19+
20+
* Migrate to ``pyproject.toml`` and remove redundant infrastructure.
21+
By :user:`Saransh Chopra <Saransh-cpp>` :issue:`1158`.
22+
1723
.. _release_2.13.3:
1824

1925
2.13.3

mypy.ini

-4
This file was deleted.

pyproject.toml

+78-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
11
[build-system]
2-
requires = ["setuptools>=40.8.0", "wheel"]
2+
requires = ["setuptools>=40.8.0", "setuptools-scm", "wheel"]
33
build-backend = "setuptools.build_meta"
4+
5+
6+
[project]
7+
name = "zarr"
8+
description = "An implementation of chunked, compressed, N-dimensional arrays for Python"
9+
readme = { file = "README.md", content-type = "text/markdown" }
10+
maintainers = [
11+
{ name = "Alistair Miles", email = "[email protected]" }
12+
]
13+
requires-python = ">=3.8"
14+
dependencies = [
15+
'asciitree',
16+
'numpy>=1.7',
17+
'fasteners',
18+
'numcodecs>=0.10.0',
19+
]
20+
dynamic = [
21+
"version",
22+
]
23+
classifiers = [
24+
'Development Status :: 6 - Mature',
25+
'Intended Audience :: Developers',
26+
'Intended Audience :: Information Technology',
27+
'Intended Audience :: Science/Research',
28+
'License :: OSI Approved :: MIT License',
29+
'Programming Language :: Python',
30+
'Topic :: Software Development :: Libraries :: Python Modules',
31+
'Operating System :: Unix',
32+
'Programming Language :: Python :: 3',
33+
'Programming Language :: Python :: 3.8',
34+
'Programming Language :: Python :: 3.9',
35+
'Programming Language :: Python :: 3.10',
36+
]
37+
38+
[project.optional-dependencies]
39+
jupyter = [
40+
'notebook',
41+
'ipytree>=0.2.2',
42+
'ipywidgets>=8.0.0',
43+
]
44+
45+
[project.urls]
46+
"Bug Tracker" = "https://github.com/zarr-developers/zarr-python/issues"
47+
Changelog = "https://zarr.readthedocs.io/en/stable/release.html"
48+
Discussions = "https://github.com/zarr-developers/zarr-python/discussions"
49+
Documentation = "https://zarr.readthedocs.io/"
50+
Homepage = "https://github.com/zarr-developers/zarr-python"
51+
52+
53+
[tool.setuptools]
54+
packages = ["zarr", "zarr._storage", "zarr.tests"]
55+
56+
[tool.setuptools_scm]
57+
version_scheme = "guess-next-dev"
58+
local_scheme = "dirty-tag"
59+
write_to = "zarr/version.py"
60+
61+
[tool.mypy]
62+
python_version = "3.8"
63+
ignore_missing_imports = true
64+
follow_imports = "silent"
65+
66+
[tool.pytest.ini_options]
67+
doctest_optionflags = [
68+
"NORMALIZE_WHITESPACE",
69+
"ELLIPSIS",
70+
"IGNORE_EXCEPTION_DETAIL",
71+
]
72+
addopts = [
73+
"--durations=10",
74+
]
75+
filterwarnings = [
76+
"error:::zarr.*",
77+
"ignore:Not all N5 implementations support blosc compression.*:RuntimeWarning",
78+
"ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning",
79+
"ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning",
80+
]

pytest.ini

-8
This file was deleted.

release.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ tox
33
echo $version
44
git tag -a v$version -m v$version
55
git push --tags
6-
python setup.py register sdist
6+
# Install `build` if not present with `python -m pip install build` or similar
7+
# for building Zarr
8+
python -m build
9+
# Install `twine` if not present with `python -m pip install twine` or similar
10+
# for publishing Zarr to PyPI
711
twine upload dist/zarr-${version}.tar.gz

setup.cfg

-3
This file was deleted.

setup.py

-59
This file was deleted.

0 commit comments

Comments
 (0)