mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3 Downloader] Allow for requiring minimum python version (#1455)
This commit is contained in:
parent
935028addc
commit
728ab6c8c1
@ -5,6 +5,8 @@ from sys import path as syspath
|
|||||||
from typing import Tuple, Union
|
from typing import Tuple, Union
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
import sys
|
||||||
|
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
from redbot.core import checks
|
from redbot.core import checks
|
||||||
from redbot.core.data_manager import cog_data_path
|
from redbot.core.data_manager import cog_data_path
|
||||||
@ -275,6 +277,13 @@ class Downloader:
|
|||||||
await ctx.send(_("Error, there is no cog by the name of"
|
await ctx.send(_("Error, there is no cog by the name of"
|
||||||
" `{}` in the `{}` repo.").format(cog_name, repo_name.name))
|
" `{}` in the `{}` repo.").format(cog_name, repo_name.name))
|
||||||
return
|
return
|
||||||
|
elif cog.min_python_version > sys.version_info:
|
||||||
|
await ctx.send(_(
|
||||||
|
"This cog requires at least python version {}, aborting install.".format(
|
||||||
|
'.'.join([str(n) for n in cog.min_python_version])
|
||||||
|
)
|
||||||
|
))
|
||||||
|
return
|
||||||
|
|
||||||
if not await repo_name.install_requirements(cog, self.LIB_PATH):
|
if not await repo_name.install_requirements(cog, self.LIB_PATH):
|
||||||
await ctx.send(_("Failed to install the required libraries for"
|
await ctx.send(_("Failed to install the required libraries for"
|
||||||
|
|||||||
@ -38,6 +38,9 @@ class Installable(RepoJSONMixin):
|
|||||||
bot_version : `tuple` of `int`
|
bot_version : `tuple` of `int`
|
||||||
The minimum bot version required for this installation. Right now
|
The minimum bot version required for this installation. Right now
|
||||||
this is always :code:`3.0.0`.
|
this is always :code:`3.0.0`.
|
||||||
|
min_python_version : `tuple` of `int`
|
||||||
|
The minimum python version required for this cog. This field will not
|
||||||
|
apply to repo info.json's.
|
||||||
hidden : `bool`
|
hidden : `bool`
|
||||||
Whether or not this cog will be hidden from the user when they use
|
Whether or not this cog will be hidden from the user when they use
|
||||||
`Downloader`'s commands.
|
`Downloader`'s commands.
|
||||||
@ -70,6 +73,7 @@ class Installable(RepoJSONMixin):
|
|||||||
|
|
||||||
self.author = ()
|
self.author = ()
|
||||||
self.bot_version = (3, 0, 0)
|
self.bot_version = (3, 0, 0)
|
||||||
|
self.min_python_version = (3, 5, 1)
|
||||||
self.hidden = False
|
self.hidden = False
|
||||||
self.required_cogs = {} # Cog name -> repo URL
|
self.required_cogs = {} # Cog name -> repo URL
|
||||||
self.requirements = ()
|
self.requirements = ()
|
||||||
@ -159,9 +163,15 @@ class Installable(RepoJSONMixin):
|
|||||||
try:
|
try:
|
||||||
bot_version = tuple(info.get("bot_version", [3, 0, 0]))
|
bot_version = tuple(info.get("bot_version", [3, 0, 0]))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
bot_version = 2
|
bot_version = self.bot_version
|
||||||
self.bot_version = bot_version
|
self.bot_version = bot_version
|
||||||
|
|
||||||
|
try:
|
||||||
|
min_python_version = tuple(info.get('min_python_version', [3, 5, 1]))
|
||||||
|
except ValueError:
|
||||||
|
min_python_version = self.min_python_version
|
||||||
|
self.min_python_version = min_python_version
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hidden = bool(info.get("hidden", False))
|
hidden = bool(info.get("hidden", False))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user