Skip to content

Commit

Permalink
Remove pkg_resources and replaced with packaging, updated requirement…
Browse files Browse the repository at this point in the history
…s.txt
  • Loading branch information
Taaku18 committed Nov 20, 2023
1 parent 55f9ba8 commit 5482e94
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 129 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ emoji = "==2.8.0"
isodate = "==0.6.1"
motor = "==3.3.2"
natural = "==0.2.0" # Why is this needed?
packaging = "==23.2"
parsedatetime = "==2.6"
pymongo = {extras = ["srv"], version = "*"} # Required by motor
python-dateutil = "==2.8.2"
Expand Down
198 changes: 111 additions & 87 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from discord.ext import commands, tasks
from discord.ext.commands.view import StringView
from emoji import is_emoji
from pkg_resources import parse_version
from packaging.version import Version


try:
Expand Down Expand Up @@ -186,7 +186,7 @@ async def load_extensions(self):

@property
def version(self):
return parse_version(__version__)
return Version(__version__)

@property
def api(self) -> ApiClient:
Expand Down Expand Up @@ -1586,7 +1586,7 @@ async def autoupdate(self):
changelog = await Changelog.from_url(self)
latest = changelog.latest_version

if self.version < parse_version(latest.version):
if self.version < Version(latest.version):
error = None
data = {}
try:
Expand Down
6 changes: 3 additions & 3 deletions cogs/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import discord
from discord.ext import commands

from pkg_resources import parse_version
from packaging.version import Version

from core import checks
from core.models import PermissionLevel, getLogger
Expand Down Expand Up @@ -300,7 +300,7 @@ async def parse_user_input(self, ctx, plugin_name, check_version=False):
if check_version:
required_version = details.get("bot_version", False)

if required_version and self.bot.version < parse_version(required_version):
if required_version and self.bot.version < Version(required_version):
embed = discord.Embed(
description="Your bot's version is too low. "
f"This plugin requires version `{required_version}`.",
Expand Down Expand Up @@ -688,7 +688,7 @@ async def plugins_registry(self, ctx, *, plugin_name: typing.Union[int, str] = N
embed.set_footer(text="This plugin is currently loaded.")
else:
required_version = details.get("bot_version", False)
if required_version and self.bot.version < parse_version(required_version):
if required_version and self.bot.version < Version(required_version):
embed.set_footer(
text="Your bot is unable to install this plugin, "
f"minimum required version is v{required_version}."
Expand Down
11 changes: 6 additions & 5 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
from typing import Union

import discord
from aiohttp import ClientResponseError
from discord.enums import ActivityType, Status
from discord.ext import commands, tasks
from discord.ext.commands.view import StringView
from pkg_resources import parse_version

from aiohttp import ClientResponseError
from packaging.version import Version

from core import checks, utils
from core.changelog import Changelog
Expand Down Expand Up @@ -341,9 +342,9 @@ async def about(self, ctx):
latest = changelog.latest_version

if self.bot.version.is_prerelease:
stable = next(filter(lambda v: not parse_version(v.version).is_prerelease, changelog.versions))
stable = next(filter(lambda v: not Version(v.version).is_prerelease, changelog.versions))
footer = f"You are on the prerelease version • the latest version is v{stable.version}."
elif self.bot.version < parse_version(latest.version):
elif self.bot.version < Version(latest.version):
footer = f"A newer version is available v{latest.version}."
else:
footer = "You are up to date with the latest version."
Expand Down Expand Up @@ -1930,7 +1931,7 @@ async def update(self, ctx, *, flag: str = ""):
"(https://github.com/modmail-dev/modmail/blob/master/bot.py#L1)"
)

if self.bot.version >= parse_version(latest.version) and flag.lower() != "force":
if self.bot.version >= Version(latest.version) and flag.lower() != "force":
embed = discord.Embed(title="Already up to date", description=desc, color=self.bot.main_color)

data = await self.bot.api.get_user_info()
Expand Down
59 changes: 28 additions & 31 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
#
# These requirements were autogenerated by pipenv
# To regenerate from the project's Pipfile, run:
#
# pipenv lock --requirements
#

-i https://pypi.org/simple
aiohttp==3.8.1
aiosignal==1.2.0; python_version >= '3.6'
async-timeout==4.0.2; python_version >= '3.6'
attrs==21.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
cairocffi==1.3.0; python_version >= '3.7'
cairosvg==2.5.2
cffi==1.15.0
charset-normalizer==2.0.12; python_version >= '3.5'
colorama==0.4.4
cssselect2==0.6.0; python_version >= '3.7'
aiohttp==3.9.0
aiosignal==1.3.1; python_version >= '3.7'
async-timeout==4.0.3; python_version < '3.11'
attrs==23.1.0; python_version >= '3.7'
cairocffi==1.6.1; python_version >= '3.7'
cairosvg==2.7.1; python_version >= '3.5'
certifi==2023.11.17; python_version >= '3.6'
cffi==1.16.0; python_version >= '3.8'
charset-normalizer==3.3.2; python_version >= '3.7'
colorama==0.4.6
cssselect2==0.7.0; python_version >= '3.7'
defusedxml==0.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
dnspython==2.2.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
emoji==1.7.0
frozenlist==1.3.0; python_version >= '3.7'
discord.py==2.0.1
idna==3.3; python_version >= '3.5'
discord.py==2.3.2
dnspython==2.4.2; python_version >= '3.8' and python_version < '4.0'
emoji==2.8.0
frozenlist==1.4.0; python_version >= '3.8'
idna==3.4; python_version >= '3.5'
isodate==0.6.1
lottie[pdf]==0.6.11
motor==2.5.1
multidict==6.0.2; python_version >= '3.7'
lottie[pdf]==0.7.0
motor==3.3.2
multidict==6.0.4; python_version >= '3.7'
natural==0.2.0
packaging==23.2
parsedatetime==2.6
pillow==9.1.0; python_version >= '3.7'
pillow==10.1.0; python_version >= '3.8'
pycparser==2.21
pymongo==3.12.3
pymongo[srv]==4.6.0
python-dateutil==2.8.2
python-dotenv==0.20.0
python-dotenv==1.0.0
requests==2.31.0
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
tinycss2==1.1.1; python_version >= '3.6'
uvloop==0.16.0; sys_platform != 'win32'
tinycss2==1.2.1; python_version >= '3.7'
urllib3==2.1.0; python_version >= '3.8'
uvloop==0.19.0; sys_platform != 'win32'
webencodings==0.5.1
yarl==1.7.2; python_version >= '3.6'
yarl==1.9.3; python_version >= '3.7'

0 comments on commit 5482e94

Please sign in to comment.