Skip to content

Commit

Permalink
Revert tox ini
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Nov 22, 2024
1 parent 0a5b42d commit bc9368e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
3.10
3.11
3.12
fetch-depth: 0 # Ensure tags are fetched for versioning
- name: Install llvm on MacOS
if: startsWith(matrix.os, 'macos')
shell: bash -l {0}
Expand Down
27 changes: 12 additions & 15 deletions build_utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,40 @@
import sys
import os

if new_dir := os.getenv("MESON_SOURCE_ROOT"):
os.chdir(new_dir)

gits = ["git"]
if sys.platform == "win32":
gits += ["git.cmd", "git.exe"]

match sys.argv:
case [_, "--dist"]:
type_ = "dist"

Check notice on line 15 in build_utils/version.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

build_utils/version.py#L15

Constant name "type_" doesn't conform to UPPER_CASE naming style
case [_, "--dump"]:
type_ = "dump"
case [_]:
type_ = "print"

Check notice on line 17 in build_utils/version.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

build_utils/version.py#L17

Constant name "type_" doesn't conform to UPPER_CASE naming style

version_file = Path(__file__).parent.parent / "euphonic" / "version.py"

for gitcmd in gits:
try:
proc = subprocess.run([gitcmd, "describe", "--tags", "--dirty"], capture_output=True, check=True, text=True)
version, *dirty = proc.stdout.strip().split("-")
if dirty:
version += f"+{dirty[0]}.{dirty[1]}{'.dirty' if len(dirty) > 2 and type_ != 'dump' else ''}"
break

except (OSError, subprocess.CalledProcessError) as err:
print(f"Tried {gitcmd}, returned: {err}", file=sys.stderr)
proc = subprocess.run([gitcmd, "describe", "--tags", "--dirty"], capture_output=True, check=True, text=True)

Check notice on line 22 in build_utils/version.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

build_utils/version.py#L22

Line too long (116/100)

version, *dirty = proc.stdout.strip().split("-")
if dirty:
version += f"+{dirty[0]}.{dirty[1]}{'.dirty' if len(dirty) > 2 and type_ != 'dump' else ''}"
break

else: # Can't use git
version = version_file.read_text().split("=")[1].strip('"\n ')

version_file.write_text(f'__version__ = "{version}"', encoding="utf-8")

match type_:
case "dist":
version_file.write_text(f'__version__ = "{version}"', encoding="utf-8")
dist_path = os.getenv("MESON_DIST_ROOT")
version_file = Path(dist_path) / "euphonic" / "version.py"
version_file.parent.mkdir(parents=True, exist_ok=True)
version_file.write_text(f'__version__ = "{version}"', encoding="utf-8")

case "dump":
version_file.write_text(f'__version__ = "{version}"', encoding="utf-8")

case "print":
print(version)
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ endforeach

version_script = files('./build_utils/version.py')
meson.add_dist_script('python', version_script, '--dist')
meson.add_postconf_script('python', version_script, '--dist')

# If building from sdist not under git so will be read from last version
version = configure_file(input: 'build_utils/version.py.in',
Expand Down
68 changes: 47 additions & 21 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,79 +1,105 @@
[tox]
# The python environments to run the tests in
envlist = py310,py311,py312,py310-{base,matplotlib,phonopy_reader,brille,all},py310-minrequirements-linux
isolated_build = true
# Skip the execution of setup.py as we do it with the correct arg in commands_pre below
# skipsdist = True
skipsdist = True
whitelist_externals = git

[testenv]
changedir = tests_and_analysis/test
test_command = python run_tests.py --report
passenv = CC CC_LD LDFLAGS CPPFLAGS

[testenv:{py310,py311,py312}]
install_command =
python -m pip install -v \
python -m pip install \
--force-reinstall \
--upgrade \
--upgrade-strategy eager \
{opts} \
{packages}

[testenv:{py310,py311,py312}]
extras =
matplotlib
phonopy_reader
brille
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

# 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}'
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}
extras = matplotlib
commands_pre =
python -m pip install \
--upgrade \
--upgrade-strategy eager \
'{toxinidir}[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}
extras = phonopy_reader
commands_pre =
python -m pip install \
--upgrade \
--upgrade-strategy eager \
'{toxinidir}[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}
extras = brille
commands_pre =
python -m pip install \
--upgrade \
--upgrade-strategy eager \
'{toxinidir}[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}
extras =
phonopy_reader
matplotlib
brille
commands_pre =
python -m pip install \
--upgrade \
--upgrade-strategy eager \
'{toxinidir}[phonopy_reader,matplotlib,brille]'
commands =
{[testenv]test_command} --cov -m multiple_extras

[testenv:py310-minrequirements-linux]
whitelist_externals = rm
skipsdist = True
install_command =
python -m pip install --upgrade pip --force-reinstall -v {opts} {packages}
python -m pip install --force-reinstall {opts} {packages}
platform =
linux: linux
deps =
numpy==1.24.0
-r{toxinidir}/tests_and_analysis/minimum_euphonic_requirements.txt
-r{toxinidir}/tests_and_analysis/tox_requirements.txt
{[testenv:py310]deps}
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 -v -r '{toxinidir}/tests_and_analysis/minimum_euphonic_requirements.txt' '{toxinidir}[test,matplotlib,phonopy_reader,brille]'
python -m pip install '{toxinidir}[matplotlib,phonopy_reader,brille]'
commands = {[testenv]test_command}

0 comments on commit bc9368e

Please sign in to comment.