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

feat: add session sync for uv #857

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Wurstnase
Copy link
Contributor

This is a draft how uv synv could be added to nox[uv].

@nox.session(venv_backend="uv")
def test(session):
    session.sync(extras="all")  # inexact by default
    session.install("pytest")
    session.run(*"pytest tests".split())

@Wurstnase Wurstnase mentioned this pull request Oct 6, 2024
@henryiii
Copy link
Collaborator

henryiii commented Oct 7, 2024

This doesn't feel right to me yet. You can already do:

@nox.session(venv_backend="uv")
def test(session):
    session.run_install("uv", "sync", "--inexact", "--frozen", "--all-extras",
        env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location})
    session.install("pytest")
    session.run("pytest", "tests")

Which is more explicit and more flexible - the UV_PROJECT_ENVIRONMENT is inconvenient, but I'm not sure it warrants a custom command - a recipe for this would be better for now, I thinl. The benefit of a custom command would be to provide the same API for multiple backends (which isn't here yet). If we had a plugin system (#848), and users could add support for Poetry and whatnot, that might be more interesting. Or maybe if we integrate with .venv; the custom environments feature (#167 (comment)) which I'd like to work on in the next month or two would also potentially provide a better place to put this; we could require that users use Env's if they want to use locking. We also don't know what the multi-environment support for uv will look like. So good idea, and great idea for a cookbook example, but maybe let's hold off on it for a bit?

@henryiii henryiii mentioned this pull request Oct 7, 2024
@henryiii henryiii marked this pull request as draft October 7, 2024 04:33
@Wurstnase
Copy link
Contributor Author

Thanks for your feedback.

I start with run_install but I need to repeat this part again and again. In between I patched the @nox.session to return a CustomSession which has something like the sync method.

However, I see your point and I think it's worth to wait for PEP 751.

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

Successfully merging this pull request may close these issues.

2 participants