Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tox configuration #37

Merged
merged 3 commits into from
Aug 29, 2022
Merged

Fix tox configuration #37

merged 3 commits into from
Aug 29, 2022

Conversation

aromanielloNTIA
Copy link
Member

@aromanielloNTIA aromanielloNTIA commented Aug 26, 2022

Switching the build system to hatchling broke the configuration for tox.

This update fixes the tox configuration, moves it to pyproject.toml, and updates the related part of the README.

A future version of tox will natively support configuration in pyproject.toml, rather than the legacy version currently implemented in this PR. (See tox-dev/tox#999)

@aromanielloNTIA aromanielloNTIA added the bug Something isn't working label Aug 26, 2022
@aromanielloNTIA aromanielloNTIA self-assigned this Aug 26, 2022
@ofek
Copy link

ofek commented Aug 27, 2022

Would adding isolated_build = true under [tox] work instead?

@aromanielloNTIA
Copy link
Member Author

@ofek I went back and forth about the best way to do this. When I use the tox config:

[tox]
envlist = py{38,39,310}
skip_missing_interpreters = True
isolated_build = True

[testenv]
deps =
    pytest >= 7.1.2
    pytest-cov >= 3.0.0
commands = pytest

...

I get: WARNING: could not copy distfile to H:\.tox\distshare at the beginning of the testing output when running tox.

The upside to the implementation in this PR is that this warning doesn't show up (I can't find much information about what its implications are), and the testing dependencies are only defined once in pyproject.toml. The downside is that additional [dev] dependencies are installed in the testing environments unnecessarily.

A better solution may be to create a new set of optional dependencies (listed under [project.optional-dependencies] in pyproject.toml) just for the testing environment. This would still require multiply-defined testing requirements. I would expect that when tox adds native support for pyproject.toml configuration, this will become a bit less awkward.

@ofek
Copy link

ofek commented Aug 29, 2022

Have you tried Hatch environments?

@aromanielloNTIA
Copy link
Member Author

@ofek We have internally discussed using Hatch for this repository after this issue was raised. We plan to test out Hatch and see if it is the solution we want to use longer-term, but for now we just want a quick fix for tox.

@ofek
Copy link

ofek commented Aug 29, 2022

When the time comes, this:

[tox]
envlist = py{38,39,310}
skip_missing_interpreters = True
skipsdist = True

[testenv]
commands =
    pip install .[dev]
    pytest

[testenv:coverage]
commands =
    pip install .[dev]
    pytest --cov --cov-append --cov-report=term-missing --no-cov-on-fail

could become in a hatch.toml:

[[envs.default.matrix]]
python = ["38", "39", "310"]

[envs.default.scripts]
test = "pytest"
test-cov = "pytest --cov --cov-append --cov-report=term-missing --no-cov-on-fail"

@aromanielloNTIA
Copy link
Member Author

Thanks for the feedback and assistance, @ofek!

Copy link
Member

@jhazentia jhazentia left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@jhazentia jhazentia merged commit 3d74407 into master Aug 29, 2022
@jhazentia jhazentia deleted the fix-tox branch August 29, 2022 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants