Add flag for fresh Environment
Description
Currently, the environment is reused between runs. What I want is a flag that uses its own fresh environment for each specific run.
Use case/motivation
dev-mode = false installs the project as non-editable whl mode, so when you do update the project code, the environment doesn't pick it up, and we need to first hatch env remove [environment-name] then run the code.
If we had a flag for fresh env, that would go well with dev-mode = false
Related issues
https://github.com/pypa/hatch/issues/2134#issuecomment-3622375564 Another way to approach this problem is by checking if the project whl needs to be reinstalled (uninstalled then installed) This requires
- Check the src dir for changes
- Check BuildHook for changes
- Check MetadataHook for changes If yes, reinstall!
This is actually more performant than having to recreate the whole environment. But I figure it'd be harder to implement.
Thus, a clean-env flag for now would do, as it only requires making a time-based hashed env for each session.
Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow the Python Software Foundation's Code of Conduct
We can certainly have a discussion around having a sync command. But for the following "Another way to approach this problem is by checking if the project whl needs to be reinstalled (uninstalled then installed)" along with "Check the src dir for changes" This is what dev-mode being true is for to have an editable install of your project in an environment which already handles changes in source code. It would be helpful to maybe have you lay out more of the use case where reinstalling the the project whl is needed in terms of the problem space you are trying to solve for.
editable install means the project is not installed from whl; instead, the project dir is directly linked.
With dev-mode = false, the project is installed from whl. This is useful because we can test the exact case the way the user is consuming the package, ie, installing the whl.
Now, what's the problem with the current dev-mode = false? You need to remove the test env first to test after each edit.
Your question is "why you're not removing it, since you don't like how dev-mode = false works?"
Again, I'm using dev-mode = false because I want the package to be installed as whl, ie, not directly linked.
But that doesn't mean I want to keep the old version installed even after editing or deleting the environment after each edit.
Now, If you're asking why project whl install can be better than editable install,
It's because if I download external assets in BuildHook you won't find them in editable install, as I'm keeping the project src dir clean, ie, not polluting src by downloading directly in it.
I can download it outside and link it with build_data["force_include"]
So, when installed as whl it works, but direct project linking fails to find the downloaded file.