textile / python-textile

A Python port of Textile, A humane web text generator
Other
69 stars 23 forks source link

Remove u'' syntax that is unsupported in Py 3.2. #5

Closed mblayman closed 10 years ago

mblayman commented 10 years ago

Include a very basic tox.ini file to run the test suite against multiple versions of Python.

The removal of the u'' syntax is in line with the fact that Python 3 strings are unicode by default.

@ikirudennis, I found that Python 2.7 and Python 3.2 tests were broken so I figured this branch would help make things a little better. You mentioned being 'n00b' so here's some extra explanation to help you out with what I did. Sorry if this is overly pedantic. I try to assume people have minimal knowledge even at the risk of repeating myself or boring you with stuff you already know.

In a nutshell, I gave developer's the ability to quickly test against other versions of Python if those versions are installed on their machines. tox is the tool that makes that possible. My Ubuntu 14.04 machine has Python 2.7, 3.2, 3.3, and 3.4 installed on it. Here is a quick list of commands you could run to get a flavor for this (assuming you have the same versions installed).

$ virtualenv ~/venv
$ source ~/venv/bin/activate
(venv) $ cd python-textile
(venv) $ python setup.py develop
(venv) $ tox -e py27
(venv) $ tox -e py33
(venv) $ tox -e py34
  1. virtualenv lets you create an environment to install stuff without using sudo (i.e. everything you install goes into the virtual environment instead).
  2. Activate the virtualenv.
  3. Install tox via the setup.py file
  4. Run tox on various versions of Python

If all this stuff is goodness for you, I can eventually show you how to integrate this with Travis CI (https://travis-ci.org/). Travis CI would then monitor the repo and run the tests for all the versions automatically each time a commit happens to master. Additionally, each pull request would have the Travis build results showing whether tests passed or failed before you even review it. I think that's very useful. Hopefully you do too.

I'd be happy to do some more on the branch (like adding the initial Travis file) if that's of interest to you.

ikirudennis commented 10 years ago

My earlier comment about being a n00b was more in reference to my experience with pypi in particular. However, I also haven't worked with tox or travis yet, so thanks for those pointers. I will gladly take all the help I can get.

ikirudennis commented 10 years ago

There were also two last issues with the py32 branch that I've fixed in 805c08cd2170e1856800ca60398e60cd03512e52. I'll sort out uploading a py32-specific version to pypi tomorrow.

mblayman commented 10 years ago

Dennis, I see this only got merged into a py32 branch on GitHub. I tried to work on some Travis work so I could submit it for a pull request, but I didn't have my revelation until after I ran into errors showing me that master did not have the changes I proposed.

Are you trying to maintain separate branches rather than have everything be in the master branch? Or am I jumping the gun and you're planning to merge work into master when you think it's ready?

ikirudennis commented 10 years ago

Well, it's a syntactical difference between the versions and as far as I understand, the code just won't run at all on 3.0 - 3.2. We might be able to get around it with from __future__ import unicode_literals but to me it feels more like it was a bug that was fixed in 3.3. This problem requires that the tests for unicode characters be treated differently. That just rubs me the wrong way. Do you have any thoughts on how to proceed?

mblayman commented 10 years ago

I do not have a great answer for this. I have not done a lot of porting to Python 3. I just watched a good relevant talk from PyCon 2014 (http://pyvideo.org/video/2626/by-your-bootstraps-porting-your-application-to-p). That may be a good starting point. Tres also pointed to http://python3porting.com/ which may also offer good advice. I have not read it (yet).

ikirudennis commented 10 years ago

I've tried a bunch of different ways to write the code so that the same tests work on all versions of python, and have not yet found a satisfactory means. Given the following:

I don't feel like spending more time trying to figure this out. If someone else wants to work out a way to have one unified codebase for all versions of python, please submit a pull request.

mblayman commented 10 years ago

That's totally reasonable. Thanks for trying!