diff --git a/.circleci/config.yml b/.circleci/config.yml index c35b126..329408e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ tox_common: &tox_common steps: - checkout - restore_cache: - key: tox-deps2-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} + key: tox-deps3-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} - run: name: install dependencies command: pip install --user tox @@ -16,12 +16,13 @@ tox_common: &tox_common paths: - .tox - ./eggs - key: tox-deps2-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} + key: tox-deps3-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} orbs: win: circleci/windows@2.2.0 # The Windows orb give you everything you need to start using the Windows executor. jobs: + # Job(s) with Linux OS venv_build: docker: - image: circleci/python:3.8 @@ -29,12 +30,12 @@ jobs: steps: - checkout - restore_cache: - key: venv-deps1-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} + key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} - run: name: Install requirements in venv command: make venv_build_test - save_cache: - key: venv-deps1-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} + key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} paths: - ./venv venv_pytest: @@ -44,7 +45,7 @@ jobs: steps: - checkout - restore_cache: - key: venv-deps1-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} + key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} - run: name: Run tests with venv command: make venv_test @@ -60,7 +61,7 @@ jobs: steps: - checkout - restore_cache: - key: venv-deps1-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} + key: venv-deps2-{{ arch }}-{{ .Branch }}-{{ checksum "requirements.txt" }}-{{ checksum "requirements_test.txt" }}-{{ checksum "setup.py" }} - run: name: Run linter with venv command: make venv_lint @@ -76,7 +77,6 @@ jobs: - image: circleci/python:3.8 environment: TOXENV: py38-core - # Linux tox-py37-script: <<: *tox_common docker: @@ -89,7 +89,7 @@ jobs: - image: circleci/python:3.8 environment: TOXENV: py38-script - # Windows + # Job(s) with Windows OS win-py37-script: executor: name: win/default diff --git a/Makefile b/Makefile index e6377c2..3875ef1 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ clean: $(VENV_NAME)/bin/activate: requirements.txt @test -d $(VENV_NAME) || python3 -m venv --clear $(VENV_NAME) + ${VENV_NAME}/bin/python setup.py install ${VENV_NAME}/bin/python -m pip install -r requirements.txt ${VENV_NAME}/bin/python -m pip install -r requirements_test.txt @touch $(VENV_NAME)/bin/activate diff --git a/README.md b/README.md index eed6d38..1e2cbd0 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,101 @@ # eth2.0-deposit-cli + + +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* + +- [Tutorial for users](#tutorial-for-users) + - [Requirements](#requirements) + - [For Linux or MacOS users](#for-linux-or-macos-users) + - [Step 1. Install deposit-cli dependencies](#step-1-install-deposit-cli-dependencies) + - [Step 2. Create your keys and deposit data](#step-2-create-your-keys-and-deposit-data) + - [For Windows users](#for-windows-users) + - [Step 1. Install deposit-cli dependencies](#step-1-install-deposit-cli-dependencies-1) + - [Step 2. Create your keys and deposit data](#step-2-create-your-keys-and-deposit-data-1) + - [For `venv` users](#for-venv-users) +- [Development](#development) + - [Install basic requirements](#install-basic-requirements) + - [Install testing requirements](#install-testing-requirements) + - [Run tests](#run-tests) + + + ## Tutorial for users -### Create deposits +### Requirements + +- [Python **3.7+**](https://www.python.org/about/gettingstarted/) +- [pip3](https://pip.pypa.io/en/stable/installing/) + +### For Linux or MacOS users + +#### Step 1. Install deposit-cli dependencies + +If it's your first time to use this tool, you need to install the Python library dependencies: + +```sh +./deposit.sh install +``` + +#### Step 2. Create your keys and deposit data + +Run the following command: + +```sh +./deposit.sh +``` + +You can also run the tool with optional arguments: ```sh ./deposit.sh --num_validators= --mnemonic_language=english --password= --folder= ``` +### For Windows users + +#### Step 1. Install deposit-cli dependencies + +If it's your first time to use this tool, you need to install the Python library dependencies: + +```sh +sh deposit.sh install +``` + +#### Step 2. Create your keys and deposit data + +Run the following command: + +```sh +sh deposit.sh +``` + +You can also run the tool with optional arguments: + +```sh +sh deposit.sh --num_validators= --mnemonic_language=english --password= --folder= +``` + +You should see the following messages after successfully generated the keystore(s) and the deposit(s): + +``` +Creating your keys. +Saving your keystore(s). +Creating your deposit(s). +Verifying your keystore(s). +Verifying your deposit(s). + +Success! +Your keys can be found at: +``` + +### For `venv` users + +If you want to use Python [`venv`](https://docs.python.org/3.7/library/venv.html), just run: + +```sh +make venv_deposit +``` + ## Development ### Install basic requirements diff --git a/deposit.sh b/deposit.sh index 8d667d8..2d06649 100755 --- a/deposit.sh +++ b/deposit.sh @@ -1,30 +1,28 @@ #!/bin/bash -case "$(uname -s)" in +if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then + echo $OSTYPE - Darwin) - echo 'Mac OS X' - python3 -m pip install -r requirements.txt + if [[ $1 == install ]]; then + python3 -m pip3 install -r requirements.txt python3 setup.py install - python3 ./eth2deposit/deposit.py "$@" - ;; + exit 1 + fi - Linux) - echo 'Linux' - python3 -m pip install -r requirements.txt - python3 setup.py install - python3 ./eth2deposit/deposit.py "$@" - ;; + python3 ./eth2deposit/deposit.py "$@" - CYGWIN*|MINGW32*|MSYS*|MINGW*) - echo 'MS Windows' +elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then + echo $OSTYPE + if [[ $1 == install ]]; then python -m pip install -r requirements.txt python setup.py install - python ./eth2deposit/deposit.py "$@" - ;; + exit 1 + fi - *) - echo 'Other OS' - ;; + python ./eth2deposit/deposit.py "$@" -esac +else + echo "Sorry, to run deposit-cli on" $(uname -s)", please see the trouble-shooting on https://github.com/ethereum/eth2.0-deposit-cli" + exit 1 + +fi diff --git a/test_deposit_script.py b/test_deposit_script.py index ba34d31..3e66b5e 100755 --- a/test_deposit_script.py +++ b/test_deposit_script.py @@ -12,7 +12,7 @@ async def main(): if os.name == 'nt': # Windows script = 'sh deposit.sh' - else: + else: # Mac or Linux script = './deposit.sh' cmd_args = [ diff --git a/tests/test_cli.py b/tests/test_cli.py index 5122443..8c3de15 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -47,6 +47,12 @@ async def test_script(): if not os.path.exists(my_folder_path): os.mkdir(my_folder_path) + proc = await asyncio.create_subprocess_shell( + './deposit.sh install', + stdin=asyncio.subprocess.PIPE, + stdout=asyncio.subprocess.PIPE, + ) + cmd_args = [ './deposit.sh', '--num_validators', '1', diff --git a/tox.ini b/tox.ini index c63baca..1017a36 100644 --- a/tox.ini +++ b/tox.ini @@ -12,19 +12,15 @@ extras = test basepython= py37: python3.7 py38: python3.8 - -[common-install] deps= -r{toxinidir}/requirements.txt -r{toxinidir}/requirements_test.txt [common-core] -deps={[common-install]deps} commands= pytest {posargs:tests} [common-lint] -deps={[common-install]deps} commands= flake8 --config={toxinidir}/flake8.ini {toxinidir}/cli {toxinidir}/tests mypy --config-file {toxinidir}/mypy.ini -p eth2deposit @@ -36,19 +32,15 @@ commands= python {toxinidir}/test_deposit_script.py [testenv:py37-core] -deps={[common-core]deps} commands={[common-core]commands} [testenv:py38-core] -deps={[common-core]deps} commands={[common-core]commands} [testenv:py37-lint] -deps={[common-lint]deps} commands={[common-lint]commands} [testenv:py38-lint] -deps={[common-lint]deps} commands={[common-lint]commands} [testenv:py37-script]