-
Notifications
You must be signed in to change notification settings - Fork 18
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
Clarify how development dependencies are installed #399
Comments
See #389 |
Is it possible to install the dev dependencies as well? Or is it a design choice to disallow it? |
The reason I ask is I have a session that runs |
You can do this: session.install("mypy", "types-foobar") Or this: session.run_always("poetry", "install", external=True)
nox-poetry does not change that. It just makes it respect the lockfile. So if you add mypy and types-foobar as development dependencies, the first example will install them at the versions recorded in the lockfile. This is by design. Nox sessions are for isolated, repeatable, dedicated checks. That's what makes them different from a development environment like the one Poetry sets up for you, where you do want everything installed for convenience (and an editable install of your own package, so you see changes immediately). |
To expand on this, So you need to install these dependencies explicitly: nox-poetry is very much about development dependencies. It makes sure that you can manage these tools in Poetry, and the Nox sessions will use the expected version. If you really want to install every development dependency in a Nox session, use Poetry as an external command, as shown above in the second example. |
Got it, thanks! |
A little hacky, but I think I have a better way. nox-poetry creates requirements.txt at a predictable location which contains all the dev dependencies, so rather than calling poetry externally, we can pip -r install that
I think there is support in Poetry for having other dependency groups beyond just dev and "normal" so this would probably include those too - haven't tried |
Help me understand, why don't you want to invoke Poetry directly to install development dependencies? The location of the generated requirements file is an implementation detail. For example, this location would change when #350 is implemented. |
That's good to know - so not an ideal solution. Perhaps nox-poetry could provide There's no hugely compelling reasoning. This makes pip install everything, instead of a mix of pip when you use Why does nox provide What might be nice as an alternative/addition is if nox-poetry provided a |
You can use session.poetry.export_requirements. While this function is (historically) part of the public API, let me explain why you may not want to use it (and why we should really deprecate this function). The requirements file returned by this function is no longer one-to-one what you get from
I understand how this seems preferable, but the transformation from Poetry's dependency information to something that pip understands is (alas) not lossless. For example, we had to drop hashes from the export, and that's not the only thing. So if you can use Poetry directly, you should. The main use case where you can't (yet) use Poetry directly is when you want specific development dependencies installed. With Nox you generally create a lot of environments for different Python versions. Being able to install only the dependencies you actually need is nice both for efficiency and isolation. And that's essentially why nox-poetry exists. Maybe this will change when Poetry's dependency groups become a thing (#481).
I'm not sure I understand what you're getting at here. Yes, the
But nox-poetry does not use Poetry as an installer. When you invoke The If you want to use both installation methods (plain nox vs nox-poetry), that is already possible: import nox
import nox_poetry
@nox.session
def test(session):
session.install("foo") # use plain pip
nox_poetry.Session(session).install("foo") # use pip with constraints |
Thanks for the clear answer, if nothing else, I've learned something today. I guess the fundamental difference is we want to use an "external" Poetry, but "per-venv" pip It still makes some sense to me to have an abstraction wrapped around Poetry with the units Poetry understands (dependencies, dev-dependencies, groups(?) etc), in the same way that a wrapper around pip understands package names, but I guess it boils down to little more than a trivial convenience wrapper if I follow your comments above correctly. It would enable handling, to take an absurd case, things like, if the command |
There's sometimes confusion why
session.install
does not get the development dependencies installed. The documentation could be clearer here.The text was updated successfully, but these errors were encountered: