Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyroma doesn't work on Windows 10 #28

Closed
sandeepbhat opened this issue Jul 20, 2018 · 6 comments · Fixed by #53
Closed

Pyroma doesn't work on Windows 10 #28

sandeepbhat opened this issue Jul 20, 2018 · 6 comments · Fixed by #53

Comments

@sandeepbhat
Copy link

pyroma fails to run and results in the following error. black is just as an example here. pyroma fails when run on other folders containing python code as well.

Error information

$ pyroma.exe -d black/
------------------------------
Checking black/
Exception when running setup.
Traceback (most recent call last):
  File "c:\users\sanbha\work\black\env\lib\site-packages\pyroma\projectdata.py", line 138, in run_setup
    exec_(f.read(), glocals, glocals)
  File "c:\users\sanbha\work\black\env\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 22: character maps to <undefined>
Traceback (most recent call last):
  File "C:\Users\sanbha\AppData\Local\Programs\Python\Python36\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\sanbha\AppData\Local\Programs\Python\Python36\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\sanbha\work\black\env\Scripts\pyroma.exe\__main__.py", line 9, in <module>
  File "c:\users\sanbha\work\black\env\lib\site-packages\pyroma\__init__.py", line 63, in main
    rating = run(mode, argument)
  File "c:\users\sanbha\work\black\env\lib\site-packages\pyroma\__init__.py", line 75, in run
    data = projectdata.get_data(os.path.abspath(argument))
  File "c:\users\sanbha\work\black\env\lib\site-packages\pyroma\projectdata.py", line 167, in get_data
    distro = run_setup('setup.py', stop_after='config')
  File "c:\users\sanbha\work\black\env\lib\site-packages\pyroma\projectdata.py", line 151, in run_setup
    script_name)
RuntimeError: 'distutils.core.setup()' was never called -- perhaps 'setup.py' is not a Distutils setup script?

Steps to reproduce

  1. Clone black repository → git clone git@github.com:ambv/black.git
  2. Create virtualenvvirtualenv black/
  3. Activate virtualenv$ . env/Scripts/activate
  4. Install pyroma using pippip install pyroma
  5. Run pyromapyroma -d black/

Environment

Operating system: Windows 10 Enterprise
Python version: 3.6.6, PE32+ executable (console) x86-64, for MS Windows
pyroma version: 2.3.1
Bash version: GNU bash, version 4.4.19(2)-release (x86_64-pc-msys)

@regebro regebro pinned this issue Jun 1, 2019
@regebro
Copy link
Owner

regebro commented Jun 1, 2019

Indeed, it seems to not work on Windows.

@regebro regebro changed the title pyroma 2.3.1 not wokring on Windows 10 Pyroma doesn't work on Windows 10 Jun 1, 2019
@CAM-Gerlach
Copy link
Collaborator

CAM-Gerlach commented Mar 6, 2021

Taking a quick glance at the traceback, this looks like a basic mistake that is unfortunately quite common, but very easy to fix. What's likely happening is you're reading setup.py without correctly specifying the encoding (i.e. utf-8, as required by the relevant standards). The default encoding for open in text mode is locale.getpreferredencoding() which defaults to the current ANSI codepage on Windows, most commonly Windows-1252 (cp1252). This is almost never what you want; you should instead always explicitly specify an encoding, i.e. encoding="utf-8". Otherwise, the read will fail with an encoding-related error (as seen here) if the file contains any non-ASCII characters.

@CAM-Gerlach
Copy link
Collaborator

I can confirm that, both with the latest pyroma 3.0.1, and pyroma 2.4 (the latest available on conda), Pyroma works in a test package with a pure-ASCII setup.py, while if I introduce non-ASCII characters within a string literal, I can reproduce the above error. Therefore, very likely the above is the case.

@CAM-Gerlach
Copy link
Collaborator

Indeed, adding encoding="UTF-8" to the offending line 122 of projectdata.py fixes this. I'll submit a PR shortly.

@CAM-Gerlach
Copy link
Collaborator

Opened as PR #53

@CAM-Gerlach
Copy link
Collaborator

@regebro Seems this can be unpinned? Maybe pin the PyPI issue instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants