diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a833531..0e95b18c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,13 +37,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install Tox and any other packages - run: | - python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions - - name: Test - run: tox -vvv + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh + - name: Install Python + if: matrix.python-version != '3.13' + run: uv python install --python-preference only-managed ${{ matrix.python-version }} + - name: Setup test suite + run: tox run -vv --notest --skip-missing-interpreters false + env: + TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }} + - name: Run test suite + run: tox run + env: + TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }} diff --git a/pyproject.toml b/pyproject.toml index 53eb2e60..54104f3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ keywords = [ requires-python = ">=3.9" dependencies = [ "numpy>=1.19.3, <3.0", + "numpy>=1.21.3, <3.0 ; platform_machine=='arm64' and platform_system=='Darwin'", "sympy>=1.7", "packaging>=20.9", ] @@ -45,6 +46,36 @@ Homepage = "https://github.com/yt-project/unyt" Documentation = "https://unyt.readthedocs.io/en/stable/index.html" Changelog = "https://unyt.readthedocs.io/en/stable/history.html" +[dependency-groups] +test = [ + "pytest-doctestplus>=1.2.1", + "pytest>=7.2.1", +] +covcheck = [ + "coverage[toml]>=5.0.0", +] +doc = [ + "docutils>=0.21.2", + "sphinx>=7.4.7", +] +integration = [ + "astropy>=4.0.4", + "astropy>=5.0.0 ; platform_machine=='arm64' and platform_system=='Darwin'", + "dask[array,diagnostics]>=2021.4.1", + "dask[array,diagnostics]>=2021.5.1 ; platform_machine=='arm64' and platform_system=='Darwin'", + "h5py>=3.0.0", + "h5py>=3.7.0 ; platform_machine=='arm64' and platform_system=='Darwin'", + "matplotlib>=3.3.3,!=3.5.0", + "matplotlib>=3.5.1 ; platform_machine=='arm64' and platform_system=='Darwin'", + "pint>=0.9", + + # this is redundant with runtime requirements, but needed for tox + tox-uv with + # UV_RESOLUTION=lowest-direct + # because tox installs dependency groups *before* installing the package itself + "numpy>=1.19.3, <3.0", + "numpy>=1.21.3, <3.0 ; platform_machine=='arm64' and platform_system=='Darwin'", +] + [tool.setuptools] include-package-data = true zip-safe = false @@ -119,7 +150,7 @@ write_to = "unyt/_version.py" version_scheme = "post-release" [tool.pytest.ini_options] -addopts = "--ignore=benchmarks --ignore=paper --ignore=unyt/_mpl_array_converter --color=yes" +addopts = "-ra --ignore=benchmarks --ignore=paper --ignore=unyt/_mpl_array_converter --color=yes" filterwarnings = [ "error", "ignore:Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.:UserWarning", @@ -127,6 +158,7 @@ filterwarnings = [ "ignore:distutils Version classes are deprecated. Use packaging.version instead.:DeprecationWarning", 'ignore:datetime\.datetime\.utcfromtimestamp\(\) is deprecated:DeprecationWarning', # https://github.com/dateutil/dateutil/pull/1285 'ignore:mpnumeric is deprecated:DeprecationWarning', # sympy 1.12 VS mpmath 1.4, solution: https://github.com/sympy/sympy/pull/25290 + 'ignore:`np.compat`, which was used during the Python 2 to 3 transition, is deprecated since 1.26.0, and will be removed:DeprecationWarning' # from dask 2021.x ] [tool.coverage.run] diff --git a/tox.ini b/tox.ini index 4d2010d0..ac48a37f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,35 +1,35 @@ [tox] +min_version = 4.22.0 # for pep 735 dependency groups envlist = py39-docs,begin,py39-dependencies,py39-versions,py{39,310,311,312},py39-unyt-module-test-function,end isolated_build = True +requires = + tox-uv # for oldest dependency testing -[gh-actions] +[gh] python = - 3.9: py39, py39-docs, py39-dependencies, py39-versions, py39-unyt-module-test-function - 3.10: py310 - 3.11: py311 - 3.12: py312 + 3.9 = py39, py39-docs, py39-dependencies, py39-versions, py39-unyt-module-test-function + 3.10 = py310 + 3.11 = py311 + 3.12 = py312 [testenv] +depends = begin package = wheel wheel_build_env = .pkg setenv = PYTHONPATH = {toxinidir} MPLBACKEND = agg recreate = true -depends = begin -deps = - pytest - h5py - !py39: pint - !py39: astropy!=6.1.1 - coverage[toml]>=5.0 - pytest-cov - pytest-doctestplus - matplotlib!=3.5.0 - docutils - dask[array,diagnostics] +dependency_groups = + test + covcheck + doc + integration +uv_resolution = + # install the oldest versions of all dependencies + versions: lowest-direct commands = - pytest --cov=unyt --cov-append --doctest-modules --doctest-plus --doctest-rst --basetemp={envtmpdir} + coverage run --append -m pytest --doctest-modules --doctest-plus --doctest-rst --basetemp={envtmpdir} coverage report --omit='.tox/*' [testenv:py39] @@ -37,72 +37,59 @@ commands = # but some of our optional deps (pint, astropy) don't have a version that support # both numpy>=2.0 and Python 3.9 commands= - pytest --cov=unyt --cov-append --basetemp={envtmpdir} + coverage run --append -m pytest --basetemp={envtmpdir} coverage report --omit='.tox/*' [testenv:py39-versions] -deps = - docutils - pytest - sympy==1.7 - numpy==1.19.3 - h5py==3.0.0 - pint==0.9 - astropy==4.0.4 - matplotlib==3.3.3 - coverage[toml] - pytest-cov - pytest-doctestplus - dask[array,diagnostics]==2021.04.1 commands = + {list_dependencies_command} # don't do doctests on old numpy versions - pytest --cov=unyt --cov-append --basetemp={envtmpdir} + coverage run --append -m pytest --basetemp={envtmpdir} coverage report --omit='.tox/*' [testenv:py39-dependencies] -deps = - docutils - pytest - coverage[toml] - pytest-cov - pytest-doctestplus depends = begin +dependency_groups = + doc + test + covcheck commands = # don't do doctests in rst files due to lack of way to specify optional # test dependencies there - pytest --cov=unyt --cov-append --doctest-modules --doctest-plus --basetemp={envtmpdir} + coverage run --append -m pytest --doctest-modules --doctest-plus --basetemp={envtmpdir} coverage report --omit='.tox/*' [testenv:py39-docs] allowlist_externals = make changedir = docs -deps = - pytest - sphinx - matplotlib!=3.5.0 - dask[array,diagnostics] +dependency_groups = + test + doc + integration commands = make clean python -m sphinx -M html "." "_build" -W [testenv:py39-unyt-module-test-function] depends = py39 +dependency_groups = + test commands = python -c 'import unyt; unyt.test()' [testenv:begin] -commands = - coverage erase depends = skip_install = true -deps = - coverage[toml] +dependency_groups = + covcheck +commands = + coverage erase [testenv:end] +depends = py{39,310,311,312} +skip_install = true +dependency_groups = + covcheck commands = coverage report --omit='.tox/*' coverage html --omit='.tox/*' -skip_install = true -depends = py{39,310,311,312} -deps = - coverage[toml]