From d521903963a335e6c7c51ca5fa13bd49d4a8ee4b Mon Sep 17 00:00:00 2001 From: matejcik Date: Fri, 9 Aug 2019 18:08:35 +0200 Subject: [PATCH] python: clarify requirements, enable tox in CI --- .gitlab-ci.yml | 2 +- Pipfile | 6 +++++- Pipfile.lock | 25 ++++++++++++++++++++++++- ci/Dockerfile | 8 ++++++++ ci/python.yml | 7 +++++++ python/requirements-dev.txt | 8 -------- python/requirements.txt | 1 - python/setup.py | 1 - python/tox.ini | 13 ++++++++----- 9 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 ci/python.yml delete mode 100644 python/requirements-dev.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 08fc61656..ef32af317 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,6 +35,6 @@ include: - ci/prebuild.yml # common, style - ci/core.yml - ci/legacy.yml - # - ci/python.yml TODO + - ci/python.yml - ci/crypto.yml - ci/storage.yml diff --git a/Pipfile b/Pipfile index ec4c78557..5d7aa47da 100644 --- a/Pipfile +++ b/Pipfile @@ -10,12 +10,16 @@ scons = "*" protobuf = "==3.4.0" pyblake2 = "*" -## tests +## test tools pytest = "*" mock = "*" coverage = "==4.5.3" # coverage 5+ uses binary format flaky = ">=3.6.1" # https://github.com/box/flaky/issues/156 pytest-random-order = "*" +tox = "*" + +## test requirements +shamir-mnemonic = "*" ## typing mypy = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 073a6e618..b2cb1f2f0 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "dcb322f20cb35e8779f1667304894d51dcc8bdaab0ed613502cd4acd356b21ab" + "sha256": "79f117b15c6ca077e6304f4f99517da7c880ba84832ebf8034807996e2c337bd" }, "pipfile-spec": 6, "requires": {}, @@ -220,6 +220,13 @@ ], "version": "==0.3" }, + "filelock": { + "hashes": [ + "sha256:18d82244ee114f543149c66a6e0c14e9c4f8a1044b5cdaadd0f82159d6a6ff59", + "sha256:929b7d63ec5b7d6b71b0fa5ac14e030b3f70b75747cef1b10da9b879fef15836" + ], + "version": "==3.0.12" + }, "flake8": { "hashes": [ "sha256:19241c1cbc971b9962473e4438a2ca19749a7dd002dd1a946eaba171b4114548", @@ -538,6 +545,7 @@ "sha256:1cc08d276e05b13cd32bd3b0c5d1cb6c30254e0086e0f6857ec106d4cceff121", "sha256:5e7cc1354697e304b7868fc01085bcd4b30bb2020b77b6cc5ceeb0c032d513a7" ], + "index": "pypi", "version": "==0.1.0" }, "six": { @@ -561,6 +569,14 @@ ], "version": "==0.10.0" }, + "tox": { + "hashes": [ + "sha256:dab0b0160dd187b654fc33d690ee1d7bf328bd5b8dc6ef3bb3cc468969c659ba", + "sha256:ee35ffce74933a6c6ac10c9a0182e41763140a5a5070e21b114feca56eaccdcd" + ], + "index": "pypi", + "version": "==3.13.2" + }, "trezor": { "editable": true, "path": "./python" @@ -610,6 +626,13 @@ ], "version": "==1.25.3" }, + "virtualenv": { + "hashes": [ + "sha256:6cb2e4c18d22dbbe283d0a0c31bb7d90771a606b2cb3415323eea008eaee6a9d", + "sha256:909fe0d3f7c9151b2df0a2cb53e55bdb7b0d61469353ff7a49fd47b0f0ab9285" + ], + "version": "==16.7.2" + }, "wcwidth": { "hashes": [ "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", diff --git a/ci/Dockerfile b/ci/Dockerfile index 033052e10..fd1381916 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -17,6 +17,14 @@ RUN echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/so RUN apt-get update && apt-get install -t stretch-backports -y clang-format-6.0 RUN ln -s clang-format-6.0 /usr/bin/clang-format +# install python versions from deadsnakes +# assuming our installed Python is 3.7 +RUN apt-add-repository ppa:deadsnakes/ppa +RUN apt-get update && apt-get install -y \ + python3.5 python3.5-dev \ + python3.6 python3.6-dev \ + python3.8 python3.8-dev python3.8-distutils + # TODO are all apt packages actually needed? # install dependencies from toolchain source build diff --git a/ci/python.yml b/ci/python.yml new file mode 100644 index 000000000..d333717b8 --- /dev/null +++ b/ci/python.yml @@ -0,0 +1,7 @@ +image: registry.gitlab.com/satoshilabs/trezor/trezor-firmware/environment + +test python: + stage: test + script: + - cd python + - pipenv run tox diff --git a/python/requirements-dev.txt b/python/requirements-dev.txt deleted file mode 100644 index 2569b213d..000000000 --- a/python/requirements-dev.txt +++ /dev/null @@ -1,8 +0,0 @@ --r requirements.txt --r requirements-optional.txt -pytest>=3.6 -flake8 -protobuf -isort>=4.3.14 -black; python_version >= "3.6" -autoflake>=1.2 diff --git a/python/requirements.txt b/python/requirements.txt index 29c0bdf08..adb45d580 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,6 +1,5 @@ ecdsa>=0.9 mnemonic>=0.17 -shamir-mnemonic>=0.1.0 requests>=2.4.0 click>=7,<8 libusb1>=1.6.4 diff --git a/python/setup.py b/python/setup.py index ddf1f0cf4..098271244 100755 --- a/python/setup.py +++ b/python/setup.py @@ -9,7 +9,6 @@ install_requires = [ "setuptools>=19.0", "ecdsa>=0.9", "mnemonic>=0.17", - "shamir-mnemonic>=0.1.0", "requests>=2.4.0", "click>=7,<8", "libusb1>=1.6.4", diff --git a/python/tox.ini b/python/tox.ini index 8141ec23c..2f505eeda 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -3,16 +3,19 @@ envlist = py35, py36, py37, + py38, [testenv] deps = - -rrequirements-dev.txt + -rrequirements.txt + pytest>=3.6 + pytest-random-order commands = # Generate local files python setup.py build # Working in the local directory, try to compile all bytecode - python -m compileall trezorlib/ - # From installed version, smoke-test trezorctl + python -m compileall src tests + # Smoke-test trezorctl trezorctl --help - # Run non-device-dependent tests from installed version - python -E -m pytest --pyargs trezorlib.tests.unit_tests + # Run test suite + pytest --random-order tests