Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .coveragerc

This file was deleted.

8 changes: 3 additions & 5 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,26 @@ jobs:
# - On PRs, run just oldest and newest Python versions (and omit 3.8 aarch64)
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
CIBW_SKIP="pp* cp36-* cp37-* cp38-* cp39-* cp310-* cp311-* cp38-*_aarch64 *musllinux*"
CIBW_SKIP="cp38-* cp39-* cp310-* cp311-* cp38-*_aarch64 *musllinux*"
else
CIBW_SKIP="pp* cp36-* cp37-* cp38-* *musllinux_aarch64"
CIBW_SKIP="cp38-* *musllinux_aarch64"
fi
echo "CIBW_SKIP=$CIBW_SKIP" >> $GITHUB_ENV
echo "Setting CIBW_SKIP=$CIBW_SKIP"

- name: "Building ${{ matrix.os }} (${{ matrix.arch }}) wheels"
uses: pypa/cibuildwheel@v3.1.4
env:
# Skips pypy py36,37,38
CIBW_SKIP: ${{ env.CIBW_SKIP }}
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
# Emulated testing is slow, so trust that the Python 3.12 test is good enough on aarch64
# (takes about 5 minutes per wheel to build, and 5 minutes to test)
CIBW_TEST_SKIP: "cp39-*_aarch64 cp310-*_aarch64 cp311-*_aarch64"
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_GROUPS: dev
CIBW_TEST_COMMAND: >
python -c "import cftime; print(f'cftime v{cftime.__version__}')" &&
python -m pip install check-manifest cython pytest pytest-cov &&
python -m pytest -vv {package}/test

- uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- name: Install unstable cftime dependencies via pip
run: |
python -m pip install --pre -r requirements-dev.txt
python -m pip install --pre --group dev
# get nightly wheels for numpy
python -m pip install \
--index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/ \
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
include *.txt
include README.md
include LICENSE
include pyproject.toml
include Changelog
exclude *.legacy
Expand Down
102 changes: 99 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,105 @@
[project]
name = "cftime"
version = "1.6.5"
description = "Time-handling functionality from netcdf4-python"
readme = "README.md"
authors = [
{ name="Jeff Whitaker", email="whitaker.jeffrey@gmail.com"}
]
license = "MIT"
license-files = ["LICENSE"]
classifiers = [
'Development Status :: 5 - Production/Stable',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Topic :: Scientific/Engineering',
]
dependencies = [
"numpy>1.13.3",
]
requires-python = ">=3.8"

[dependency-groups]
dev = [
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that I redefined requirements-tests.txt as a PEP 735 dependency group, which accomplishes the same thing: dev-only, and user-invisible dependencies. This PEP is already supported by pip, uv, cibuildwheel, tox and (I suspect) pdm.

"check-manifest",
"coverage",
"coveralls",
"cython>=0.29.20",
"pytest",
"pytest-cov",
"sphinx",
"twine",
]

[build-system]
requires = [
"setuptools>=41.2",
"setuptools>=77.0.1",
"cython>=0.29.20",
"wheel",
"oldest-supported-numpy ; python_version < '3.9'",
"numpy>=2.0.0rc1,<3 ; python_version >= '3.9'",
"numpy>=2.0.0,<3 ; python_version >= '3.9'",
]
build-backend = "setuptools.build_meta"

[tool.setuptools]
package-dir = {"" = "src"}

[tool.pytest.ini_options]
testpaths = "test"
addopts = [
"-ra",
"-v",
"--doctest-modules",
"--cov=cftime",
"--cov-report=term-missing",
]
doctest_optionflags = [
"NORMALIZE_WHITESPACE",
"ELLIPSIS",
]

[tool.coverage.run]
relative_files = true
branch = true
plugins = [
"Cython.Coverage",
]
include = [
"src/cftime/*",
]
omit = [
"setup.py",
"docs/*",
"ci/*",
"test/*",
".eggs",
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if __name__ == .__main__.:",
]

[tool.check-manifest]
ignore = [
"*.yml",
".coveragerc",
".gitignore",
"README.release",
"ci",
"ci/*",
"docs",
"docs/*",
"test",
"test/*",
]
9 changes: 0 additions & 9 deletions requirements-dev.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

23 changes: 0 additions & 23 deletions setup.cfg

This file was deleted.

74 changes: 9 additions & 65 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
import sys
import numpy

from Cython.Build import cythonize
from setuptools import Command, Extension, setup

# https://github.com/Unidata/cftime/issues/34
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: direct invocations of setup.py as a scripts are deprecated in setuptools, so gh-34 should not be an issue now.

try:
from Cython.Build import cythonize
except ImportError:
cythonize = False


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


def extract_version():
version = None
with open(CYTHON_FNAME) as fi:
for line in fi:
if (line.startswith('__version__')):
_, version = line.split('=')
version = version.strip()[1:-1] # Remove quotation characters.
break
return version


def load(fname):
result = []
with open(fname, 'r') as fi:
result = [package.strip() for package in fi.readlines()]
return result


def description():
fname = os.path.join(BASEDIR, 'README.md')
with open(fname, 'r') as fi:
result = ''.join(fi.readlines())
return result


if ((FLAG_COVERAGE in sys.argv or os.environ.get('CYTHON_COVERAGE', None))
and cythonize):
COMPILER_DIRECTIVES = {
Expand All @@ -99,43 +69,17 @@ def description():
ext_modules = []
else:
extension = Extension('{}._{}'.format(NAME, NAME),
sources=[CYTHON_FNAME],
sources=[os.path.relpath(CYTHON_FNAME, BASEDIR)],
define_macros=DEFINE_MACROS,
include_dirs=[numpy.get_include(),])
ext_modules = [extension]
if cythonize:
ext_modules = cythonize(extension,
compiler_directives=COMPILER_DIRECTIVES,
language_level=3)

ext_modules = cythonize(
extension,
compiler_directives=COMPILER_DIRECTIVES,
language_level=3,
)

setup(
name=NAME,
author='Jeff Whitaker',
author_email='whitaker.jeffrey@gmail.com',
description='Time-handling functionality from netcdf4-python',
long_description=description(),
long_description_content_type='text/markdown',
cmdclass={'clean_cython': CleanCython},
packages=[NAME],
package_dir={'':'src'},
version=extract_version(),
ext_modules=ext_modules,
install_requires=load('requirements.txt'),
tests_require=load('requirements-dev.txt'),
license='License :: OSI Approved :: MIT License',
python_requires=">=3.8",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Topic :: Scientific/Engineering',
'License :: OSI Approved :: MIT License'],
)
)
10 changes: 9 additions & 1 deletion src/cftime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
from ._cftime import (microsec_units, millisec_units,
sec_units, hr_units, day_units, min_units,
UNIT_CONVERSION_FACTORS)
from ._cftime import __version__, CFWarning
from ._cftime import CFWarning
# these will be removed in a future release
from ._cftime import (DatetimeNoLeap, DatetimeAllLeap, Datetime360Day,
Datetime360Day, DatetimeJulian,
DatetimeGregorian, DatetimeProlepticGregorian)


def __getattr__(item: str):
if item == "__version__":
from importlib.metadata import version
return version("cftime")

raise AttributeError(f"module 'cftime' has no attribute {item!r}")
2 changes: 0 additions & 2 deletions src/cftime/_cftime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ cdef int[12] _dayspermonth_leap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 3
cdef int[13] _cumdayspermonth = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]
cdef int[13] _cumdayspermonth_leap = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]

__version__ = '1.6.5'

# Adapted from http://delete.me.uk/2005/03/iso8601.html
# 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.
# For example, the TZ spec "+01:0" will still work even though the minutes value is only one character long.
Expand Down
Loading