mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Add a dev dependency group

Open cbrnr opened this issue 6 months ago • 8 comments

Add a dev dependency group so that uv sync automatically installs these dependencies.

cbrnr avatar May 27 '25 07:05 cbrnr

When I tried this a couple of months ago, pip did not yet understand dep groups. Is this resolved now?

Also, why just dev – anything we don't want to expose in the distribution should be a dep group, including doc, no? And the extras with that name should be nixed.

If this is not possible yet (e.g. due to missing pip support), I'd be -1 on this as it would add duplications Unless we drop pip and go full-on uv (which IMHO is the way to go anyway, but …)

hoechenberger avatar May 27 '25 07:05 hoechenberger

When I tried this a couple of months ago, pip did not yet understand dep groups. Is this resolved now?

I don't know. This change is to improve the workflow with uv.

Also, why just dev – anything we don't want to expose in the distribution should be a dep group, including doc, no?

Because dev is special because it is the default dependency group, meaning that uv sync will automatically install it.

And the extras with that name should be nixed.

This can be done later, it does not hurt to have both variants at the same time for a transition period.

If this is not possible yet (e.g. due to missing pip support), I'd be -1 on this as it would add duplications Unless we drop pip and go full-on uv (which IMHO is the way to go anyway, but …)

I don't think that's necessary, I just wanted to make life easier for uv users.

cbrnr avatar May 27 '25 08:05 cbrnr

Got you. Perhaps we should combine this with an update of our contribution docs? Do you think we should ship a lock file, too? (probably not, since we're not an app)

Lastly, the syncing of dev by default, do you know if this is bound to stay or if there's discussions about changing this? To me, it's a bit unexpected behavior tbh (even though I appreciate it)

hoechenberger avatar May 27 '25 09:05 hoechenberger

Got you. Perhaps we should combine this with an update of our contribution docs?

Sure, but we could also wait until we support uv more prominently. This is just a small quality of life change that I'd like to have rather sooner than later, so it does not have to be documented right now.

Do you think we should ship a lock file, too? (probably not, since we're not an app)

No, I wouldn't do that exactly for this reason.

Lastly, the syncing of dev by default, do you know if this is bound to stay or if there's discussions about changing this? To me, it's a bit unexpected behavior tbh (even though I appreciate it)

It's here to stay I think: https://docs.astral.sh/uv/concepts/projects/dependencies/#default-groups

cbrnr avatar May 27 '25 09:05 cbrnr

Ok, you convinced me, all green from my end, then. Happy to keep PySide6 too, until we run into issues – won't be user-facing, so we can change this whenever we feel we need to.

hoechenberger avatar May 27 '25 09:05 hoechenberger

it might hurt to have both variants at the same time (emphasis added):

Tools MAY choose to provide the same or similar interfaces for interacting with Dependency Groups as they do for managing extras. Tools authors are advised that the specification does not forbid having an extra whose name matches a Dependency Group. Separately, users are advised to avoid creating Dependency Groups whose names match extras, and tools MAY treat such matching as an error.

Regarding this point, can someone check how pip, pixi, and uv each handle the case where a dependency group name exactly matches an extras name? If those three all handle it the same way (and it's not "raise an error") then I'd feel fine moving forward with this duplication of dev.

Failing that: we could consider skipping/shortening the deprecation period for the dev extras, since it's not exactly user-facing (set of people impacted by it should be much smaller than "our whole user base")

drammock avatar Jun 06 '25 21:06 drammock

This works with uv and pip (which does not support dependency groups at all). I have not tested with pixi since I don't use it.

cbrnr avatar Jun 08 '25 15:06 cbrnr

I haven't followed lately the addition to MNE, so some of the information below might be outdated. That said, you can use the default dev as a "for everything" group, or you can split it in doc, test, similarly to the current extras (as @hoechenberger initially mentioned). In this case, you can add:

[tool.uv]
default-groups = "all"

To the pyproject.toml and uv sync will sync everything (the default is dev which is why you get that default behavior). Ideally, anything which does not need to be installed by the user (which is not an extra) should be defined within those groups.

Caveat on the sys_info utility which will probably need to be adapted (at least once the extras are removed). The dependency groups are intentionally omitted from metadata, so you'll have to parse them from the pyproject.toml file directly. My Python template has a similar utility (inspired from MNE) which I've already updated for that usecase: https://github.com/mscheltienne/template-python/blob/main/template/utils/config.py

mscheltienne avatar Jun 13 '25 14:06 mscheltienne

superseded by #13452

drammock avatar Oct 27 '25 16:10 drammock