From 3d023a63d8d5b7c3e104f27b93dc65eaf33f1157 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 21 Jan 2017 21:28:46 -0500 Subject: [PATCH] python3 fixes --- pipenv/_pipfile/api.py | 8 +++++--- pipenv/cli.py | 5 +++-- pipenv/project.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pipenv/_pipfile/api.py b/pipenv/_pipfile/api.py index 6d937718..f4a5a1be 100644 --- a/pipenv/_pipfile/api.py +++ b/pipenv/_pipfile/api.py @@ -1,11 +1,13 @@ import toml +import codecs import json import hashlib import platform import sys import os + def format_full_version(info): version = '{0.major}.{0.minor}.{0.micro}'.format(info) kind = info.releaselevel @@ -128,12 +130,12 @@ class Pipfile(object): @property def hash(self): """Returns the SHA256 of the pipfile.""" - return hashlib.sha256(self.contents).hexdigest() + return hashlib.sha256(self.contents.encode('utf-8')).hexdigest() @property def contents(self): """Returns the contents of the pipfile.""" - with open(self.filename, 'r') as f: + with codecs.open(self.filename, 'r', 'utf-8') as f: return f.read() def freeze(self): @@ -172,7 +174,7 @@ class Pipfile(object): } # Assert each specified requirement. - for marker, specifier in self.data['_meta']['requires'].iteritems(): + for marker, specifier in self.data['_meta']['requires'].items(): if marker in lookup: try: diff --git a/pipenv/cli.py b/pipenv/cli.py index dd6dccf5..abece407 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -297,7 +297,8 @@ def install(package_name=False, dev=False, system=False): try: assert c.return_code == 0 except AssertionError: - click.echo('{1} An error occured while installing {1}'.format(crayons.red('Error: '), crayons.green(package_name))) + click.echo('{0} An error occured while installing {1}'.format(crayons.red('Error: '), crayons.green(package_name))) + click.echo(crayons.blue(c.err)) sys.exit(1) if dev: @@ -322,7 +323,7 @@ def uninstall(package_name=False, system=False): do_purge(allow_global=system) sys.exit(1) - click.echo('Un-installing {1}...'.format(crayons.green(package_name))) + click.echo('Un-installing {0}...'.format(crayons.green(package_name))) c = delegator.run('{0} uninstall {1} -y'.format(which_pip(allow_global=system), package_name)) click.echo(crayons.blue(c.out)) diff --git a/pipenv/project.py b/pipenv/project.py index f589e740..e887367d 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -81,7 +81,7 @@ class Project(object): p[key] = {} package = convert_deps_from_pip(package_name) - package_name = package.keys()[0] + package_name = [k for k in package.keys()][0] # Add the package to the group. p[key][package_name] = package[package_name]