Skip to content

Commit

Permalink
Migrate to tox 4
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Nov 22, 2024
1 parent c829321 commit 508f602
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 64 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests_and_analysis/ci_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
tox==3.28.0
tox>=4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests_and_analysis/test/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
108 changes: 47 additions & 61 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit 508f602

Please sign in to comment.