Merge pull request #1141 from freqtrade/fix/python3.7
fix running freqtrade on python3.7
This commit is contained in:
commit
0750d356a1
@ -1,4 +1,4 @@
|
|||||||
FROM python:3.6.6-slim-stretch
|
FROM python:3.7.0-slim-stretch
|
||||||
|
|
||||||
# Install TA-lib
|
# Install TA-lib
|
||||||
RUN apt-get update && apt-get -y install curl build-essential && apt-get clean
|
RUN apt-get update && apt-get -y install curl build-essential && apt-get clean
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
from freqtrade.strategy.interface import IStrategy
|
from freqtrade.strategy.interface import IStrategy
|
||||||
@ -12,8 +13,18 @@ def import_strategy(strategy: IStrategy, config: dict) -> IStrategy:
|
|||||||
Imports given Strategy instance to global scope
|
Imports given Strategy instance to global scope
|
||||||
of freqtrade.strategy and returns an instance of it
|
of freqtrade.strategy and returns an instance of it
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Copy all attributes from base class and class
|
# 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 sys.version_info.major == 3 and sys.version_info.minor == 7 and '_abc_impl' in comb:
|
||||||
|
del comb['_abc_impl']
|
||||||
|
|
||||||
|
attr = deepcopy(comb)
|
||||||
# Adjust module name
|
# Adjust module name
|
||||||
attr['__module__'] = 'freqtrade.strategy'
|
attr['__module__'] = 'freqtrade.strategy'
|
||||||
|
|
||||||
|
29
setup.sh
29
setup.sh
@ -1,13 +1,31 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#encoding=utf8
|
#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 () {
|
function updateenv () {
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo "Update your virtual env"
|
echo "Update your virtual env"
|
||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
source .env/bin/activate
|
source .env/bin/activate
|
||||||
echo "pip3 install in-progress. Please wait..."
|
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 --upgrade
|
||||||
pip3 install --quiet -r requirements.txt
|
pip3 install --quiet -r requirements.txt
|
||||||
pip3 install --quiet -e .
|
pip3 install --quiet -e .
|
||||||
@ -79,7 +97,7 @@ function reset () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
python3.6 -m venv .env
|
${PYTHON} -m venv .env
|
||||||
updateenv
|
updateenv
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +201,7 @@ function install () {
|
|||||||
install_debian
|
install_debian
|
||||||
else
|
else
|
||||||
echo "This script does not support your OS."
|
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."
|
echo "Wait 10 seconds to continue the next install steps or use ctrl+c to interrupt this shell."
|
||||||
sleep 10
|
sleep 10
|
||||||
fi
|
fi
|
||||||
@ -193,7 +211,7 @@ function install () {
|
|||||||
echo "-------------------------"
|
echo "-------------------------"
|
||||||
echo "Run the bot"
|
echo "Run the bot"
|
||||||
echo "-------------------------"
|
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 () {
|
function plot () {
|
||||||
@ -214,6 +232,9 @@ function help () {
|
|||||||
echo " -p,--plot Install dependencies for Plotting scripts."
|
echo " -p,--plot Install dependencies for Plotting scripts."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verify if 3.6 or 3.7 is installed
|
||||||
|
check_installed_python
|
||||||
|
|
||||||
case $* in
|
case $* in
|
||||||
--install|-i)
|
--install|-i)
|
||||||
install
|
install
|
||||||
|
Loading…
Reference in New Issue
Block a user