Skip to content

Commit

Permalink
Clean up markers when formatting pipfiles
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed Oct 10, 2018
1 parent 51b02bd commit 4a8086d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ def resolve_deps(
using pip-tools -- and their hashes, using the warehouse API / pip.
"""
from .patched.notpip._vendor.requests.exceptions import ConnectionError
from .vendor.requirementslib.models.requirements import Requirement
from ._compat import TemporaryDirectory

index_lookup = {}
Expand Down Expand Up @@ -447,17 +448,11 @@ def resolve_deps(
sys.exit(1)
for result in resolved_tree:
if not result.editable:
name = pep423_name(result.name)
version = clean_pkg_version(result.specifier)
req = Requirement.from_ireq(result)
name = pep423_name(req.name)
version = str(req.get_version())
index = index_lookup.get(result.name)
if not markers_lookup.get(result.name):
markers = (
str(result.markers)
if result.markers and "extra" not in str(result.markers)
else None
)
else:
markers = markers_lookup.get(result.name)
req.index = index
collected_hashes = []
if result in hashes:
collected_hashes = list(hashes.get(result))
Expand Down Expand Up @@ -493,13 +488,16 @@ def resolve_deps(
# except (ValueError, KeyError, ConnectionError, IndexError):
# if verbose:
# print('Error generating hash for {}'.format(name))
collected_hashes = sorted(set(collected_hashes))
d = {"name": name, "version": version, "hashes": collected_hashes}
if index:
d.update({"index": index})
if markers:
d.update({"markers": markers.replace('"', "'")})
results.append(d)
req.hashes = sorted(set(collected_hashes))
name, entry = req.pipfile_entry
entry["name"] = name
entry["version"] = version
# if index:
# d.update({"index": index})
if markers_lookup.get(result.name):
entry.update({"markers": markers_lookup.get(result.name)})
entry = translate_markers(entry)
results.append(entry)
req_dir.cleanup()
return results

Expand Down

0 comments on commit 4a8086d

Please sign in to comment.