OS _ makefile - dwisianto/dwisianto GitHub Wiki
Env Vars
- https://stackoverflow.com/questions/23843106/how-to-set-child-process-environment-variable-in-makefile
- https://stackoverflow.com/questions/23843106/how-to-set-child-process-environment-variable-in-makefile
Makefile Location
Makefile and Env Variables
Makefile and Anaconda
- https://blog.ianpreston.ca/posts/2020-05-13-conda_envs.html
- https://blog.ianpreston.ca/conda/python/bash/2020/05/13/conda_envs.html
- https://stackoverflow.com/questions/53382383/makefile-cant-use-conda-activate
# Oneshell means I can run multiple lines in a recipe in the same shell, so I don't have to
# chain commands together with semicolon
.ONESHELL:
# Need to specify bash in order for conda activate to work.
SHELL=/bin/bash
# Note that the extra activate is needed to ensure that the activate floats env to the front of PATH
CONDA_ACTIVATE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate
test:
$(CONDA_ACTIVATE) eg_env
echo $$(which python)
# format the file with black
lint:
$(CONDA_ACTIVATE) eg_env
black eg.py
# Run the file directly
run_py:
$(CONDA_ACTIVATE) eg_env
python eg.py
# Run the file from a shell script
run_sh:
$(CONDA_ACTIVATE) eg_env
bash eg.sh
eg_env.yml
name: eg_env
dependencies:
- numpy
- black
eg.sh
#!/bin/bash
echo "This is my test bash script"
echo "Activating conda environment"
eval "$($(which conda) 'shell.bash' 'hook')"
conda activate eg_env
echo "Running python script"
python eg.py