unitedstates / inspectors-general

Collecting reports from Inspectors General across the US federal government.
https://sunlightfoundation.com/blog/2014/11/07/opengov-voices-opening-up-government-reports-through-teamwork-and-open-data/
Creative Commons Zero v1.0 Universal
107 stars 21 forks source link

pip install -r requirements.txt fails on OS X -- error installing jsonpatch 0.4 #253

Closed audiodude closed 9 years ago

audiodude commented 9 years ago

Looks like it might be a python 3 compatibility issue?

Downloading/unpacking jsonpatch==0.4 (from internetarchive->-r requirements.txt (line 10))
  Downloading jsonpatch-0.4.tar.gz
  Running setup.py (path:/Users/tmoney/.pyenv/versions/inspectors-general/src/internetarchive/setup.py) egg_info for package internetarchive

  Installing extra requirements: 'egg'
Downloading/unpacking jsonpatch==0.4 (from internetarchive->-r requirements.txt (line 10))
  Downloading jsonpatch-0.4.tar.gz
  Running setup.py (path:/Users/tmoney/.pyenv/versions/inspectors-general/build/jsonpatch/setup.py) egg_info for package jsonpatch
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/Users/tmoney/.pyenv/versions/inspectors-general/build/jsonpatch/setup.py", line 13, in <module>
        src = open('jsonpatch.py').read()
      File "/Users/tmoney/.pyenv/versions/inspectors-general/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 173: ordinal not in range(128)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

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

  File "/Users/tmoney/.pyenv/versions/inspectors-general/build/jsonpatch/setup.py", line 13, in <module>

    src = open('jsonpatch.py').read()

  File "/Users/tmoney/.pyenv/versions/inspectors-general/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 173: ordinal not in range(128)

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/tmoney/.pyenv/versions/inspectors-general/build/jsonpatch
Storing debug log for failure in /var/folders/bv/35gtt13d7wv0rqkcjrkbqx100000gp/T/tmphay4dn7q
audiodude commented 9 years ago

I tried a fresh virtualenv but it didn't help, FYI.

audiodude commented 9 years ago

I've also opened stefankoegl/python-json-patch/issues/42

divergentdave commented 9 years ago

Can't reproduce this on Windows or Linux. It looks like this would probably be fixed by stefankoegl/python-json-patch@45b44b7e41e56de101b1dd0ce34bd572798abfd5 in newer versions of jsonpatch. Unfortunately even the latest upstream version of jjjake/internetarchive still requires jsonpatch==0.4.

(By the way, jjjake/internetarchive supports Python 3 as of jjjake/internetarchive#76, so we probably should use a newer release instead of the git repo)

divergentdave commented 9 years ago

Oh awkward, looks like the internetarchive project is intentionally using an older version of jsonpatch, which complies with a draft version of the JSON patch standard, while newer versions of the jsonpatch package comply with the RFC version. See https://github.com/jjjake/internetarchive/commit/d6e5749f248bfd54a423be0e803fe9138a3aa257

As a workaround, could you try running PYTHONIOENCODING=utf-8 pip install -r requirements.txt or LC_CTYPE=en_US.UTF-8 pip install -r requirements.txt? The environment variable hack should only be necessary at installation time, since the bug is just in setup.py.

audiodude commented 9 years ago

That worked, good thinking!