Member-only story
Python HOW: Create a Local pre-commit Hook for Conda
But why?
In short, so you don’t have to remember to do this every single time after installing/updating a package!
You do do this, right, right? 🧐
But how?
By using the pre-commit framework. Unfortunately, however, there isn’t a pre-defined hook by conda to do this easily. Instead, we will define a local hook that runs a local python script that generates environment.yaml
!
1. Define target environment name 🎯
We will define the target environment name in the pyproject.toml
. If you are not sure what a pyproject.toml
file is, check Brett Cannon’s article “What the heck is pyproject.toml
?” 🔗:
“a standard file that…all projects should (eventually) have … development tools realized they … could put their own configuration”