# Buggy code
def run_egg_info(self):
    assert self.source_dir
    if self.name:
        logger.debug(
            "Running setup.py (path:%s) egg_info for package %s",
            self.setup_py,
            self.name,
        )
    else:
        logger.debug(
            "Running setup.py (path:%s) egg_info for package from %s",
            self.setup_py,
            self.link,
        )

    with indent_log():
        script = self._run_setup_py
        script = script.replace("__SETUP_PY__", repr(self.setup_py))
        script = script.replace("__PKG_NAME__", repr(self.name))
        base_cmd = [sys.executable, "-c", script]
        if self.isolated:
            base_cmd += ["--no-user-cfg"]
        egg_info_cmd = base_cmd + ["egg_info"]
        # We can't put the .egg-info files at the root, because then the
        # source code will be mistaken for an installed egg, causing
        # problems
        if self.editable:
            egg_base_option = []
        else:
            egg_info_dir = os.path.join(self.source_dir, "pip-egg-info")
            ensure_dir(egg_info_dir)
            egg_base_option = ["--egg-base", "pip-egg-info"]
        cwd = self.source_dir
        if self.editable_options and "subdirectory" in self.editable_options:
            cwd = os.path.join(cwd, self.editable_options["subdirectory"])
        call_subprocess(
            egg_info_cmd + egg_base_option,
            cwd=cwd,
            show_stdout=False,
            command_level=logging.DEBUG,
            command_desc="python setup.py egg_info",
        )

    if not self.req:
        if isinstance(pkg_resources.parse_version(self.pkg_info()["Version"]), Version):
            op = "=="
        else:
            op = "==="
        self.req = pkg_resources.Requirement.parse(
            "".join(
                [
                    self.pkg_info()["Name"],
                    op,
                    self.pkg_info()["Version"],
                ]
            )
        )
        self._correct_build_location()
    else:
        metadata_name = canonicalize_name(self.pkg_info()["Name"])
        if canonicalize_name(self.req.project_name) != metadata_name:
            raise InstallationError(
                "Running setup.py (path:%s) egg_info for package %s "
                "produced metadata for project name %s"
                % (self.setup_py, self.name, metadata_name)
            )


# Traceback (UnicodeDecodeError)
$ pip wheel --wheel-dir .  -v pysmfDownloading/unpacking pysmf
Downloading pysmf-0.1.1.tar.gz (50kB):
Downloading from URL https://pypi.python.org/packages/source/p/pysmf/pysmf-0.1.1.tar.gz#md5=8354f3cd7752b12e2668d4ed9aaa25c9 (from https://pypi.python.org/simple/pysmf/)
...Downloading pysmf-0.1.1.tar.gz (50kB): 50kB downloaded
Storing download in cache at ./.pip_download_cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpysmf%2Fpysmf-0.1.1.tar.gz
Running setup.py (path:/home/chris/tmp/pip_build_chris/pysmf/setup.py) egg_info for package pysmf
running egg_info
creating pip-egg-info/pysmf.egg-info
writing pip-egg-info/pysmf.egg-info/PKG-INFO
writing top-level names to pip-egg-info/pysmf.egg-info/top_level.txt
writing dependency_links to pip-egg-info/pysmf.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/pysmf.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found

reading manifest file 'pip-egg-info/pysmf.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/pysmf.egg-info/SOURCES.txt'
Building wheels for collected packages: pysmf
Running setup.py bdist_wheel for pysmf
Destination directory: /home/chris
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1623: ordinal not in range(128)
Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/chris/tmp/pip_build_chris/pysmf/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /home/chris:
Traceback (most recent call last):

File "<string>", line 1, in <module>

File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode

return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1623: ordinal not in range(128)

----------------------------------------
Failed building wheel for pysmf
Failed to build pysmf
Cleaning up...
Removing temporary dir /home/chris/tmp/pip_build_chris...

# Fixed code
def run_egg_info(self):
    assert self.source_dir
    if self.name:
        logger.debug(
            "Running setup.py (path:%s) egg_info for package %s",
            self.setup_py,
            self.name,
        )
    else:
        logger.debug(
            "Running setup.py (path:%s) egg_info for package from %s",
            self.setup_py,
            self.link,
        )

    with indent_log():
        script = self._run_setup_py % self.setup_py
        base_cmd = [sys.executable, "-c", script]
        if self.isolated:
            base_cmd += ["--no-user-cfg"]
        egg_info_cmd = base_cmd + ["egg_info"]
        # We can't put the .egg-info files at the root, because then the
        # source code will be mistaken for an installed egg, causing
        # problems
        if self.editable:
            egg_base_option = []
        else:
            egg_info_dir = os.path.join(self.source_dir, "pip-egg-info")
            ensure_dir(egg_info_dir)
            egg_base_option = ["--egg-base", "pip-egg-info"]
        cwd = self.source_dir
        if self.editable_options and "subdirectory" in self.editable_options:
            cwd = os.path.join(cwd, self.editable_options["subdirectory"])
        call_subprocess(
            egg_info_cmd + egg_base_option,
            cwd=cwd,
            show_stdout=False,
            command_level=logging.DEBUG,
            command_desc="python setup.py egg_info",
        )

    if not self.req:
        if isinstance(pkg_resources.parse_version(self.pkg_info()["Version"]), Version):
            op = "=="
        else:
            op = "==="
        self.req = pkg_resources.Requirement.parse(
            "".join(
                [
                    self.pkg_info()["Name"],
                    op,
                    self.pkg_info()["Version"],
                ]
            )
        )
        self._correct_build_location()
    else:
        metadata_name = canonicalize_name(self.pkg_info()["Name"])
        if canonicalize_name(self.req.project_name) != metadata_name:
            raise InstallationError(
                "Running setup.py (path:%s) egg_info for package %s "
                "produced metadata for project name %s"
                % (self.setup_py, self.name, metadata_name)
            )