-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile.envs
More file actions
73 lines (65 loc) · 2.15 KB
/
Makefile.envs
File metadata and controls
73 lines (65 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#
# Environment Management Makefile
#
include Makefile.include
$(EASYDATA_LOCKFILE): environment.yml
ifeq (conda, $(VIRTUALENV))
$(CONDA_EXE) env update -n $(PROJECT_NAME) -f $<
$(CONDA_EXE) env export -n $(PROJECT_NAME) -f $@
# pip install -e . # uncomment for conda <= 4.3
else
$(error Unsupported Environment `$(VIRTUALENV)`. Use conda)
endif
.PHONY: create_environment
## Set up virtual (conda) environment for this project
create_environment: $(EASYDATA_LOCKFILE)
ifeq (conda,$(VIRTUALENV))
@rm -f $(EASYDATA_LOCKFILE)
@echo
@echo "New conda env created. Activate with:"
@echo ">>> conda activate $(PROJECT_NAME)"
@echo ">>> make update_environment"
ifneq ("X$(wildcard .post-create-environment.txt)","X")
@cat .post-create-environment.txt
endif
else
$(error Unsupported Environment `$(VIRTUALENV)`. Use conda)
endif
.PHONY: delete_environment
## Delete the virtual (conda) environment for this project
delete_environment:
ifeq (conda,$(VIRTUALENV))
@echo "Deleting conda environment."
$(CONDA_EXE) env remove -n $(PROJECT_NAME)
rm -f $(EASYDATA_LOCKFILE)
ifneq ("X$(wildcard .post-delete-environment.txt)","X")
@cat .post-delete-environment.txt
endif
else
$(error Unsupported Environment `$(VIRTUALENV)`. Use conda)
endif
.PHONY: update_environment
## Install or update Python Dependencies in the virtual (conda) environment
update_environment: environment_enabled $(EASYDATA_LOCKFILE)
ifneq ("X$(wildcard .post-update-environment.txt)","X")
@cat .post-update-environment.txt
endif
.PHONY: environment_enabled
# Checks that the conda environment is active
environment_enabled:
ifeq (conda,$(VIRTUALENV))
ifneq ($(notdir ${CONDA_DEFAULT_ENV}), $(PROJECT_NAME))
$(error Run "$(VIRTUALENV) activate $(PROJECT_NAME)" before proceeding...)
endif
else
$(error Unsupported Environment `$(VIRTUALENV)`. Use conda)
endif
.PHONY: check_lockfile
# Test that an environment lockfile exists
check_lockfile:
ifeq (X,X$(wildcard $(EASYDATA_LOCKFILE)))
$(error Run "make update_environment" before proceeding...)
endif
.PHONY: check_environment
## Check if environment is enabled and correctly configured
check_environment: environment_enabled check_lockfile $(EASYDATA_LOCKFILE)