I'm trying to create a make.bat file with functionality similar to a Makefile on a *nix system as part of a cookiecutter project template. The challenge is in figuring out a way to be able to activate a conda environment and have this environment still active when control is passed back to the command prompt.
Here is what the make.bat file looks like. Also, in case you are paying attention, the activate and deactivate commands are not prefixed with source or conda due to the Windows environment.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: VARIABLES :
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SETLOCAL
SET PROJECT_DIR=%cd%
SET PROJECT_NAME="00_test"
SET ENV_NAME=00_test
SET CONDA_PARENT=arcgispro-py3
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: COMMANDS :
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Jump to command
GOTO %1
:data
CALL activate %ENV_NAME%
CALL python src/data/make_dataset.py
ECHO ">>> Data processed."
EXIT /B
:: Export the current environment
:env_export
CALL conda env export --name %ENV_NAME% > environment.yml
ECHO ">>> %PROJECT_NAME% conda environment exported to ./environment.yml"
EXIT /B
:: Build the local environment from the environment file
:env
:: Run this from the ArcGIS Python Command Prompt
:: Clone and activate the new environment
CALL conda create --name %ENV_NAME% --clone %CONDA_PARENT%
CALL activate %ENV_NAME%
:: Install additional packages
CALL conda env update -f environment.yml
:: Additional steps for the map widget to work in Jupyter Lab
CALL jupyter labextension install @jupyter-widgets/jupyterlab-manager -y
CALL jupyter labextension install arcgis-map-ipywidget@1.7.0 -y
EXIT /B
:: Activate the environment
:env_activate
CALL activate %ENV_NAME%
EXIT /B
EXIT /B
I want to simply be able to type...
> make env_activate
...and have the command prompt activate the environment so I can continue working using the project conda environment.
As you can see in the screenshot, while the environment is getting activated, it is not persisting once back at the command prompt.
Any help with this is greatly appreciated. This has been driving me crazy for a long time.