diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 99c38d39..e662397e 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -19,23 +19,31 @@ jobs: uses: actions/setup-python@v1.1.1 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install Mac dependencies + if: startsWith(matrix.os, 'mac') + run: | + brew update && brew install gmp boost openssl + - name: Install ubuntu dependencies + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt-get install libboost-all-dev libssl-dev + - name: Run install script + env: + INSTALL_PYTHON_VERSION: ${{ matrix.python-version }} run: | - brew update && brew install gmp boost openssl || echo "" - sudo apt-get install libboost-all-dev || echo "" - sudo apt-get install libssl-dev || echo "" sh install.sh + - name: Install time lord + run: | + sh install-timelord.sh + - name: Install developer requirements + run: | + venv/bin/python -m pip install -r requirements-dev.txt - name: Lint source with flake8 run: | ./venv/bin/flake8 src --exclude src/electron-ui/node_modules - name: Lint source with mypy run: | ./venv/bin/mypy src tests - - name: Install chiavdf from source - if: matrix['python-version'] == '3.7' && startsWith(matrix.os, 'ubuntu') - run: | - source venv/bin/activate - pip install --force --no-binary chiavdf chiavdf==0.12.1 - name: Test blockchain code with pytest run: | ./venv/bin/py.test tests -s -v diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d330cb47..253c27bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,6 +22,7 @@ The first time the tests are run, BlockTools will create and persist many plots. proofs of space during testing. The next time tests are run, this won't be necessary. ```bash +pip install -r requirements-dev.txt # you only need to do this once black src tests && flake8 src --exclude src/wallet/electron/node_modules && mypy src tests py.test tests -s -v ``` diff --git a/INSTALL.md b/INSTALL.md index ffd7ed58..f85671b9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,19 +18,24 @@ sh install.sh ### Debian/Ubuntu -On Ubuntu 18.04, you need python 3.7. +On Ubuntu 18.04, you need python 3.7. It's not available in the default +repository, so you need to add an alternate source. ```bash -sudo add-apt-repository ppa:deadsnakes/ppa -sudo apt install python3.7-venv python3.7-dev +sudo -s +apt install software-properties-common -y # for add-apt-repository +add-apt-repository ppa:deadsnakes/ppa -y +exit ``` Install dependencies. ```bash -sudo apt-get update -sudo apt-get install build-essential git cmake libgmp3-dev python3-dev -y -sudo apt-get install python3-venv libssl-dev libboost-all-dev -y +sudo -s +apt-get update +apt-get install python3.7-venv python3.7-dev -y # install python3.7 with venv and headers +apt-get install build-essential git cmake libgmp3-dev libssl-dev libboost-all-dev -y +exit git clone https://github.com/Chia-Network/chia-blockchain.git cd chia-blockchain diff --git a/install-timelord.sh b/install-timelord.sh new file mode 100644 index 00000000..8af45e4f --- /dev/null +++ b/install-timelord.sh @@ -0,0 +1,16 @@ + +THE_PATH=`python -c 'import pkg_resources; print( pkg_resources.get_distribution("chiavdf").location)' 2> /dev/null`/vdf_client + +if [ -e $THE_PATH ] +then + echo "vdf_client already exists, no action taken" +else + if [ -e venv/bin/python ] + then + echo "installing chiavdf from source" + echo venv/bin/python -m pip install --force --no-binary chiavdf chiavdf==0.12.1 + venv/bin/python -m pip install --force --no-binary chiavdf chiavdf==0.12.1 + else + echo "no venv created yet, please run install.sh" + fi +fi diff --git a/install.sh b/install.sh index 5afc5c50..bba0ed90 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,3 @@ -#!/bin/bash set -e if [ `uname` = "Linux" ] && type apt-get; then @@ -6,12 +5,16 @@ if [ `uname` = "Linux" ] && type apt-get; then sudo apt-get install -y libgmp3-dev libboost-dev libboost-system-dev npm python3-dev cmake fi -python3 -m venv venv +# this fancy syntax sets INSTALL_PYTHON_PATH to "python3.7" unless INSTALL_PYTHON_VERSION is defined +# if INSTALL_PYTHON_VERSION=3.8, then INSTALL_PYTHON_PATH becomes python3.8 + +INSTALL_PYTHON_PATH=python${INSTALL_PYTHON_VERSION:-3.7} + +$INSTALL_PYTHON_PATH -m venv venv ln -s venv/bin/activate . ./activate # pip 20.x+ supports Linux binary wheels pip install --upgrade pip -pip install wheel pip install -e . pip install -r requirements.txt diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..5e59761b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.5.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +local_scheme = "no-local-version" diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..fdd3f576 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,37 @@ +Click==7.0 +PyYAML==5.3 +appdirs==1.4.3 +autoflake==1.3.1 +black==19.10b0 +cbor2==5.0.1 +cffi==1.13.2 +cryptography==2.8 +entrypoints==0.3 +flake8==3.7.9 +idna==2.8 +importlib-metadata==1.4.0 +isort==4.3.21 +mccabe==0.6.1 +more-itertools==8.1.0 +multidict==4.7.4 +mypy-extensions==0.4.3 +mypy==0.761 +packaging==20.0 +pathspec==0.7.0 +pluggy==0.13.1 +py==1.8.1 +pycodestyle==2.5.0 +pycparser==2.19 +pyflakes==2.1.1 +pyparsing==2.4.6 +pytest-asyncio==0.10.0 +pytest==5.3.4 +regex==2020.1.8 +setuptools-scm==3.4.2 +six==1.14.0 +toml==0.10.0 +typed-ast==1.4.1 +typing-extensions==3.7.4.1 +wcwidth==0.1.8 +websockets==8.1.0 +zipp==2.0.0 diff --git a/requirements.txt b/requirements.txt index 8b1d091d..736ec0ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,54 +1,3 @@ -aiohttp==3.6.2 -aiosqlite==0.11.0 -aiter==0.13.20191203 -appdirs==1.4.3 -async-timeout==3.0.1 -attrs==19.3.0 -autoflake==1.3.1 -black==19.10b0 -blspy==0.1.14 -cbor2==5.0.1 -cffi==1.13.2 -chardet==3.0.4 -chiabip158==0.12 -chiapos==0.12 -chiavdf==0.12.1 -Click==7.0 -colorlog==4.1.0 -cryptography==2.8 -entrypoints==0.3 -flake8==3.7.9 -idna==2.8 -importlib-metadata==1.4.0 -isort==4.3.21 -mccabe==0.6.1 -miniupnpc==2.0.2 -more-itertools==8.1.0 -multidict==4.7.4 -mypy==0.761 -mypy-extensions==0.4.3 -packaging==20.0 -pathspec==0.7.0 -pluggy==0.13.1 -py==1.8.1 -pycodestyle==2.5.0 -pycparser==2.19 -pyflakes==2.1.1 -pyparsing==2.4.6 -pytest==5.3.4 -pytest-asyncio==0.10.0 -PyYAML==5.3 -regex==2020.1.8 -setuptools-scm==3.4.2 -six==1.14.0 -toml==0.10.0 -typed-ast==1.4.1 -typing-extensions==3.7.4.1 -wcwidth==0.1.8 -yarl==1.4.2 -zipp==2.0.0 -sortedcontainers==2.1.0 -websockets==8.1.0 -e git+https://github.com/Chia-Network/py-setproctitle.git@d2ed86c5080bb645d8f6b782a4a86706c860d9e6#egg=py-setproctitle -e git+https://github.com/Chia-Network/clvm.git@b912f3a0e0bd18a5ecbb29124a00fc68d8b03adb#egg=clvm -e git+https://github.com/Chia-Network/clvm_tools.git@6ff53bcfeb0c970647b6cfdde360d32b316b1326#egg=clvm_tools diff --git a/setup.py b/setup.py index 4f1fc8d0..67ac4378 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ dependencies = [ "chiavdf", # timelord and vdf verification "chiabip158", # bip158-style wallet filters "chiapos", # proof of space + "sortedcontainers", ] dev_dependencies = [ "pytest",