From e3e79a55fa6fc1baedac19d8ff1b28af78391a97 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 12 Aug 2018 10:16:51 +0200 Subject: [PATCH 1/4] Fix _abc_data pickle error in 3.7 --- freqtrade/strategy/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/freqtrade/strategy/__init__.py b/freqtrade/strategy/__init__.py index 283426dfa..49b0c45c0 100644 --- a/freqtrade/strategy/__init__.py +++ b/freqtrade/strategy/__init__.py @@ -12,8 +12,18 @@ def import_strategy(strategy: IStrategy, config: dict) -> IStrategy: Imports given Strategy instance to global scope of freqtrade.strategy and returns an instance of it """ + # Copy all attributes from base class and class - attr = deepcopy({**strategy.__class__.__dict__, **strategy.__dict__}) + + comb = {**strategy.__class__.__dict__, **strategy.__dict__} + + # Delete '_abc_impl' from dict as deepcopy fails on 3.7 with + # `TypeError: can't pickle _abc_data objects`` + # This will only apply to python 3.7 + if '_abc_impl' in comb: + del comb['_abc_impl'] + + attr = deepcopy(comb) # Adjust module name attr['__module__'] = 'freqtrade.strategy' From f7afd9a5ffc354cc0559d9019b66a8bceaee1d6c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 12 Aug 2018 10:37:10 +0200 Subject: [PATCH 2/4] update setup.sh to support 3.7 --- setup.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index a825ca41f..557bcdd12 100755 --- a/setup.sh +++ b/setup.sh @@ -1,13 +1,31 @@ #!/usr/bin/env bash #encoding=utf8 +# Check which python version is installed +function check_installed_python() { + which python3.7 + if [ $? -eq 0 ]; then + echo "using Python 3.7" + PYTHON=python3.7 + return + fi + + which python3.6 + if [ $? -eq 0 ]; then + echo "using Python 3.6" + PYTHON=python3.6 + return + fi + +} + function updateenv () { echo "-------------------------" echo "Update your virtual env" echo "-------------------------" source .env/bin/activate echo "pip3 install in-progress. Please wait..." - pip3.6 install --quiet --upgrade pip + pip3 install --quiet --upgrade pip pip3 install --quiet -r requirements.txt --upgrade pip3 install --quiet -r requirements.txt pip3 install --quiet -e . @@ -79,7 +97,7 @@ function reset () { fi echo - python3.6 -m venv .env + ${PYTHON} -m venv .env updateenv } @@ -183,7 +201,7 @@ function install () { install_debian else echo "This script does not support your OS." - echo "If you have Python3.6, pip, virtualenv, ta-lib you can continue." + echo "If you have Python3.6 or Python3.7, pip, virtualenv, ta-lib you can continue." echo "Wait 10 seconds to continue the next install steps or use ctrl+c to interrupt this shell." sleep 10 fi @@ -193,7 +211,7 @@ function install () { echo "-------------------------" echo "Run the bot" echo "-------------------------" - echo "You can now use the bot by executing 'source .env/bin/activate; python3.6 freqtrade/main.py'." + echo "You can now use the bot by executing 'source .env/bin/activate; ${PYTHON} freqtrade/main.py'." } function plot () { @@ -214,6 +232,9 @@ function help () { echo " -p,--plot Install dependencies for Plotting scripts." } +# Verify if 3.6 or 3.7 is installed +check_installed_python + case $* in --install|-i) install From a0bc17d1ef25effd20c70130ecc4407d03d4fc2d Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 12 Aug 2018 13:59:50 +0200 Subject: [PATCH 3/4] Update dockerfile to 3.7.0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e959b9296..5d1b44f8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.6.6-slim-stretch +FROM python:3.7.0-slim-stretch # Install TA-lib RUN apt-get update && apt-get -y install curl build-essential && apt-get clean From d007ac4b96b3bf34f7e55a07ee53b0f3680e0b19 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 15 Aug 2018 08:37:20 +0200 Subject: [PATCH 4/4] check version explicitly, use "python" in venv --- freqtrade/strategy/__init__.py | 3 ++- setup.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/strategy/__init__.py b/freqtrade/strategy/__init__.py index 49b0c45c0..38a110bd7 100644 --- a/freqtrade/strategy/__init__.py +++ b/freqtrade/strategy/__init__.py @@ -1,4 +1,5 @@ import logging +import sys from copy import deepcopy from freqtrade.strategy.interface import IStrategy @@ -20,7 +21,7 @@ def import_strategy(strategy: IStrategy, config: dict) -> IStrategy: # Delete '_abc_impl' from dict as deepcopy fails on 3.7 with # `TypeError: can't pickle _abc_data objects`` # This will only apply to python 3.7 - if '_abc_impl' in comb: + if sys.version_info.major == 3 and sys.version_info.minor == 7 and '_abc_impl' in comb: del comb['_abc_impl'] attr = deepcopy(comb) diff --git a/setup.sh b/setup.sh index 557bcdd12..bd58edbee 100755 --- a/setup.sh +++ b/setup.sh @@ -211,7 +211,7 @@ function install () { echo "-------------------------" echo "Run the bot" echo "-------------------------" - echo "You can now use the bot by executing 'source .env/bin/activate; ${PYTHON} freqtrade/main.py'." + echo "You can now use the bot by executing 'source .env/bin/activate; python freqtrade/main.py'." } function plot () {