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

Allow for easy wheel-sharing #740

Open
hynek opened this issue Sep 15, 2023 · 1 comment
Open

Allow for easy wheel-sharing #740

hynek opened this issue Sep 15, 2023 · 1 comment

Comments

@hynek
Copy link
Contributor

hynek commented Sep 15, 2023

How would this feature be useful?

Currently, Nox builds and installs a fresh wheel for every session. That is slow & unnecessary for 99.999% of situations.

Describe the solution you'd like

I'd like something akin to tox's

[testenv]
package = wheel
wheel_build_env = .pkg

(see also https://hynek.me/articles/turbo-charge-tox/)

so I can say that one wheel is plenty for all environments, like

nox.options.one_wheel_for_all = True

I don't think Nox needs as fine-grained controls like tox has – courtesy of Python. But this one use case is common enough to save a lot of CPU and IO cycles.

Describe alternatives you've considered

You can do it by hand, either by passing an argument:

@nox.session
def tests(session):
    posargs = list(session.posargs)

    try:
        i = posargs.index("--installpkg")
        pkg = posargs[i + 1]
        del posargs[i : i + 2]
    except ValueError:
        pkg = "."

    session.install(pkg)

Or an explicit environment:

@nox.session
def build(session: nox.Session) -> None:
    shutil.rmtree("dist", ignore_errors=True)
    session.install("build")
    session.run("python", "-m", "build")


@nox.session(python=[...])
def tests(session: nox.Session) -> None:
    (wheel,) = Path("dist").glob("*.whl")

    session.install(wheel, "coverage[toml]")

    session.run("coverage", "run", "-m", "pytest", *session.posargs)

    if os.environ.get("CI") != "true":
        session.notify("coverage_report")

But but both require manual intervention and present sharp edges. E.g. calling nox -s tests -p 3.11 won't rebuild the package and will run the tests against outdated code.

If this would be handled by Nox, I would expect it to make sure the wheel is built when I call session.install('.')

Anything else?

No response

@chrysle
Copy link
Contributor

chrysle commented Feb 25, 2024

I think that wheel could be cached. I'll have a look at the implementation, as this annoys me, too.

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

No branches or pull requests

2 participants