Skip to content

Commit

Permalink
fix #133
Browse files Browse the repository at this point in the history
  • Loading branch information
achillesrasquinha committed Mar 30, 2022
1 parent 10643df commit 8a3374a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/pipupgrade/_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class FakeParsedRequirement(object):
DistInfoDistribution,
EggInfoDistribution
)
from pip._vendor.packaging.requirements import (
Requirement
)

def _get_pip_executable(multiple = False):
pips = ("pip", "pip3", "pip2")
Expand Down
8 changes: 6 additions & 2 deletions src/pipupgrade/model/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ def to_datetime(string):
return datetime.strptime(string, "%Y-%m-%d %H:%M:%S.%f")

def parse_parsed_requirement(package):
requirement = package.requirement
requirement = _pip.Requirement(package.requirement)
meta_data = { }

meta_data["name"] = requirement.name
meta_data["current_version"] = str(requirement.specifier)

return meta_data

Expand All @@ -110,6 +113,7 @@ def __init__(self, package, sync = False, pip_exec = None):
elif isinstance(package, _pip.ParsedRequirement):
meta_data = parse_parsed_requirement(package)
self.name = meta_data["name"]
self.current_version = meta_data["current_version"]
elif isinstance(package, dict):
self.name = package["name"]
self.current_version = package["version"]
Expand Down Expand Up @@ -159,7 +163,7 @@ def __init__(self, package, sync = False, pip_exec = None):
self.latest_version = _pypi_info.get("version")

self.home_page = _pypi_info.get("home_page")
self.releases = [version for version in iterkeys(_pypi_info.get("releases") or [])]
self.releases = [version for version in iterkeys(_pypi_info.get("releases") or {})]

if not res:
try:
Expand Down

0 comments on commit 8a3374a

Please sign in to comment.