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 25, 2024
1 parent c829321 commit fdadfe9
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 60 deletions.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ documentation = "https://euphonic.readthedocs.io/en/stable/"

[project.optional-dependencies]
matplotlib = ["matplotlib>=3.8.0"]
phonopy_reader = ["h5py>=3.6.0", "PyYAML>=6.0"]
phonopy_reader = ["h5py>=3.6.0", "PyYAML>=6.0"] # Deprecated, will be removed in future versions.
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"]

[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
103 changes: 47 additions & 56 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,99 +1,90 @@
[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_LD
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

[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]'
# Test with phonopy-reader extra only
[testenv:py310-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-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'

[testenv:py310-minrequirements-linux]
whitelist_externals = rm
skip_install = True
allowlist_externals = rm
install_command =
python -m pip install --force-reinstall {opts} {packages}
platform =
linux: linux
deps =
numpy==1.24.0
{[testenv:py310]deps}
-r{toxinidir}/tests_and_analysis/tox_requirements.txt
commands_pre =
python -m pip install --force-reinstall \
-r{toxinidir}/tests_and_analysis/minimum_euphonic_requirements.txt
Expand Down

0 comments on commit fdadfe9

Please sign in to comment.