nedbat / coveragepy

The code coverage tool for Python
https://coverage.readthedocs.io
Apache License 2.0
2.96k stars 428 forks source link

Unicode decode error when put coverage into setup script in Windows #539

Open nedbat opened 7 years ago

nedbat commented 7 years ago

Originally reported by Chen Huang (Bitbucket: chinux23, GitHub: chinux23)


I am using Windows 10 with Anaconda 64 bit python 3.5. It seems I can't put coverage as part of a requirement in any setup scripts.

For example, running the following setup script will fail:

#!python

'''
Copyright (c) 2016 Test. All rights reserved.
'''
from setuptools import setup

setup(
    name='testpackage',
    version='1.0',
    description='test',
    author='test',
    author_email='',
    long_description="HelloWorld",
    license='BSD',
    classifiers=[],
    install_requires=[
        'pytz',
        'coverage'
    ],
)
Installed c:\users\chen\anaconda3\lib\site-packages\testpackage-1.0-py3.5.egg
Processing dependencies for testpackage==1.0
Searching for coverage==4.2
Best match: coverage 4.2
Processing coverage-4.2-py3.5-win-amd64.egg
coverage 4.2 is already the active version in easy-install.pth
Installing coverage-3.5-script.py script to C:\Users\Chen\Anaconda3\Scripts
Traceback (most recent call last):
  File "setup2.py", line 17, in <module>
    'coverage'
  File "C:\Users\Chen\Anaconda3\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\Chen\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Users\Chen\Anaconda3\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\install.py", line 67, in run
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\install.py", line 117, in do_egg_install
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 409, in run
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 645, in easy_install
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 696, in install_item
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 751, in process_distribution
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 664, in easy_install
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 699, in install_item
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 721, in process_distribution
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\setuptools\command\easy_install.py", line 599, in install_egg_scripts
  File "C:\Users\Chen\Anaconda3\lib\site-packages\setuptools-27.2.0-py3.5.egg\pkg_resources\__init__.py", line 1469, in get_metadata
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

Any thoughts?

By revmoing "coverage" in the setup script, the install script pass.


nedbat commented 7 years ago

Original comment by Félix Antoine Goudreault (Bitbucket: fgoudreault, GitHub: fgoudreault)


Yes, pip install -e seems to work.

nedbat commented 7 years ago

@fgoudreault does "pip install -e ." work for you?

nedbat commented 7 years ago

Original comment by Félix Antoine Goudreault (Bitbucket: fgoudreault, GitHub: fgoudreault)


I used python setup.py develop where setup.py looks like:

#!python

from setuptools import setup
import versioneer

setup(name="name",
      description="description",
      url="url",
      install_requires=["nose", "pep8", "coverage", "openpyxl"],
      version=versioneer.get_version(),
      cmdclass=versioneer.get_cmdclass())
nedbat commented 7 years ago

@fgoudreault thanks for the link to the pypa issue. I didn't know about that one. It mentions easy_install. Can you show the specific commands you are using to run the installation? @chinux23 What commands did you use to install?

nedbat commented 7 years ago

Original comment by Félix Antoine Goudreault (Bitbucket: fgoudreault, GitHub: fgoudreault)


I got the same error on windows 10 pro using Miniconda in a virtual env. conda version: 4.3.22 python version: 3.6.1

Also, removing coverage in the install requires fixes the issue. Installing coverage through pip before calling the setup fixes the issue also. There is an issue on setuptools about that : https://github.com/pypa/setuptools/issues/819

nedbat commented 7 years ago

Hmm, I have no idea why that would happen. I don't know where there's a 0x90 byte in the coverage.py metadata.

Is there any way you could debug into pkg_resources__init__.py to see what it's looking at?