disqus / disqus-python

Disqus API bindings for Python
https://disqus.com/api/docs/
Apache License 2.0
165 stars 51 forks source link

Python 3 support #22

Closed ShaunaGordon closed 10 years ago

ShaunaGordon commented 10 years ago

Considering the Python maintainers say that Python 3 is the "current and future version," and Python 2 is "legacy," it seems to make sense to port disqus-python to Python 3. As stands, it's unusable in a Python 3 environment, and a tool like auto2to3 fails with an ImportError (no module named 'disqus_static').

For starters, in Python 3, httplib was changed to http.client (see also: http://stackoverflow.com/questions/13778252/import-httplib-importerror-no-module-named-httplib).

mattrobenolt commented 10 years ago

master already supports python 3 and has passing tests, we just need to cut a release after it's been tested.

If you want to run master and give feedback, that'd be awesome.

mattrobenolt commented 10 years ago

Also looking at this, I have no idea where "disqus_static" is coming from considering that doesn't exist in the code anywhere. Can you show me the full dump of that ImportError?

ShaunaGordon commented 10 years ago

I was using disqus-python via Pelican's disqus_static plugin. Apologies for the conflation, that error is probably related more to that than this repo.

That said, I did try to install disqus-python from the git repo, via pip and received the following error (admittedly, I'm a bit of a Python newb, though this seemed a "not-my-fault" error):

Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3.4/site-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python3.4/site-packages/pip/req.py", line 1197, in prepare_files
    do_download,
  File "/usr/lib/python3.4/site-packages/pip/req.py", line 1375, in unpack_url
    self.session,
  File "/usr/lib/python3.4/site-packages/pip/download.py", line 582, in unpack_http_url
    unpack_file(temp_location, location, content_type, link)
  File "/usr/lib/python3.4/site-packages/pip/util.py", line 627, in unpack_file
    and is_svn_page(file_contents(filename))):
  File "/usr/lib/python3.4/site-packages/pip/util.py", line 210, in file_contents
    return fp.read().decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

(Python 3.4.1, pip 1.5.6 on Arch)

mattrobenolt commented 10 years ago

Oh, that's concerning. Lemme test that out.

mattrobenolt commented 10 years ago

Hmm, were you installing anything else at the same time? I can't recreate that. That looks like a different dependency failing.

Can you paste the full output of:

pip install https://github.com/disqus/disqus-python/archive/master.zip
ShaunaGordon commented 10 years ago

That worked.

TIL: Pip prefers (requires?) git+ in front of both SSH and https.

Thanks for putting up with my Python noobness.

mattrobenolt commented 10 years ago

It wants git+ if you're trying to actually access the git repository, because it needs to know to run git clone instead of just downloading a file and extracting it, which I assume is what happened in your utf8 error.

mattrobenolt commented 10 years ago

For example:

$ pip install git+https://github.com/disqus/disqus-python.git

vs

$ pip install https://github.com/disqus/disqus-python/archive/master.zip

The first one is the actual git repository, and the latter is a zipfile of the repository. The first needs to be run with git clone and the latter can just be downloaded and extracted.