Makefile 4.76 KB
Newer Older
1
2
3
4
5
BIN_PATH ?= ${HOME}/.local/bin
INSTALL_PREFIX ?= ${HOME}/.local
EXAMPLES_PATH ?= ${HOME}/nni/examples
WHOAMI := $(shell whoami)
YARN := $(INSTALL_PREFIX)/yarn/bin/yarn
6
7
8
9
ifndef TRAVIS
PIP_MODE ?= --user
endif
.PHONY: build install uninstall dev-install
Deshui Yu's avatar
Deshui Yu committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

build:
	### Building NNI Manager ###
	cd src/nni_manager && yarn && yarn build
	
	### Building Web UI ###
	cd src/webui && yarn && yarn build
	
	### Building Python SDK ###
	cd src/sdk/pynni && python3 setup.py build
	
	### Building nnictl ###
	cd tools && python3 setup.py build


install:
26
27
28
29
30
31
32
33
34
35
    ifneq ('$(HOME)', '/root')
        ifeq (${WHOAMI}, root)
			### Sorry, sudo make install is not supported ###
			exit 1
        endif
    endif

	mkdir -p $(BIN_PATH)
	mkdir -p $(INSTALL_PREFIX)/nni
	mkdir -p $(EXAMPLES_PATH)
Deshui Yu's avatar
Deshui Yu committed
36
37
	
	### Installing NNI Manager ###
38
39
	cp -rT src/nni_manager/dist $(INSTALL_PREFIX)/nni/nni_manager
	cp -rT src/nni_manager/node_modules $(INSTALL_PREFIX)/nni/nni_manager/node_modules
Deshui Yu's avatar
Deshui Yu committed
40
41
	
	### Installing Web UI ###
42
43
	cp -rT src/webui/build $(INSTALL_PREFIX)/nni/webui
	ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules/serve/bin/serve.js $(BIN_PATH)/serve
Deshui Yu's avatar
Deshui Yu committed
44
45
	
	### Installing Python SDK dependencies ###
46
	pip3 install $(PIP_MODE) -r src/sdk/pynni/requirements.txt
Deshui Yu's avatar
Deshui Yu committed
47
	### Installing Python SDK ###
48
	cd src/sdk/pynni && python3 setup.py install $(PIP_MODE)
Deshui Yu's avatar
Deshui Yu committed
49
50
	
	### Installing nnictl ###
51
	cd tools && python3 setup.py install $(PIP_MODE)
Deshui Yu's avatar
Deshui Yu committed
52
	
53
	echo '#!/bin/sh' > $(BIN_PATH)/nnimanager
54
	echo 'cd $(INSTALL_PREFIX)/nni/nni_manager && node main.js $$@' >> $(BIN_PATH)/nnimanager
55
	chmod +x $(BIN_PATH)/nnimanager
Deshui Yu's avatar
Deshui Yu committed
56
	
57
58
59
	echo '#!/bin/sh' > $(BIN_PATH)/nnictl
	echo 'NNI_MANAGER=$(BIN_PATH)/nnimanager WEB_UI_FOLDER=$(INSTALL_PREFIX)/nni/webui python3 -m nnicmd.nnictl $$@' >> $(BIN_PATH)/nnictl
	chmod +x $(BIN_PATH)/nnictl
Deshui Yu's avatar
Deshui Yu committed
60
61
	
	### Installing examples ###
62
63
64
65
66
67
	cp -rT examples $(EXAMPLES_PATH)


pip-install:
    ifneq ('$(HOME)', '/root')
        ifeq (${WHOAMI}, root)
68
			### Sorry, sudo pip install is not supported ###
69
70
71
72
73
74
75
76
77
78
79
80
81
82
			exit 1
        endif
    endif

	### Prepare Node.js ###
	wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz
	tar xf node-v10.9.0-linux-x64.tar.xz
	cp -rT node-v10.9.0-linux-x64 $(INSTALL_PREFIX)/node
	
	### Prepare Yarn 1.9.4 ###
	wget https://github.com/yarnpkg/yarn/releases/download/v1.9.4/yarn-v1.9.4.tar.gz
	tar xf yarn-v1.9.4.tar.gz
	cp -rT yarn-v1.9.4 $(INSTALL_PREFIX)/yarn

Deshui Yu's avatar
Deshui Yu committed
83
84
	### Export PATH for node and yarn, and build NNI Manager ###
	export PATH=$(INSTALL_PREFIX)/node/bin:$(INSTALL_PREFIX)/yarn/bin:$(PATH) && cd src/nni_manager && $(YARN) && $(YARN) build
85

86
	### Building Web UI ###
Deshui Yu's avatar
Deshui Yu committed
87
	export PATH=$(INSTALL_PREFIX)/node/bin:$(INSTALL_PREFIX)/yarn/bin:$(PATH) && cd src/webui && $(YARN) && $(YARN) build
88
89
90
	
	mkdir -p $(BIN_PATH)
	mkdir -p $(INSTALL_PREFIX)/nni
Deshui Yu's avatar
Deshui Yu committed
91
	mkdir -p $(EXAMPLES_PATH)
92
93
94
95
	
	### Installing NNI Manager ###
	cp -rT src/nni_manager/dist $(INSTALL_PREFIX)/nni/nni_manager
	cp -rT src/nni_manager/node_modules $(INSTALL_PREFIX)/nni/nni_manager/node_modules
Crysple's avatar
Crysple committed
96

97
98
99
100
	echo '#!/bin/sh' > $(BIN_PATH)/nnimanager
	echo 'cd $(INSTALL_PREFIX)/nni/nni_manager && node main.js $$@' >> $(BIN_PATH)/nnimanager
	chmod +x $(BIN_PATH)/nnimanager

Crysple's avatar
Crysple committed
101
102
103
104
	echo '#!/bin/sh' > $(BIN_PATH)/nnictl
	echo 'NNI_MANAGER=$(BIN_PATH)/nnimanager WEB_UI_FOLDER=$(INSTALL_PREFIX)/nni/webui python3 -m nnicmd.nnictl $$@' >> $(BIN_PATH)/nnictl
	chmod +x $(BIN_PATH)/nnictl

105
106
107
108
109
110
	### Installing Web UI ###
	cp -rT src/webui/build $(INSTALL_PREFIX)/nni/webui
	ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules/serve/bin/serve.js $(BIN_PATH)/serve
	
	### Installing examples ###
	cp -rT examples $(EXAMPLES_PATH)
Deshui Yu's avatar
Deshui Yu committed
111
112
113


dev-install:
114
115
116
117
118
119
120
121
122
123
124
	mkdir -p $(BIN_PATH)
	mkdir -p $(INSTALL_PREFIX)/nni
	
	### Installing NNI Manager ###
	ln -sf $(INSTALL_PREFIX)/nni/nni_manager $(PWD)/src/nni_manager/dist
	ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules $(PWD)/src/nni_manager/node_modules
	
	### Installing Web UI ###
	ln -sf $(INSTALL_PREFIX)/nni/webui $(PWD)/src/webui
	ln -sf $(INSTALL_PREFIX)/nni/nni_manager/node_modules/serve/bin/serve.js $(BIN_PATH)/serve
	
Deshui Yu's avatar
Deshui Yu committed
125
	### Installing Python SDK dependencies ###
126
	pip3 install $(PIP_MODE) -r src/sdk/pynni/requirements.txt
Deshui Yu's avatar
Deshui Yu committed
127
	### Installing Python SDK ###
128
	cd src/sdk/pynni && pip3 install $(PIP_MODE) -e .
Deshui Yu's avatar
Deshui Yu committed
129
130
	
	### Installing nnictl ###
131
132
133
134
135
136
137
138
139
140
141
142
	cd tools && pip3 install $(PIP_MODE) -e .
	
	echo '#!/bin/sh' > $(BIN_PATH)/nnimanager
	echo 'cd $(INSTALL_PREFIX)/nni/nni_manager && node main.js $$@' >> $(BIN_PATH)/nnimanager
	chmod +x $(BIN_PATH)/nnimanager
	
	echo '#!/bin/sh' > $(BIN_PATH)/nnictl
	echo 'NNI_MANAGER=$(BIN_PATH)/nnimanager python3 -m nnicmd.nnictl $$@' >> $(BIN_PATH)/nnictl
	chmod +x $(BIN_PATH)/nnictl
	
	### Installing examples ###
	ln -sf $(EXAMPLES_PATH) $(PWD)/examples
Deshui Yu's avatar
Deshui Yu committed
143
144
145
146


uninstall:
	-pip3 uninstall -y nni
147
148
149
	-pip3 uninstall -y nnictl
	-rm -r $(INSTALL_PREFIX)/nni
	-rm -r $(EXAMPLES_PATH)
150
	-rm $(BIN_PATH)/serve
151
152
	-rm $(BIN_PATH)/nnimanager
	-rm $(BIN_PATH)/nnictl