Skip to content

Commit

Permalink
Switch from tox to hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
benvial committed Aug 27, 2024
1 parent 3e7d58b commit 359603f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 63 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install Python build tools
run: python -m pip install tox wheel
run: python -m pip install hatch wheel
- name: Run tests
run: python -m tox run -e py
if: startsWith(matrix.python-version, 'pypy') != true
run: hatch test -i python=${{ matrix.python-version }}
- name: Run tests (pypy)
if: startsWith(matrix.python-version, 'pypy') == true
run: |
PYTHONENV=${{ matrix.python-version }}
PYTHONENV=${PYTHONENV//-} # replace all dashes
hatch test -i python=${PYTHONENV}
- name: Install Scipy prerequisites for Ubuntu
if: startsWith(matrix.platform, 'ubuntu')
run: sudo apt-get install libopenblas-dev
- name: Run tests with scipy
if: startsWith(matrix.platform, 'ubuntu') || startsWith(matrix.python-version, 'pypy') != true
run: python -m tox run -e py-scipy
run: hatch test -i python=${{ matrix.python-version }} -i feature=scipy
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,29 @@ extend-exclude = []
lint.extend-ignore = ["E731"]
lint.extend-select = ["I", "W"]
line-length = 109

[tool.hatch.envs.default]
dependencies = ["coverage[toml]", "pytest", "pytest-cov"]

[tool.hatch.envs.default.scripts]
test = 'pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=autograd --cov=tests'

[tool.hatch.envs.hatch-test.overrides]
matrix.version.env-vars = "PRODUCT_VERSION"
matrix.feature.env-vars = "EXPERIMENTAL=true"
matrix.feature.dependencies = [{ value = "scipy", if = ["scipy"] }]

[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
feature = ["scipy"]

[[tool.hatch.envs.hatch-test.matrix]]
python = ["pypy-3.9", "pypy3.10"]

[[tool.hatch.envs.hatch-test.matrix]]
python = ["pypy3.9", "pypy3.10"]
feature = ["scipy"]

60 changes: 0 additions & 60 deletions tox.ini

This file was deleted.

3 comments on commit 359603f

@agriyakhetarpal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @benvial, I just happened to notice your branch here. I'm trying to migrate from tox to nox here: #632, which I find slightly better than hatch (just my opinion, of course). There are a few other changes in that PR because I'm also trying to improve the testing infrastructure to accommodate more NumPy versions. I just wanted to point that out and save your effort in case you haven't already seen it!

@benvial
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @agriyakhetarpal! Thanks for the heads up, I was just trying to set things up and play around with hatch but I think I prefer nox too.
BTW thanks for maintaining autograd!

@agriyakhetarpal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome, and I'm happy to help! I would appreciate your contributions and wherever they're feasible for you; trying to get the issue count down is one of my main tasks over the coming weeks. :) In that case, please feel free to leave your suggestions, if any, on the nox PR and I'll be glad to incorporate them for you!

Please sign in to comment.