From 1caa67be438fec5a177e158d56bedade0854faff Mon Sep 17 00:00:00 2001 From: Peter Bull Date: Sun, 16 Oct 2016 10:01:37 -0400 Subject: [PATCH] Detect conda and support conda envs; tweaks for vanilla virtualenv (#51) * OSX Junk in gitignore * Support conda envs by default * Make it run on vanilla Ubuntu --- .gitignore | 3 +++ {{ cookiecutter.repo_name }}/Makefile | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 0012cf8..a1ea213 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ docs/site/ + +# OSX Junk +.DS_Store diff --git a/{{ cookiecutter.repo_name }}/Makefile b/{{ cookiecutter.repo_name }}/Makefile index bef8958..61871ec 100644 --- a/{{ cookiecutter.repo_name }}/Makefile +++ b/{{ cookiecutter.repo_name }}/Makefile @@ -7,6 +7,7 @@ BUCKET = {{ cookiecutter.s3_bucket }} PROJECT_NAME = {{ cookiecutter.repo_name }} PYTHON_INTERPRETER = {{ cookiecutter.python_interpreter }} +IS_ANACONDA=$(shell python -c "import sys;t=str('anaconda' in sys.version.lower() or 'continuum' in sys.version.lower());sys.stdout.write(t)") ################################################################################# # COMMANDS # @@ -38,12 +39,21 @@ sync_data_from_s3: ## Set up python interpreter environment create_environment: - @pip install -q virtualenvwrapper +ifeq (True,$(IS_ANACONDA)) + @echo ">>> Detected Anaconda, creating conda environment." +ifeq (3,$(findstr 3,$(PYTHON_INTERPRETER))) + conda create --name $(PROJECT_NAME) python=3.5 +else + conda create --name $(PROJECT_NAME) python=2.7 +endif + @echo ">>> New conda env created. Activate with:\nsource activate $(PROJECT_NAME)" +else + @pip install -q virtualenv virtualenvwrapper @echo ">>> Installing virtualenvwrapper if not already intalled.\nMake sure the following lines are in shell startup file\n\ - export WORKON_HOME=$HOME/.virtualenvs\nexport PROJECT_HOME=$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n" - - source /usr/local/bin/virtualenvwrapper.sh; mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER) + export WORKON_HOME=$$HOME/.virtualenvs\nexport PROJECT_HOME=$$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n" + @bash -c "source `which virtualenvwrapper.sh`;mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)" @echo ">>> New virtualenv created. Activate with:\nworkon $(PROJECT_NAME)" +endif ## Test python environment is setup correctly test_environment: @@ -114,4 +124,4 @@ show-help: } \ printf "\n"; \ }' \ - | more $(shell test $(shell uname) == Darwin && echo '--no-init --raw-control-chars') \ No newline at end of file + | more $(shell test $(shell uname) == Darwin && echo '--no-init --raw-control-chars')