Skip to content

Commit 2b9ae0e

Browse files
committed
MNT: unify static configuration files into pyproject.toml, update PEP 639 license metadata
1 parent 323f4f1 commit 2b9ae0e

10 files changed

Lines changed: 117 additions & 130 deletions

File tree

.coveragerc

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/cibuildwheel.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ jobs:
6666
# Emulated testing is slow, so trust that the Python 3.12 test is good enough on aarch64
6767
# (takes about 5 minutes per wheel to build, and 5 minutes to test)
6868
CIBW_TEST_SKIP: "cp39-*_aarch64 cp310-*_aarch64 cp311-*_aarch64"
69-
CIBW_TEST_REQUIRES: pytest
69+
CIBW_TEST_GROUPS: dev
7070
CIBW_TEST_COMMAND: >
7171
python -c "import cftime; print(f'cftime v{cftime.__version__}')" &&
72-
python -m pip install check-manifest cython pytest pytest-cov &&
7372
python -m pytest -vv {package}/test
7473
7574
- uses: actions/upload-artifact@v4

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
include *.txt
2-
include README.md
3-
include LICENSE
42
include pyproject.toml
53
include Changelog
64
exclude *.legacy

pyproject.toml

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,105 @@
1+
[project]
2+
name = "cftime"
3+
version = "1.6.5"
4+
description = "Time-handling functionality from netcdf4-python"
5+
readme = "README.md"
6+
authors = [
7+
{ name="Jeff Whitaker", email="whitaker.jeffrey@gmail.com"}
8+
]
9+
license = "MIT"
10+
license-files = ["LICENSE"]
11+
classifiers = [
12+
'Development Status :: 5 - Production/Stable',
13+
'Operating System :: MacOS :: MacOS X',
14+
'Operating System :: Microsoft :: Windows',
15+
'Operating System :: POSIX :: Linux',
16+
'Programming Language :: Python',
17+
'Programming Language :: Python :: 3',
18+
'Programming Language :: Python :: 3.8',
19+
'Programming Language :: Python :: 3.9',
20+
'Programming Language :: Python :: 3.10',
21+
'Programming Language :: Python :: 3.11',
22+
'Programming Language :: Python :: 3.12',
23+
'Programming Language :: Python :: 3.13',
24+
'Topic :: Scientific/Engineering',
25+
]
26+
dependencies = [
27+
"numpy>1.13.3",
28+
]
29+
requires-python = ">=3.8"
30+
31+
[dependency-groups]
32+
dev = [
33+
"check-manifest",
34+
"coverage",
35+
"coveralls",
36+
"cython>=0.29.20",
37+
"pytest",
38+
"pytest-cov",
39+
"sphinx",
40+
"twine",
41+
]
42+
143
[build-system]
244
requires = [
345
"setuptools>=41.2",
446
"cython>=0.29.20",
5-
"wheel",
647
"oldest-supported-numpy ; python_version < '3.9'",
7-
"numpy>=2.0.0rc1,<3 ; python_version >= '3.9'",
48+
"numpy>=2.0.0,<3 ; python_version >= '3.9'",
849
]
950
build-backend = "setuptools.build_meta"
51+
52+
[tool.setuptools]
53+
package-dir = {"" = "src"}
54+
55+
[tool.pytest.ini_options]
56+
testpaths = "test"
57+
addopts = [
58+
"-ra",
59+
"-v",
60+
"--doctest-modules",
61+
"--cov=cftime",
62+
"--cov-report term-missing",
63+
]
64+
doctest_optionflags = [
65+
"NORMALIZE_WHITESPACE",
66+
"ELLIPSIS",
67+
]
68+
69+
[tool.coverage.run]
70+
relative_files = true
71+
branch = true
72+
plugins = [
73+
"Cython.Coverage",
74+
]
75+
include = [
76+
"src/cftime/*",
77+
]
78+
omit = [
79+
"setup.py",
80+
"docs/*",
81+
"ci/*",
82+
"test/*",
83+
".eggs",
84+
]
85+
86+
[tool.coverage.report]
87+
exclude_lines = [
88+
"pragma: no cover",
89+
"def __repr__",
90+
"if __name__ == .__main__.:",
91+
]
92+
93+
[tool.check-manifest]
94+
ignore = [
95+
"*.yml",
96+
".coveragerc",
97+
".gitignore",
98+
"README.release",
99+
"ci",
100+
"ci/*",
101+
"docs",
102+
"docs/*",
103+
"test",
104+
"test/*",
105+
]

requirements-dev.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 23 deletions
This file was deleted.

setup.py

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
import sys
33
import numpy
44

5+
from Cython.Build import cythonize
56
from setuptools import Command, Extension, setup
67

7-
# https://github.com/Unidata/cftime/issues/34
8-
try:
9-
from Cython.Build import cythonize
10-
except ImportError:
11-
cythonize = False
12-
138

