pytest githook on Windows with Anaconda

  anaconda3, git, githooks, python, windows

I have the following setup:

  • Windows 10
  • python installed via Anaconda
  • Virtual environment setup via Anaconda for running and testing my project with pytest
  • git version control via MINGW

Now I’d like to set a githook that runs all my tests before I push. I have the following problem: I can’t activate my virtual environment within the githook.

I tried to activate my anaconda env in the githook script but I can’t get it to work. activate as command is not available and calling the whole path ../Anaconda3/Scripts/activate.bat does nothing.

I also tried to use python-githooks to configure the hook for me, but this doesn’t seem to work in Windows (it can’t read PWD from the environment…)

I’m gratefull for any suggestions.

Source: StackOverflow

LEAVE A COMMENT