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

add initial tox.ini #3196

Merged
merged 7 commits into from
Feb 24, 2025
Merged

add initial tox.ini #3196

merged 7 commits into from
Feb 24, 2025

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Jan 31, 2025

I started out on a tox.ini because it's handy to have; it's not complete enough to close #3170, but it should be sufficient for #2699 once the CI is updated to use it.

everybody's very welcome to push commits to this PR, but I don't think we should block merging it until the tox/nox config is perfect (leaving that for followup PRs) Cause I Wanna Use It ™️

@jakkdl
Copy link
Member Author

jakkdl commented Feb 14, 2025

ugh, native toml not supporting https://tox.wiki/en/latest/config.html#conditional-settings makes it a non-trivial conversion. I think the way to get around that is with more explicit environments + https://tox.wiki/en/latest/config.html#string-substitution-references; but... that's for another day/person

@jakkdl
Copy link
Member Author

jakkdl commented Feb 14, 2025

If you review ci.sh with ignoring whitespace: https://github.com/python-trio/trio/pull/3196/files?w=1
you see that it's solely just removing the CHECK_FORMATTING logic.

I propose delaying further CI/ci.sh/tox-gh stuff for future PR's, as that quickly gets very messy.

Copy link
Member

@CoolCat467 CoolCat467 left a comment

Choose a reason for hiding this comment

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

I think this mostly makes sense, wondering about mypy runs, and I thought there was some sort of tox github actions thing that was useful for some reason the last time I used tox.

Comment on lines +77 to +79
mypy --platform linux
mypy --platform darwin
mypy --platform win32
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this use mypy_annotate?

Copy link
Member Author

Choose a reason for hiding this comment

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

hm. Maybe, but mypy_annotate is less needed with tox supressing output of succesful commands and in general reformatting the output. One of the problems with check.sh was simply finding what it was that failed, which I think is what prompted the creation of it. But we don't want it when running outside of CI, so needs some logic to differentiate.
But if we don't use it here then it should just be removed.

I'll procrastinate on it a little bit, and see what the output looks like in practice. I suspect the end result is going to be removing mypy_annotate

@webknjaz
Copy link
Member

@jakkdl thanks for pinging! Love that it's being worked on. I'll review shortly :)

@webknjaz
Copy link
Member

  • I probably prefer having this in pyproject.toml

I'd vote for tox.toml since dumping multiple things into one terribly huge config is going to be difficult to maintain.

- name: Check Formatting
if: matrix.check_formatting == '1'
run:
python -m pip install tox &&
Copy link
Member

Choose a reason for hiding this comment

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

You may want to use tox-uv too. Though, it's okay to omit. Especially in the initial effort.

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure there's much, if any, speedup when we're only running a single environment

Copy link
Member

Choose a reason for hiding this comment

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

I haven't compared them, but I'd imagine that provisioning that env would be faster. You don't separate the provisioning step in this PR, so I can't see how much it takes. But it's probably not important enough right now.

[testenv:docs]
deps =
-r docs-requirements.txt
# base_python synced with .readthedocs.yml
Copy link
Member

Choose a reason for hiding this comment

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

We can also make RTD just call tox in a follow-up. This is what I do these days.

base_python = 3.13
set_env =
PYRIGHT_PYTHON_IGNORE_WARNINGS=1
commands =
Copy link
Member

Choose a reason for hiding this comment

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

Let's also add --python-version= in follow-ups.

Copy link
Member Author

@jakkdl jakkdl Feb 24, 2025

Choose a reason for hiding this comment

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

python versions are specified in pyproject.toml for both tools

edit: ah you mean parametrizing the version

@webknjaz
Copy link
Member

and I thought there was some sort of tox github actions thing that was useful for some reason the last time I used tox.

@CoolCat467 there's a plugin: https://github.com/tox-dev/tox-gh. It also demonstrates separating the invocation into preparation and testing. But I think this is something to look into separately, beyond the initial effort. I don't exactly like how the jobs are mixed up right now, but I believe this is out of the scope, so I choose not to start those discussions just yet.

Copy link
Member

@webknjaz webknjaz left a comment

Choose a reason for hiding this comment

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

I think this is ready to be merged and can be iterated on separately. Though, if you have a minute to accept the commands_pre thing and add descriptions, it'd be nice to include into the scope of this PR.

jakkdl and others added 2 commits February 24, 2025 12:30

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@jakkdl jakkdl enabled auto-merge February 24, 2025 11:33
@jakkdl jakkdl added this pull request to the merge queue Feb 24, 2025
Merged via the queue into python-trio:main with commit 1b82247 Feb 24, 2025
43 checks passed
@jakkdl jakkdl deleted the add_tox branch February 24, 2025 11:52
# protip: install uv-tox for faster venv generation

[testenv]
description = "Base environment for running tests depending on python version."
Copy link
Member

Choose a reason for hiding this comment

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

@jakkdl is configparser able to handle the quotes well? I think this is the first time I see them in this context.. Does the output of tox l look good?

Copy link
Member Author

Choose a reason for hiding this comment

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

...no 😅

❯ tox l
default environments:
py39 -> "Base environment for running tests depending on python version."
py310 -> "Base environment for running tests depending on python version."
py311 -> "Base environment for running tests depending on python version."
py312 -> "Base environment for running tests depending on python version."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace check.sh and/or ci.sh with tox/nox Use tox and/or pre-commit for static analysis checks
3 participants