Commit 7d69e3d5 authored by Yan Ni's avatar Yan Ni Committed by fishyds
Browse files

update makefile & doc for pypi & installation (#440)

* update pypi/makefile for multiple platform support

* update linux os spec

* udpate doc for installation & pypi

* update readme
parent 8f06383f
...@@ -27,14 +27,14 @@ The tool dispatches and runs trial jobs generated by tuning algorithms to search ...@@ -27,14 +27,14 @@ The tool dispatches and runs trial jobs generated by tuning algorithms to search
## **Install & Verify** ## **Install & Verify**
**Install through pip** **Install through pip**
* We only support Linux in current stage, Ubuntu 16.04 or higher are tested and supported. Simply run the following `pip install` in an environment that has `python >= 3.5`. * We support Linux and MacOS in current stage, Ubuntu 16.04 or higher, along with macOS 10.14.1 are tested and supported. Simply run the following `pip install` in an environment that has `python >= 3.5`.
```bash ```bash
python3 -m pip install --user --upgrade nni python3 -m pip install --user --upgrade nni
``` ```
Note: If you are in docker container (as root), please remove `--user` from the installation command. Note: If you are in docker container (as root), please remove `--user` from the installation command.
**Install through source code** **Install through source code**
* We only support Linux (Ubuntu 16.04 or higher) in our current stage. * We support Linux (Ubuntu 16.04 or higher), macOS (10.14.1) in our current stage.
* Run the following commands in an environment that has `python >= 3.5`, `git` and `wget`. * Run the following commands in an environment that has `python >= 3.5`, `git` and `wget`.
```bash ```bash
git clone -b v0.4 https://github.com/Microsoft/nni.git git clone -b v0.4 https://github.com/Microsoft/nni.git
......
CWD := $(PWD)/ CWD := $(PWD)/
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
OS_SPEC := linux
WHEEL_SPEC := manylinux1_x86_64
else ifeq ($(UNAME_S), Darwin)
OS_SPEC := darwin
WHEEL_SPEC := macosx_10_9_x86_64
else
$(error platform $(UNAME_S) not supported)
endif
.PHONY: build .PHONY: build
build: build:
python3 -m pip install --user --upgrade setuptools wheel python3 -m pip install --user --upgrade setuptools wheel
wget https://aka.ms/nodejs-download -O $(CWD)node-linux-x64.tar.xz wget https://aka.ms/nni/nodejs-download/$(OS_SPEC) -O $(CWD)node-$(OS_SPEC)-x64.tar.xz
rm -rf $(CWD)node-linux-x64 rm -rf $(CWD)node-$(OS_SPEC)-x64
mkdir $(CWD)node-linux-x64 mkdir $(CWD)node-$(OS_SPEC)-x64
tar xf $(CWD)node-linux-x64.tar.xz -C node-linux-x64 --strip-components 1 tar xf $(CWD)node-$(OS_SPEC)-x64.tar.xz -C node-$(OS_SPEC)-x64 --strip-components 1
cd $(CWD)../../src/nni_manager && yarn && yarn build cd $(CWD)../../src/nni_manager && yarn && yarn build
cd $(CWD)../../src/webui && yarn && yarn build cd $(CWD)../../src/webui && yarn && yarn build
rm -rf $(CWD)nni rm -rf $(CWD)nni
...@@ -14,7 +25,7 @@ build: ...@@ -14,7 +25,7 @@ build:
cp -r $(CWD)../../src/webui/build $(CWD)nni/static cp -r $(CWD)../../src/webui/build $(CWD)nni/static
cp $(CWD)../../src/nni_manager/package.json $(CWD)nni cp $(CWD)../../src/nni_manager/package.json $(CWD)nni
cd $(CWD)nni && yarn --prod cd $(CWD)nni && yarn --prod
cd $(CWD) && python3 setup.py bdist_wheel cd $(CWD) && python3 setup.py bdist_wheel -p $(WHEEL_SPEC)
cd $(CWD)../../src/sdk/pynni && python3 setup.py bdist_wheel cd $(CWD)../../src/sdk/pynni && python3 setup.py bdist_wheel
cp -r $(CWD)../../src/sdk/pynni/dist/*.whl $(CWD)dist cp -r $(CWD)../../src/sdk/pynni/dist/*.whl $(CWD)dist
cd $(CWD) cd $(CWD)
...@@ -22,4 +33,13 @@ build: ...@@ -22,4 +33,13 @@ build:
.PHONY: upload .PHONY: upload
upload: upload:
python3 -m pip install --user --upgrade twine python3 -m pip install --user --upgrade twine
python3 -m twine upload dist/* python3 -m twine upload dist/*
\ No newline at end of file
.PHONY: clean
clean:
-rm -rf $(CWD)../../src/sdk/pynni/dist/*.whl
-rm -rf $(CWD)build
-rm -rf $(CWD)dist
-rm -rf $(CWD)nni
-rm -rf $(CWD)nni.egg-info
-rm -rf $(CWD)node-$(OS_SPEC)-x64
\ No newline at end of file
...@@ -22,6 +22,14 @@ make ...@@ -22,6 +22,14 @@ make
``` ```
## 3.How to upload ## 3.How to upload
### upload for testing
```bash
TWINE_REPOSITORY_URL=https://test.pypi.org/legacy/ make upload
```
You may need to input the account and password of https://test.pypi.org during this process.
### upload for release
```bash ```bash
make upload make upload
``` ```
......
import setuptools import setuptools
import platform
from os import walk, path from os import walk, path
data_files = [('bin', ['node-linux-x64/bin/node'])] os_type = platform.system()
if os_type == 'Linux':
os_name = 'POSIX :: Linux'
elif os_type == 'Darwin':
os_name = 'MacOS'
else:
raise NotImplementedError('current platform {} not supported'.format(os_type))
data_files = [('bin', ['node-{}-x64/bin/node'.format(os_type.lower())])]
for (dirpath, dirnames, filenames) in walk('./nni'): for (dirpath, dirnames, filenames) in walk('./nni'):
files = [path.normpath(path.join(dirpath, filename)) for filename in filenames] files = [path.normpath(path.join(dirpath, filename)) for filename in filenames]
data_files.append((path.normpath(dirpath), files)) data_files.append((path.normpath(dirpath), files))
...@@ -38,7 +47,7 @@ setuptools.setup( ...@@ -38,7 +47,7 @@ setuptools.setup(
classifiers = [ classifiers = [
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License', 'License :: OSI Approved :: MIT License',
'Operating System :: POSIX :: Linux' 'Operating System :: ' + os_name
], ],
data_files = data_files, data_files = data_files,
entry_points = { entry_points = {
......
**Install NNI on Ubuntu** **Installation of NNI**
=== ===
Currently we only support installation on Linux & Mac.
## **Installation** ## **Installation**
* __Dependencies__ * __Dependencies__
...@@ -8,7 +10,7 @@ ...@@ -8,7 +10,7 @@
git git
wget wget
python pip should also be correctly installed. You could use "python3 -m pip -v" to check in Linux. python pip should also be correctly installed. You could use "python3 -m pip -v" to check pip version.
* __Install NNI through pip__ * __Install NNI through pip__
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment