Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 52e9e37

Browse files
Modernize (#151)
* Move metadata from setup.py to pyproject.toml * Extract package version dynamically from nrrd.__version__ * Upgrade pre-commit hooks * Replace flake8 hook by https://github.com/PyCQA/flake8, which is "standard" (running the old hook was asking me for a gitlab password) * Add typos hook (only found one typo, but doesn't cost much to run it) --------- Co-authored-by: Bryn Lloyd <[email protected]> Co-authored-by: Addison Elliott <[email protected]>
1 parent d7f1d0c commit 52e9e37

7 files changed

Lines changed: 57 additions & 56 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Python
1515
uses: actions/setup-python@v3
1616
with:
17-
python-version: 3.7
17+
python-version: 3.9
1818

1919
- name: Install Python dependencies
2020
run: pip install pre-commit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ docs/build/
1111

1212
# coverage.py files
1313
.coverage
14+
15+
# Virtual environments
16+
.venv

.pre-commit-config.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@ exclude: "docs"
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.3.0
5+
rev: v4.6.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99

1010
- repo: https://github.com/asottile/pyupgrade
11-
rev: v2.34.0
11+
rev: v3.17.0
1212
hooks:
1313
- id: pyupgrade
1414
args: [--py37-plus]
1515

1616
- repo: https://github.com/timothycrosley/isort
17-
rev: 5.10.1
17+
rev: 5.13.2
1818
hooks:
1919
- id: isort
2020

21-
- repo: https://gitlab.com/pycqa/flake8
22-
rev: 5.0.4
21+
- repo: https://github.com/PyCQA/flake8
22+
rev: 7.1.1
2323
hooks:
2424
- id: flake8
2525
args: ["--config=setup.cfg"]
26+
27+
- repo: https://github.com/crate-ci/typos
28+
rev: v1.24.5
29+
hooks:
30+
- id: typos

nrrd/tests/test_writing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def test_quoted_string_list_header(self):
329329
# Strip newline from end of line
330330
lines = [line.rstrip() for line in lines]
331331

332-
# Note the order of the lines dont matter, we just want to verify theyre outputted correctly
332+
# Note the order of the lines dont matter, we just want to verify they are outputted correctly
333333
self.assertTrue('units: "mm" "cm" "in"' in lines)
334334
self.assertTrue('space units: "mm" "cm" "in"' in lines)
335335
self.assertTrue('labels: "X" "Y" "f(log(X, 10), Y)"' in lines)

pyproject.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pynrrd"
7+
dynamic = ["version"]
8+
description = "Pure python module for reading and writing NRRD files."
9+
readme = { file = "README.txt", content-type = "text/x-rst" }
10+
requires-python = ">=3.7"
11+
license = { text = "MIT License" }
12+
authors = [{ name = "Maarten Everts", email = "[email protected]" }]
13+
keywords = ["nrrd", "teem", "image", "processing", "file", "format"]
14+
classifiers = [
15+
"License :: OSI Approved :: MIT License",
16+
"Topic :: Scientific/Engineering",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3.7",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
]
24+
25+
dependencies = ["numpy >=1.11.1", "nptyping", "typing_extensions"]
26+
27+
[project.optional-dependencies]
28+
dev = ["build", "pre-commit", "pytest"]
29+
30+
[project.urls]
31+
Homepage = "https://github.com/mhe/pynrrd"
32+
Documentation = "https://pynrrd.readthedocs.io/en/stable"
33+
Tracker = "https://github.com/mhe/pynrrd/issues"
34+
35+
[tool.setuptools.dynamic]
36+
version = { attr = "nrrd._version.__version__" }
37+
38+
[tool.setuptools.packages]
39+
find = { exclude = ["*.tests", "*.tests.*", "tests.*", "tests"] }

setup.cfg

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
[bdist_wheel]
2-
# This flag says that the code is written to work on both Python 2 and Python
3-
# 3. If at all possible, it is good practice to do this. If you cannot, you
4-
# will need to generate wheels for each Python version that you support.
5-
universal=1
6-
71
[flake8]
82
max-line-length = 120
93
ignore =

setup.py

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,4 @@
1-
import os
1+
from setuptools import setup
22

3-
from setuptools import find_packages, setup
4-
5-
currentPath = os.path.abspath(os.path.dirname(__file__))
6-
7-
# Get __version__ from _version.py
8-
__version__ = None
9-
with open(os.path.join(currentPath, 'nrrd/_version.py')) as fh:
10-
exec(fh.read())
11-
12-
# Get the long description from the README file
13-
with open(os.path.join(currentPath, 'README.rst')) as fh:
14-
longDescription = fh.read()
15-
16-
longDescription = '\n' + longDescription
17-
18-
setup(name='pynrrd',
19-
python_requires='>=3.7',
20-
version=__version__,
21-
description='Pure python module for reading and writing NRRD files.',
22-
long_description=longDescription,
23-
long_description_content_type='text/x-rst',
24-
author='Maarten Everts',
25-
author_email='[email protected]',
26-
url='https://github.com/mhe/pynrrd',
27-
license='MIT License',
28-
install_requires=['numpy>=1.11.1', 'nptyping', 'typing_extensions'],
29-
packages=find_packages(exclude=['*.tests', '*.tests.*', 'tests.*', 'tests']),
30-
keywords='nrrd teem image processing file format',
31-
classifiers=[
32-
'License :: OSI Approved :: MIT License',
33-
'Topic :: Scientific/Engineering',
34-
'Programming Language :: Python',
35-
'Programming Language :: Python :: 3.7',
36-
'Programming Language :: Python :: 3.8',
37-
'Programming Language :: Python :: 3.9',
38-
'Programming Language :: Python :: 3.10',
39-
'Programming Language :: Python :: 3.11',
40-
],
41-
project_urls={
42-
'Tracker': 'https://github.com/mhe/pynrrd/issues',
43-
}
44-
)
3+
if __name__ == "__main__":
4+
setup()

0 commit comments

Comments
 (0)