mikeboers / Flask-Images

On-demand resizing of images for Flask applications.
https://mikeboers.github.io/Flask-Images/
BSD 3-Clause "New" or "Revised" License
81 stars 43 forks source link

Python3 support #34

Closed wzuo closed 6 years ago

wzuo commented 9 years ago

Added support for Python 3 - works with 3.4.0 without any problem :)

wzuo commented 9 years ago

Build passing :)

mikeboers commented 9 years ago

Seems like the usual suspects needed changing. Thanks for finding them all!

I'd like to see the 2-vs-3 code collected into one place though; I don't like the Python version logic interspersed with the image handling logic. Perhaps a pycompat module which contains functions that encapsulate all of that logic.

Or, even better: if everything we need is satisfiable by six, we mimic that API (or lift what we need (and reproduce the license)).

wzuo commented 8 years ago

Changed to use six library :smile:

keybits commented 8 years ago

This looks good to me. Can you merge and do a release to make it pip installable?

wzuo commented 8 years ago

Could you please finally merge it? It is annyoing to install Flask-Images without pip support :(

iurisilvio commented 8 years ago

Looks good and it is already time to be py3 friendly. :+1:

mikeboers commented 8 years ago

I do appreciate the enthusiasm from everyone, but I disagree that it looks good. There is at least one regression (the HTTPError handling).

I've rebased/squashed these into a single commit on the current master, at 85f6730 (the py3 branch).

I do not have the time to comb through this right now, especially since I would like to add some more tests to be able to catch that regression automatically. It will be at least 2 weeks before I can think about doing it. Even then... I have "real" work to do to pay the bills, you know?

Until then, if you want to use @wzuo's code as-is, you can pip install -e git+https://github.com/wzuo/Flask-Images.git#egg=Flask-Images

wzuo commented 8 years ago

Could you please write how to reproduce that HTTPError regression? I can look on fixing it

mikeboers commented 8 years ago

It is just missing an import of the right exception class.

Really, I'm fighting the pile-on of :+1: that would pressure me to immediately merge and release something that isn't thoroughly tested (which is my own fault, but this isn't much more than a personal project for my own sites).

mikeboers commented 8 years ago

Oh, and you can trigger it by requesting an image from something that will return an error code. https://httpbin.org/status/418 (etc.) would do wonderfully for that.

Leustad commented 7 years ago

Am I missing something? I'm using python 3.4.0 in a virtualenv and I'm still getting ImportError: No module named 'cStringIO' with from flask.ext.images import Images

wzuo commented 7 years ago

it is removed in my branch, do you my branch? master does not support py3 afaik

Leustad commented 7 years ago

@wzuo Yea I've got it from pip install -e git+https://github.com/wzuo/Flask-Images.git#egg=Flask-Images. Think this is your branch. It works. thank you for your time

emmanuelito commented 6 years ago

No documented way to use Flask-Image with Python 3 ?

Can't install the branch:

pip install -e git+https://github.com/wzuo/Flask-Images.git#egg=Flask-Images Obtaining Flask-Images from git+https://github.com/wzuo/Flask-Images.git#egg=Flask-Images Updating ./src/flask-images clone git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists. fatal: clone of 'git@github.com:mitsuhiko/flask-sphinx-themes.git' into submodule path '.../src/flask-images/docs/_themes' failed Failed to clone 'docs/_themes'. Retry scheduled git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

wzuo commented 6 years ago

@emmanuelito I'm installing it via Dockerfile this way:

(stat /tmp/Flask-Images || git clone --depth 1 https://github.com/wzuo/Flask-Images /tmp/Flask-Images) && pip install -e /tmp/Flask-Images

If you don't use Docker then you need to clone and pip install from directory. I've been struggling with installing from pip directly via git, so I decided to make workaround. It works perfectly for my projects, even that it's 3 years old PR.

ovionlogis commented 6 years ago

@wzuo Hi, I had a problem with the wrong build of a link to the picture. The links looked something like this:

/image.jpg?v=WzdUWw&w=480&s=b'PKgfqQAtQuvQseN6-gErB3tRjtM'

The whole problem in the s parameter, looks like the bytes are converted incorrectly into a string. I fixed this problem in my commit https://github.com/ovionlogis/Flask-Images/commit/9821feff51c84cae3176f3c4ab30255da85fcd49

mikeboers commented 6 years ago

Welp... I finally fixed the issues in the tests, released as 3.0.0, THEN read this through again and saw the HTTPError, wrote a test, and am waiting on 3.0.1 to pass CI.

"Official" Python3 support has landed.