Here's what I'm currently doing. My Makefile looks like this:
. /home/me/miniconda3/etc/profile.d/conda.sh; \
conda activate my-env; \
python -m my.package.main
There are a few issues with this. First, the location of anaconda depends on the user. I can get around that with some effort, e.g.,
CONDA_ROOT := $(conda info --json -s | python -c "import sys, json; print(json.load(sys.stdin)['conda_prefix']);")
but that's pretty gnarly. In particular, it's not clear to me that this JSON parsing is a "stable" part of the Conda API, since it doesn't seem to be well-documented. Moreover, when you try to activate without the conda.sh script, the error is a little misleading:
Your shell has not been properly configured to use 'conda activate'.
Indeed, my .zshrc file had been configured with this line, but the Makefile doesn't use it. It's hard to track that down.