Py3k #324

Open
wants to merge 5 commits into from

7 participants

@spulec

I'm skeptical that everything will actually work with python3, but all the tests are passing.

It's a start...

Anything that breaks with python3 should result in a new test.

@danielward

Am I missing something? I've tried to install with pip and easy_install under Python 3.3 and the installation fails. If you need further information please let me know and I'll get it across to you. Maybe I should be installing from the repo rather than PyPI?

@spulec

Can you let us know what fails? A traceback or something?

This pull request hasn't been merged in yet so there is no chance that installing from PyPI will work yet.

@danielward

Forget what I've put, I've realised after going through the issues that this was a pull request (!), I'll look at installing the changes you've submitted and let you know how I get on ;)

@danielward

Right ok, so this is what I've found thus far:

I have to manually install the following packages:

After this, when running lettuce, I'm presented with the following error:

Traceback (most recent call last):
  File "/.../bin/lettuce", line 9, in <module>
    load_entry_point('lettuce==0.2.12', 'console_scripts', 'lettuce')()
  File "/.../lib/python3.3/site-packages/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/.../lib/python3.3/site-packages/pkg_resources.py", line 2566, in load_entry_point
    return ep.load()
  File "/.../lib/python3.3/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/__init__.py", line 35, in <module>
    from lettuce.terrain import after
  File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/terrain.py", line 32, in <module>
    @world.absorb
  File "/.../lib/python3.3/site-packages/lettuce-0.2.12-py3.3.egg/lettuce/terrain.py", line 23, in absorb
    if not isinstance(name, basestring):
NameError: global name 'basestring' is not defined
@apieum
@grigi

@danielward
I also ported sure to py3.2: (in case the pypi version doesn't work for you)
https://github.com/grigi/sure (Python 3 support, which has not yet been merged in to the primary repo)

Also the Py3 porting guide has this to say:
The builtin basestring abstract type was removed. Use str instead. The str and bytes types don’t have functionality enough in common to warrant a shared base class. The 2to3 tool (see below) replaces every occurrence of basestring with str.

Actually to not break Py2 support you should do something like this:

try:
  unicode = unicode
except NameError:
  unicode = str
  basestring = (str, bytes)

I was working on getting all of lettuces dependancies working on Py3 first, once they get merged I was going to tackle lettuce Py3 support. Unfortunately it has been a month since I did the pull requests...

@danielward

I'm not sure if you've looked at it, though six library looks really nice to use as a way of providing both Python 2 and Python 3 support in your projects.

Regarding the syntax changes with Exception as ... , print(...), del(...) etc, I'm pretty sure these changes were back ported to at least 2.7 maybe earlier.

Unfortunately the lack of activity on lettuce has meant me looking at other libraries, and I'm afraid I'll be defecting to behave as the documentation is an improvement and isn't too much of a leap. Contributions for the likes of Python 3 should be of utmost importance but the requests are either being ignored or the repo has become dormant for one reason or another which is a real shame :(

@e0ne

I tried to port lettuce to Py3k. The biggest problem is that python-mox lib is not suppopred since November, 2012. What about migration to mock? It it in Python Standard Library now

@danni
Collaborator

I endorse mock. Also if you're not keen on six, have a look at python-future.

@danni
Collaborator

I've got a branch that extensively refactors the core of Lettuce (#429), I am taking the time as part of this work to try and makes things as Python3/unicode clean as I possibly can. Once this is done I'm going to attempt porting to Python 3 using python-future as the compatibility layer.

@rpaloschi

Hey guys
I think I made some steps... decided to put my work here:
https://github.com/rpaloschi/lettuce

@rpaloschi

It is working with python 3 and django 1.6.2. Maybe we can put all this efforts together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment