seanfisk/python-project-template

Python 3.3 support

Closed this issue · 8 comments

Python 3.3 support

After fixing a couple syntax problems, I've encountered the first problem: pyfiglet does not support Python 3.

Options are:

  • Discard use of pyfiglet. Wouldn't be a big deal since it's just used to print out test success or failure.
  • Add Python 3 support to pyfiglet. Not sure how big an undertaking this would be.

@seanfisk I would suggest to discard it. I guess we wouldn't use it for anything else except printing test success and failure. This is something we could either print normally or create or own print statements for printing the larger font.

That's correct; it isn't being used for anything else but printing success or failure. I originally put it in because I enabled verbosity when running py.test and it became hard to see if the entire test suite+flake8 passed or failed. I just wanted an obvious indicator at the end.

When looking at pyfiglet, this brought up another issue that pyfiglet is licensed under the GPL. I'm not a lawyer, so I'm not sure whether this applies to using it in a package, the generated output, or both. What is said in the README makes it sound like both:

Q. Can I use/modify/redstribute this code?
A. Yes, under the terms of the GPL (see LICENSE below).

It's probably best to be careful, especially for a non-important package like this. I like the big text, so I'm thinking a reasonable solution would be to regenerate the text with figlet (which is itself distributed under the New BSD License) and embed the generated text in pavement.py. Thoughts?

This also prompted me to create another issue for clarifying licenses.

@seanfisk Are you working on this? Or would you like to see some PR to get this solved?

I started on it about a week ago, but work has been very busy lately. If you have time and would like to start on it and submit a PR, by all means go ahead. Here is the only thing I changed (in pavement.py):

# Python 3 compat:
# - filter returns a generator, but we actually want a list.
# - The result of subprocess call outputs are byte strings, meaning we need
#   to pass a byte string to endswith.
git_python_files = list(filter(
    lambda filename: filename.endswith(b'.py'),
    get_project_files()))

I have pushed a python3 branch for 3.3 support to Github. Will be merged pending testing.

I managed to review the python3 branch. I also ran the 2to3 script on the generated code which gave the recommendation to use list comprehension instead of filter call. I updated the python3 branch accordingly.

In my opinion this is ready now for merging into master.

Thanks, Ben. I probably should have just done that right from the beginning.