# Some stuff to detect the OS for installing stuff
SHELL := /bin/sh
# 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

OS := $(shell uname)

all: init


init: init_repo create_env install_acdc install_hypo-initerp
	conda activate hypo-interp
	pip3 install -e .

init_repo:
	git submodule init
	git submodule update

create_env:
	conda env create -f environment.yml

install_acdc:
	#conda activate hypo-interp
	#conda install python=3.10
	@if [ "$(OS)" = "Linux" ]; then \
		sudo apt-get update && sudo apt-get install libgl1-mesa-glx graphviz build-essential graphviz-dev; \
	else \
		brew install graphviz; \
		export CFLAGS="-I$$(brew --prefix graphviz)/include"; \
		export LDFLAGS="-L$$(brew --prefix graphviz)/lib"; \
	fi
	(cd external/Automatic-Circuit-Discovery; poetry install)

# force
tests:
	python3 -m pytest -v tests

fast-tests:
	python3 -m pytest -v tests -m "not slow"

.PHONY: tests
