jaraco/configparser

CI tests fail to run on Windows

jaraco opened this issue · 2 comments

After adding Windows CI support through Azure Pipelines, I find the project fails to run with this traceback:

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\site-packages\pip\_internal\cli\base_command.py", line 228, in _main
    status = self.run(options, args)
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\site-packages\pip\_internal\cli\req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\site-packages\pip\_internal\commands\install.py", line 245, in run
    options.use_user_site = decide_user_install(
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\site-packages\pip\_internal\commands\install.py", line 664, in decide_user_install
    if site_packages_writable(root=root_path, isolated=isolated_mode):
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\site-packages\pip\_internal\commands\install.py", line 609, in site_packages_writable
    get_lib_location_guesses(root=root, isolated=isolated))
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\site-packages\pip\_internal\commands\install.py", line 600, in get_lib_location_guesses
    scheme = distutils_scheme('', user=user, home=home, root=root,
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\site-packages\pip\_internal\locations.py", line 109, in distutils_scheme
    d.parse_config_files()
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\distutils\dist.py", line 406, in parse_config_files
    parser.read(filename)
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\configparser.py", line 697, in read
    self._read(fp, filename)
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\configparser.py", line 1017, in _read
    for lineno, line in enumerate(fp, start=1):
  File "C:\hostedtoolcache\windows\Python\3.8.5\x64\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 82: character maps to <undefined>

It fails on the python -m pip install tox step when pip notices there's a setup.cfg file so tries to read it using distutils and chokes when it finds a character that's not in codepage 1252. For crying out loud; what year is it?

Now that the issue is fixed in pip, it's failing with the same error in setuptools_scm:

    File "C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-7xz4eosx\overlay\Lib\site-packages\setuptools_scm\integration.py", line 113, in infer_version
      dist_name = _read_dist_name_from_setup_cfg()
    File "C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-7xz4eosx\overlay\Lib\site-packages\setuptools_scm\_integration\setuptools.py", line 17, in read_dist_name_from_setup_cfg
      parser.read([input])
    File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\configparser.py", line 698, in read
      self._read(fp, filename)
    File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\configparser.py", line 1021, in _read
      for lineno, line in enumerate(fp, start=1):
    File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\encodings\cp1252.py", line 23, in decode
      return codecs.charmap_decode(input,self.errors,decoding_table)[0]
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 62: character maps to <undefined>
  [end of output]

After addressing the issue upstream in setuptools_scm, I see the non-ascii in setup.cfg is still triggering a failure in pip when it calls into its vendored version of distutils. There's almost no hope in fixing that, so I'm just going to declare failure and disable the test permanently.