Skip to content

Commit

Permalink
Bump Minimum Python Version to 3.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Mac committed Jan 22, 2021
1 parent 6c52730 commit a684227
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Please tick all applicable boxes.

- [ ] I am using Python 3.5.3 or higher (run `python --version` on the command line)
- [ ] I am using Python 3.8.7 or higher (run `python --version` on the command line)
- [ ] I have followed the [official guides](https://github.com/Just-Some-Bots/MusicBot/wiki) to install the bot for my system
- [ ] I have updated my dependencies to the latest version using the appropriate `update` script

Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
After creating your pull request, tick these boxes if they are applicable to you.

- [ ] I have tested my changes against the `review` branch (the latest developmental version), and this pull request is targeting that branch as a base
- [ ] I have tested my changes on Python 3.5.3 or higher
- [ ] I have tested my changes on Python 3.8.7 or higher

----

Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ language: python

matrix:
include:
- python: "3.5"
env: TYPE=docker
- python: "3.5"
env: TYPE=build
- python: "3.8"
env: TYPE=docker
- python: "3.8"
env: TYPE=build
- python: "3.9"
env: TYPE=docker
- python: "3.9"
env: TYPE=build

services:
- docker
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

[![GitHub stars](https://img.shields.io/github/stars/Just-Some-Bots/MusicBot.svg)](https://github.com/Just-Some-Bots/MusicBot/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/Just-Some-Bots/MusicBot.svg)](https://github.com/Just-Some-Bots/MusicBot/network)
[![Python version](https://img.shields.io/badge/python-3.5%2C%203.6%2C%203.7-blue.svg)](https://python.org)
[![Python version](https://img.shields.io/badge/python-3.8%2C%203.6%2C%203.7-blue.svg)](https://python.org)
[![Discord](https://discordapp.com/api/guilds/129489631539494912/widget.png?style=shield)](https://discord.gg/bots)

MusicBot is the original Discord music bot written for [Python](https://www.python.org "Python homepage") 3.5+, using the [discord.py](https://github.com/Rapptz/discord.py) library. It plays requested songs from YouTube and other services into a Discord server (or multiple servers). Besides, if the queue becomes empty MusicBot will play through a list of existing songs with configuration. The bot features a permission system allowing owners to restrict commands to certain people. As well as playing songs, MusicBot is capable of streaming live media into a voice channel (experimental).
MusicBot is the original Discord music bot written for [Python](https://www.python.org "Python homepage") 3.8+, using the [discord.py](https://github.com/Rapptz/discord.py) library. It plays requested songs from YouTube and other services into a Discord server (or multiple servers). Besides, if the queue becomes empty MusicBot will play through a list of existing songs with configuration. The bot features a permission system allowing owners to restrict commands to certain people. As well as playing songs, MusicBot is capable of streaming live media into a voice channel (experimental).

![Main](https://i.imgur.com/FWcHtcS.png)

Expand Down
20 changes: 10 additions & 10 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
What we need to do:
0. (optional) Check disk space
0.1: The same env checks in run.py?
1: Make sure this is python 3.5+
1.1: If we installed python 3.5, restart using that
1: Make sure this is python 3.8+
1.1: If we installed python 3.8, restart using that
2. Check for and install required programs:
- brew (osx)
- git
Expand Down Expand Up @@ -59,16 +59,16 @@

# Logging setup goes here

PY_VERSION = sys.version_info # (3, 5, 1, ...)
PY_VERSION = sys.version_info # (3, 8, 7, ...)
SYS_PLATFORM = sys.platform # 'win32', 'linux', 'darwin'
SYS_UNAME = platform.uname()
SYS_ARCH = ('32', '64')[SYS_UNAME[4].endswith('64')]
SYS_PKGMANAGER = None # TODO: Figure this out

PLATFORMS = ['win32', 'linux', 'darwin', 'linux2']

MINIMUM_PY_VERSION = (3, 5)
TARGET_PY_VERSION = "3.5.2"
MINIMUM_PY_VERSION = (3, 8)
TARGET_PY_VERSION = "3.8.7"

if SYS_PLATFORM not in PLATFORMS:
raise RuntimeError('Unsupported system "%s"' % SYS_PLATFORM)
Expand Down Expand Up @@ -204,7 +204,7 @@ def check(self):
if PY_VERSION >= MINIMUM_PY_VERSION:
return True

# TODO: Check for python 3.5 and restart if found
# TODO: Check for python 3.8 and restart if found

def download_win32(self):
exe, _ = tmpdownload(self.PYTHON_EXE.format(ver=TARGET_PY_VERSION))
Expand Down Expand Up @@ -269,7 +269,7 @@ def setup_darwin(self, data):

def _restart(self, *cmds):
# TODO: os.execl
pass # Restart with 3.5 if needed
pass # Restart with 3.8 if needed


class EnsureEnv(SetupTask):
Expand Down Expand Up @@ -499,15 +499,15 @@ def setup(self, data):
ensurepip.bootstrap()
except PermissionError:
# panic and try and sudo it
sudo_check_call("python3.5 -m ensurepip")
sudo_check_call("python3.8 -m ensurepip")
return

# Instead, we have to run get-pip.py.
print("Installing pip...")
try:
sudo_check_call(["python3.5", "{}".format(data)])
sudo_check_call(["python3.8", "{}".format(data)])
except FileNotFoundError:
subprocess.check_call(["python3.5", "{}".format(data)])
subprocess.check_call(["python3.8", "{}".format(data)])


class GitCloneMusicbot(SetupTask):
Expand Down
22 changes: 11 additions & 11 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def sanity_checks(optional=True):
log.info("Starting sanity checks")
## Required

# Make sure we're on Python 3.5+
# Make sure we're on Python 3.8+
req_ensure_py3()

# Fix windows encoding fuckery
Expand Down Expand Up @@ -221,19 +221,19 @@ def sanity_checks(optional=True):


def req_ensure_py3():
log.info("Checking for Python 3.5+")
log.info("Checking for Python 3.8+")

if sys.version_info < (3, 5):
log.warning("Python 3.5+ is required. This version is %s", sys.version.split()[0])
log.warning("Attempting to locate Python 3.5...")
if sys.version_info < (3, 8):
log.warning("Python 3.8+ is required. This version is %s", sys.version.split()[0])
log.warning("Attempting to locate Python 3.8...")

pycom = None

if sys.platform.startswith('win'):
log.info('Trying "py -3.5"')
log.info('Trying "py -3.8"')
try:
subprocess.check_output('py -3.5 -c "exit()"', shell=True)
pycom = 'py -3.5'
subprocess.check_output('py -3.8 -c "exit()"', shell=True)
pycom = 'py -3.8'
except:

log.info('Trying "python3"')
Expand All @@ -252,17 +252,17 @@ def req_ensure_py3():
sys.exit(0)

else:
log.info('Trying "python3.5"')
log.info('Trying "python3.8"')
try:
pycom = subprocess.check_output('python3.5 -c "exit()"'.split()).strip().decode()
pycom = subprocess.check_output('python3.8 -c "exit()"'.split()).strip().decode()
except:
pass

if pycom:
log.info("\nPython 3 found. Re-launching bot using: %s run.py\n", pycom)
pyexec(pycom, 'run.py')

log.critical("Could not find Python 3.5 or higher. Please run the bot using Python 3.5")
log.critical("Could not find Python 3.8 or higher. Please run the bot using Python 3.8")
bugger_off()


Expand Down
37 changes: 12 additions & 25 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,42 @@ cd "$(dirname "$BASH_SOURCE")"
# Set variables for python versions. Could probably be done cleaner, but this works.
declare -A python=( ["0"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[0]))' || { echo "no py"; }` ["1"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py"; }` ["2"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py"; }` )
declare -A python3=( ["0"]=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py3"; }` ["1"]=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py3"; }` )
PYTHON35_VERSION=`python3.5 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py35"; }`
PYTHON36_VERSION=`python3.6 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py36"; }`
PYTHON37_VERSION=`python3.7 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py37"; }`
PYTHON38_VERSION=`python3.8 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py38"; }`
PYTHON39_VERSION=`python3.9 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py39"; }`


if [ "${python[0]}" -eq "3" ]; then # Python = 3
if [ "${python[1]}" -eq "5" ]; then # Python = 3.5
if [ "${python[2]}" -ge "3" ]; then # Python = 3.5.3
if [ "${python[1]}" -eq "8" ]; then # Python = 3.8
if [ "${python[2]}" -ge "7" ]; then # Python = 3.8.7
python run.py
exit
fi
elif [ "${python[1]}" -ge "6" ]; then # Python >= 3.6
elif [ "${python[1]}" -ge "9" ]; then # Python >= 3.9
python run.py
exit
fi
fi

if [ "${python3[0]}" -eq "5" ]; then # Python3 = 3.5
if [ "${python3[1]}" -ge "3" ]; then # Python3 >= 3.5.3
if [ "${python3[0]}" -eq "8" ]; then # Python3 = 3.8
if [ "${python3[1]}" -ge "7" ]; then # Python3 >= 3.8.7
python3 run.py
exit
fi
fi

if [ "${python3[0]}" -ge "6" ]; then # Python3 >= 3.6
if [ "${python3[0]}" -ge "9" ]; then # Python3 >= 3.9
python3 run.py
exit
fi

if [ "$PYTHON35_VERSION" -ge "3" ]; then # Python3.5 > 3.5.3
python3.5 run.py
exit
fi

if [ "$PYTHON36_VERSION" -eq "6" ]; then # Python3.6 = 3.6
python3.6 run.py
exit
fi

if [ "$PYTHON37_VERSION" -eq "7" ]; then # Python3.7 = 3.7
python3.7 run.py
exit
fi

if [ "$PYTHON38_VERSION" -eq "8" ]; then # Python3.8 = 3.8
python3.8 run.py
exit
fi

if [ "$PYTHON39_VERSION" -eq "9" ]; then # Python3.9 = 3.9
python3.9 run.py
exit
fi
echo "You are running an unsupported Python version."
echo "Please use a version of Python above 3.5.2."
echo "Please use a version of Python above 3.8.7."
41 changes: 14 additions & 27 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,42 @@ cd "$(dirname "$BASH_SOURCE")"
# Set variables for python versions. Could probably be done cleaner, but this works.
declare -A python=( ["0"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[0]))' || { echo "no py"; }` ["1"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py"; }` ["2"]=`python -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py"; }` )
declare -A python3=( ["0"]=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py3"; }` ["1"]=`python3 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py3"; }` )
PYTHON35_VERSION=`python3.5 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[2]))' || { echo "no py35"; }`
PYTHON36_VERSION=`python3.6 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py36"; }`
PYTHON37_VERSION=`python3.7 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py37"; }`
PYTHON38_VERSION=`python3.8 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py38"; }`

PYTHON39_VERSION=`python3.9 -c 'import sys; version=sys.version_info[:3]; print("{0}".format(version[1]))' || { echo "no py39"; }`

if [ "${python[0]}" -eq "3" ]; then # Python = 3
if [ "${python[1]}" -eq "5" ]; then # Python = 3.5
if [ "${python[2]}" -ge "3" ]; then # Python = 3.5.3
if [ "${python[1]}" -eq "8" ]; then # Python = 3.8
if [ "${python[2]}" -ge "7" ]; then # Python = 3.8.7
python update.py
exit
fi
elif [ "${python[1]}" -ge "6" ]; then # Python >= 3.6
elif [ "${python[1]}" -gt "9" ]; then # Python >= 3.9
python update.py
exit
fi
fi

if [ "${python3[0]}" -eq "5" ]; then # Python3 = 3.5
if [ "${python3[1]}" -ge "3" ]; then # Python3 >= 3.5.3
python3 update.py
exit
if [ "${python3[0]}" -eq "8" ]; then # Python3 = 3.8
if [ "${python3[1]}" -ge "7" ]; then # Python3 >= 3.8.7
python3 update.py
exit
fi
fi

if [ "${python3[0]}" -ge "6" ]; then # Python3 >= 3.6
if [ "${python3[0]}" -ge "9" ]; then # Python3 >= 3.9
python3 update.py
exit
fi

if [ "$PYTHON35_VERSION" -ge "3" ]; then # Python3.5 > 3.5.3
python3.5 update.py
exit
fi

if [ "$PYTHON36_VERSION" -eq "6" ]; then # Python3.6 = 3.6
python3.6 update.py
exit
fi

if [ "$PYTHON37_VERSION" -eq "7" ]; then # Python3.7 = 3.7
python3.7 update.py
if [ "$PYTHON38_VERSION" -eq "8" ]; then # Python3.8 = 3.8
python3.8 update.py
exit
fi

if [ "$PYTHON38_VERSION" -eq "8" ]; then # Python3.8 = 3.8
python3.8 update.py
if [ "$PYTHON39_VERSION" -eq "8" ]; then # Python3.9 = 3.9
python3.9 update.py
exit
fi

echo "You are running an unsupported Python version."
echo "Please use a version of Python above 3.5.2."
echo "Please use a version of Python above 3.8.7."

0 comments on commit a684227

Please sign in to comment.