From 508f602981eeadd66478dbe1f73bdb65d7ad9cd1 Mon Sep 17 00:00:00 2001 From: Jacob Wilkins Date: Fri, 22 Nov 2024 23:01:28 +0000 Subject: [PATCH] Migrate to tox 4 --- pyproject.toml | 3 +- tests_and_analysis/ci_requirements.txt | 2 +- ...constants_calculate_qpoint_phonon_modes.py | 2 +- tests_and_analysis/test/pytest.ini | 1 + tox.ini | 108 ++++++++---------- 5 files changed, 52 insertions(+), 64 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6aec791d4..2efb15433 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,8 @@ documentation = "https://euphonic.readthedocs.io/en/stable/" matplotlib = ["matplotlib>=3.8.0"] phonopy_reader = ["h5py>=3.6.0", "PyYAML>=6.0"] brille = ["brille>=0.7.0"] -test = ["mock", "pytest~=7.0", "coverage", "pytest-mock", "pytest-lazy-fixture", "pytest-xvfb"] +test = ["mock", "pytest~=7.0", "coverage", "pytest-mock", "pytest-lazy-fixture", "pytest-xvfb", "python-slugify"] +phonopyreader = ["h5py>=3.6.0", "PyYAML>=6.0"] [project.scripts] euphonic-brille-convergence = "euphonic.cli.brille_convergence:main" diff --git a/tests_and_analysis/ci_requirements.txt b/tests_and_analysis/ci_requirements.txt index cea4f609d..dd179a87e 100644 --- a/tests_and_analysis/ci_requirements.txt +++ b/tests_and_analysis/ci_requirements.txt @@ -1 +1 @@ -tox==3.28.0 +tox>=4 diff --git a/tests_and_analysis/test/euphonic_test/test_force_constants_calculate_qpoint_phonon_modes.py b/tests_and_analysis/test/euphonic_test/test_force_constants_calculate_qpoint_phonon_modes.py index 0462761c5..56abb442c 100644 --- a/tests_and_analysis/test/euphonic_test/test_force_constants_calculate_qpoint_phonon_modes.py +++ b/tests_and_analysis/test/euphonic_test/test_force_constants_calculate_qpoint_phonon_modes.py @@ -301,7 +301,7 @@ def test_with_use_c_false_doesnt_raise_error_or_warn( fc.calculate_qpoint_phonon_modes(get_test_qpts(), use_c=False) assert len(warn_record) == 0 - +@pytest.mark.c_extension class TestForceConstantsCalculateQPointPhononModesWithCExtensionInstalled: @pytest.fixture diff --git a/tests_and_analysis/test/pytest.ini b/tests_and_analysis/test/pytest.ini index 0d0c1f49e..3c72d8828 100644 --- a/tests_and_analysis/test/pytest.ini +++ b/tests_and_analysis/test/pytest.ini @@ -4,3 +4,4 @@ markers = matplotlib: requires euphonic[matplotlib] extra to be installed brille: requires euphonic[brille] extra to be installed multiple_extras: requires any combination of the above extras e.g. phonopy_reader and matplotlib + c_extension: Requires c extension compiled diff --git a/tox.ini b/tox.ini index b5aa818df..e1fe49513 100644 --- a/tox.ini +++ b/tox.ini @@ -1,105 +1,91 @@ [tox] +requires = tox>=4 # The python environments to run the tests in -envlist = py310,py311,py312,py310-{base,matplotlib,phonopy_reader,brille,all},py310-minrequirements-linux +envlist = py310,py311,py312,py310-{base,matplotlib,phonopy_reader,brille,all,minrequirements-linux,no-c} # Skip the execution of setup.py as we do it with the correct arg in commands_pre below -skipsdist = True -whitelist_externals = git +allowlist_externals = git [testenv] +package = wheel changedir = tests_and_analysis/test test_command = python run_tests.py --report -passenv = CC CC_LD LDFLAGS CPPFLAGS - -[testenv:{py310,py311,py312}] +passenv = CC, CC_LD, LDFLAGS, CPPFLAGS install_command = - python -m pip install \ + python -m pip install -v \ --force-reinstall \ --upgrade \ --upgrade-strategy eager \ {opts} \ {packages} -deps = - numpy - -r{toxinidir}/tests_and_analysis/tox_requirements.txt -commands_pre = - python -m pip install \ - --upgrade \ - --upgrade-strategy eager \ - '{toxinidir}[matplotlib,phonopy_reader,brille]' -commands = - {[testenv]test_command} --cov +extras = + test + phonopy_reader + +[testenv:{py310,py311,py312}] +extras = + {[testenv]extras} + matplotlib + phonopy_reader + brille +commands = {[testenv]test_command} --cov # Test with no extras [testenv:py310-base] -install_command = {[testenv:py310]install_command} -deps = {[testenv:py310]deps} -commands_pre = - python -m pip install \ - --upgrade \ - --upgrade-strategy eager \ - '{toxinidir}' +extras = {[testenv]extras} commands = {[testenv]test_command} --cov -m "not (phonopy_reader or matplotlib or brille)" # Test with matplotlib extra only [testenv:py310-matplotlib] -install_command = {[testenv:py310]install_command} -deps = {[testenv:py310]deps} -commands_pre = - python -m pip install \ - --upgrade \ - --upgrade-strategy eager \ - '{toxinidir}[matplotlib]' +extras = + {[testenv]extras} + matplotlib commands = {[testenv]test_command} --cov -m "matplotlib and not multiple_extras" # Test with phonopy_reader extra only [testenv:py310-phonopy_reader] -install_command = {[testenv:py310]install_command} -deps = {[testenv:py310]deps} -commands_pre = - python -m pip install \ - --upgrade \ - --upgrade-strategy eager \ - '{toxinidir}[phonopy_reader]' +extras = + {[testenv]extras} + phonopy_reader commands = {[testenv]test_command} --cov -m "phonopy_reader and not multiple_extras" # Test with brille extra only [testenv:py310-brille] -install_command = {[testenv:py310]install_command} -deps = {[testenv:py310]deps} -commands_pre = - python -m pip install \ - --upgrade \ - --upgrade-strategy eager \ - '{toxinidir}[brille]' +extras = + {[testenv]extras} + brille commands = {[testenv]test_command} --cov -m "brille and not multiple_extras" # Run remaining tests that require multiple extras [testenv:py310-all] -install_command = {[testenv:py310]install_command} -deps = {[testenv:py310]deps} -commands_pre = - python -m pip install \ - --upgrade \ - --upgrade-strategy eager \ - '{toxinidir}[phonopy_reader,matplotlib,brille]' +extras = + {[testenv]extras} + matplotlib + phonopy_reader + brille commands = {[testenv]test_command} --cov -m multiple_extras [testenv:py310-minrequirements-linux] -whitelist_externals = rm -install_command = - python -m pip install --force-reinstall {opts} {packages} +package = sdist +allowlist_externals = rm platform = linux: linux deps = - numpy==1.24.0 - {[testenv:py310]deps} + -r{toxinidir}/tests_and_analysis/minimum_euphonic_requirements.txt +extras = {[testenv]extras} commands_pre = - python -m pip install --force-reinstall \ - -r{toxinidir}/tests_and_analysis/minimum_euphonic_requirements.txt - python -m pip install --force-reinstall \ - -r{toxinidir}/tests_and_analysis/tox_requirements.txt # Force rebuild of euphonic extension to avoid Numpy clash rm -rf {toxinidir}/build python -m pip install '{toxinidir}[matplotlib,phonopy_reader,brille]' commands = {[testenv]test_command} + +[testenv:py310-no-c] +install_command = {[testenv]install_command} -Csetup-args="-Dpython_only=true" +platform = + linux: linux +extras = + {[testenv]extras} + matplotlib + phonopy_reader + brille +commands = {[testenv]test_command} -m 'not c_extension'