Skip to content

Commit 1caa67b

Browse files
authored
Detect conda and support conda envs; tweaks for vanilla virtualenv (drivendataorg#51)
* OSX Junk in gitignore * Support conda envs by default * Make it run on vanilla Ubuntu
1 parent 947a36a commit 1caa67b

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
docs/site/
2+
3+
# OSX Junk
4+
.DS_Store

{{ cookiecutter.repo_name }}/Makefile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
BUCKET = {{ cookiecutter.s3_bucket }}
88
PROJECT_NAME = {{ cookiecutter.repo_name }}
99
PYTHON_INTERPRETER = {{ cookiecutter.python_interpreter }}
10+
IS_ANACONDA=$(shell python -c "import sys;t=str('anaconda' in sys.version.lower() or 'continuum' in sys.version.lower());sys.stdout.write(t)")
1011

1112
#################################################################################
1213
# COMMANDS #
@@ -38,12 +39,21 @@ sync_data_from_s3:
3839

3940
## Set up python interpreter environment
4041
create_environment:
41-
@pip install -q virtualenvwrapper
42+
ifeq (True,$(IS_ANACONDA))
43+
@echo ">>> Detected Anaconda, creating conda environment."
44+
ifeq (3,$(findstr 3,$(PYTHON_INTERPRETER)))
45+
conda create --name $(PROJECT_NAME) python=3.5
46+
else
47+
conda create --name $(PROJECT_NAME) python=2.7
48+
endif
49+
@echo ">>> New conda env created. Activate with:\nsource activate $(PROJECT_NAME)"
50+
else
51+
@pip install -q virtualenv virtualenvwrapper
4252
@echo ">>> Installing virtualenvwrapper if not already intalled.\nMake sure the following lines are in shell startup file\n\
43-
export WORKON_HOME=$HOME/.virtualenvs\nexport PROJECT_HOME=$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n"
44-
45-
source /usr/local/bin/virtualenvwrapper.sh; mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)
53+
export WORKON_HOME=$$HOME/.virtualenvs\nexport PROJECT_HOME=$$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n"
54+
@bash -c "source `which virtualenvwrapper.sh`;mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)"
4655
@echo ">>> New virtualenv created. Activate with:\nworkon $(PROJECT_NAME)"
56+
endif
4757

4858
## Test python environment is setup correctly
4959
test_environment:
@@ -114,4 +124,4 @@ show-help:
114124
} \
115125
printf "\n"; \
116126
}' \
117-
| more $(shell test $(shell uname) == Darwin && echo '--no-init --raw-control-chars')
127+
| more $(shell test $(shell uname) == Darwin && echo '--no-init --raw-control-chars')

0 commit comments

Comments
 (0)