From 901038bed553a38cd52a6fd78caf687fc9383d49 Mon Sep 17 00:00:00 2001
From: Jeff Stout <stoutjd@nih.gov>
Date: Thu, 9 May 2024 17:16:22 -0400
Subject: [PATCH] WIP - fix install env

---
 .github/workflows/nih2mne-actions.yml |  2 ++
 makefile                              | 38 +++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 makefile

diff --git a/.github/workflows/nih2mne-actions.yml b/.github/workflows/nih2mne-actions.yml
index 78677c2..f010e49 100755
--- a/.github/workflows/nih2mne-actions.yml
+++ b/.github/workflows/nih2mne-actions.yml
@@ -17,6 +17,8 @@ jobs:
           path: ~/FSData
           key:
             FSData.tar.gz
+      - name: Install conda env
+        run: cd nih_to_mne; make install_headless_env
       - if: ${{ steps.cache-fsdownload.outputs.cache-hit != 'true' }}
         run: pip install gdown; gdown --folder ${{ secrets.GDRIVE_MRI }} -O ~/FSData
       - name: Pytest
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..bb2cbd1
--- /dev/null
+++ b/makefile
@@ -0,0 +1,38 @@
+
+#>>>> https://stackoverflow.com/questions/53382383/makefile-cant-use-conda-activate
+# 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 
+# <<<<
+
+install_test:
+	#conda install --channel=conda-forge --name=base mamba -y
+	conda env remove -n nih2mne_test
+	mamba create --override-channels --channel=conda-forge --name=nih2mne_test "mne<3.12" "python<3.12" pip -y
+	($(CONDA_ACTIVATE) enigma_meg_test ; pip install -e .[testing]; pip install pytest pytest-reportlog )
+	git submodule init
+	git pull --recurse-submodules
+
+install_headless_env:
+	#conda install --channel=conda-forge --name=base mamba -y
+	conda env remove -n nih2mne_test
+	mamba create --override-channels --channel=conda-forge --name=nih2mne_test "mne<1.7" "python<3.12" pip "vtk>=9.2=*osmesa*" "mesalib=21.2.5" -y
+	($(CONDA_ACTIVATE) enigma_meg_test ; pip install -e .[testing]; pip install pytest pytest-reportlog )
+	git submodule init
+	git pull --recurse-submodules
+
+install_system_requirements:
+	dnf install Xvfb -y
+	dnf install git git-annex -y
+
+test:
+	($(CONDA_ACTIVATE) enigma_meg_test ; cd enigma_MEG; pytest -vv --report-log=/tmp/enigma_MEG_test_logfile.txt )  
+
+test_headless:
+	($(CONDA_ACTIVATE) enigma_meg_test ; cd enigma_MEG; xvfb-run -a pytest -vv --report-log=/tmp/enigma_MEG_test_logfile.txt )
+
+
+test_iterate_fs:
+	($(CONDA_ACTIVATE) enigma_meg_test ; cd enigma_MEG; pytest -vv --report-log=./test_logfile.txt )  #xvfb-run -a pytest -s )
+