hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Changing dev-mode is not reflected in existing envs

Open hynek opened this issue 2 years ago • 5 comments

While doing my experiments and realizing what editable installs mean in this context, I've set dev-mode = false and was surprised that coverage still worked.

Running hatch env prune and re-running breaks coverage report as expected.

hynek avatar Jan 03 '23 10:01 hynek

#771 has a similar discussion. It seems like hatch's approach is not to reinstall a project after an environment is created?

wshanks avatar May 18 '23 19:05 wshanks

Doesn’t seem like intended behavior. In non-dev-mode, Hatch should reinstall the project on every hatch [env] run

flying-sheep avatar Mar 04 '24 08:03 flying-sheep

I do not see it spelled out in the documentation but Hatch errs on the side of not reinstalling the distribution or recreating the environment. For example, even with dev-mode = true, when you remove something from project.dependencies, Hatch does not recreate the environment or otherwise try to remove the now extraneous dependency. Similarly, it does not reinstall the distribution when project.scripts is modified (reported in https://github.com/pypa/hatch/issues/771). One could imagine Hatch recreating an environment when project.dependencies or project.scripts (or other metadata) is modified. Likewise, it seems like dev-mode = false installs the project once and leaves it rather than reinstalling every time (like tox does). Maybe a plugin could provide the alternate behavior of reflecting pyproject.toml more closely at the expense of more environment rebuilds.

wshanks avatar Mar 04 '24 20:03 wshanks

I think a rebuild of the whole environment isn‘t as important as reflecting the current state of the project, so a setting to reinstall the current version of a project on each run would be nice. (For editable projects, this should be even faster and only update the metadata)

Eventually, even rebuilding the env will no longer be a question: uv, with a warm cache, resolves deps in <10ms and installs hundreds of megabytes in <300ms.

So I think once Hatch has lockfiles and uses uv, we can just sync deps and install the project on each hatch run by default.

flying-sheep avatar Mar 05 '24 08:03 flying-sheep

This will be fixed and yes UV will improve things when I add that.

ofek avatar Mar 05 '24 13:03 ofek