149
BASEDIR = os.path.abspath(os.path.dirname(__file__))
1510
SRCDIR = os.path.join(BASEDIR,'src')
@@ -58,31 +53,6 @@ def run(self):
5853
print('clean: skipping file {!r}'.format(artifact))
5954

6055

61-
def extract_version():
62-
version = None
63-
with open(CYTHON_FNAME) as fi:
64-
for line in fi:
65-
if (line.startswith('__version__')):
66-
_, version = line.split('=')
67-
version = version.strip()[1:-1] # Remove quotation characters.
68-
break
69-
return version
70-
71-
72-
def load(fname):
73-
result = []
74-
with open(fname, 'r') as fi:
75-
result = [package.strip() for package in fi.readlines()]
76-
return result
77-
78-
79-
def description():
80-
fname = os.path.join(BASEDIR, 'README.md')
81-
with open(fname, 'r') as fi:
82-
result = ''.join(fi.readlines())
83-
return result
84-
85-
8656
if ((FLAG_COVERAGE in sys.argv or os.environ.get('CYTHON_COVERAGE', None))
8757
and cythonize):
8858
COMPILER_DIRECTIVES = {
@@ -99,43 +69,17 @@ def description():
9969
ext_modules = []
10070
else:
10171
extension = Extension('{}._{}'.format(NAME, NAME),
102-
sources=[CYTHON_FNAME],
72+
sources=[os.path.relpath(CYTHON_FNAME, BASEDIR)],
10373
define_macros=DEFINE_MACROS,
10474
include_dirs=[numpy.get_include(),])
105-
ext_modules = [extension]
106-
if cythonize:
107-
ext_modules = cythonize(extension,
108-
compiler_directives=COMPILER_DIRECTIVES,
109-
language_level=3)
75+
76+
ext_modules = cythonize(
77+
extension,
78+
compiler_directives=COMPILER_DIRECTIVES,
79+
language_level=3,
80+
)
11081

11182
setup(
112-
name=NAME,
113-
author='Jeff Whitaker',
114-
author_email='whitaker.jeffrey@gmail.com',
115-
description='Time-handling functionality from netcdf4-python',
116-
long_description=description(),
117-
long_description_content_type='text/markdown',
11883
cmdclass={'clean_cython': CleanCython},
119-
packages=[NAME],
120-
package_dir={'':'src'},
121-
version=extract_version(),
12284
ext_modules=ext_modules,
123-
install_requires=load('requirements.txt'),
124-
tests_require=load('requirements-dev.txt'),
125-
license='License :: OSI Approved :: MIT License',
126-
python_requires=">=3.8",
127-
classifiers=[
128-
'Development Status :: 5 - Production/Stable',
129-
'Operating System :: MacOS :: MacOS X',
130-
'Operating System :: Microsoft :: Windows',
131-
'Operating System :: POSIX :: Linux',
132-
'Programming Language :: Python',
133-
'Programming Language :: Python :: 3',
134-
'Programming Language :: Python :: 3.9',
135-
'Programming Language :: Python :: 3.10',
136-
'Programming Language :: Python :: 3.11',
137-
'Programming Language :: Python :: 3.12',
138-
'Programming Language :: Python :: 3.13',
139-
'Topic :: Scientific/Engineering',
140-
'License :: OSI Approved :: MIT License'],
141-
)
85+
)

src/cftime/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44
from ._cftime import (microsec_units, millisec_units,
55
sec_units, hr_units, day_units, min_units,
66
UNIT_CONVERSION_FACTORS)
7-
from ._cftime import __version__, CFWarning
7+
from ._cftime import CFWarning
88
# these will be removed in a future release
99
from ._cftime import (DatetimeNoLeap, DatetimeAllLeap, Datetime360Day,
1010
Datetime360Day, DatetimeJulian,
1111
DatetimeGregorian, DatetimeProlepticGregorian)
12+
13+
14+
def __getattr__(item: str):
15+
if item == "__version__":
16+
from importlib.metadata import version
17+
return version("cftime")
18+
19+
raise AttributeError(f"module 'cftime' has no attribute {item!r}")

src/cftime/_cftime.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ cdef int[12] _dayspermonth_leap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 3
4040
cdef int[13] _cumdayspermonth = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]
4141
cdef int[13] _cumdayspermonth_leap = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]
4242

43-
__version__ = '1.6.5'
44-
4543
# Adapted from http://delete.me.uk/2005/03/iso8601.html
4644
# Note: This regex ensures that all ISO8601 timezone formats are accepted - but, due to legacy support for other timestrings, not all incorrect formats can be rejected.
4745
# For example, the TZ spec "+01:0" will still work even though the minutes value is only one character long.

0 commit comments

Comments
 (0)