Fixed update & install commands #113

This commit is contained in:
2022-09-19 21:09:41 +02:00
parent 1ed721cccb
commit ef2d73aadc
6 changed files with 58 additions and 20 deletions

View File

@@ -65,7 +65,7 @@ class Pip:
"""
result = None
with suppress(Exception):
args = [cls._executable, "-m", "pip", "show", package]
args = [cls._executable, "-m", "pip", "freeze"]
result = subprocess.check_output(
args,
@@ -75,17 +75,11 @@ class Pip:
if result is None:
return None
new_package: list[str] = str(result, 'utf-8').lower().split('\n')
new_version = ''
for p in str(result.decode()).split('\n'):
if p == package:
return p
for atr in new_package:
if 'version' in atr:
new_version = atr.split(': ')[1]
if new_version != '':
return f'{package}=={new_version}'
return package
return None
@classmethod
def get_outdated(cls) -> bytes: