Distribution with PIL

32 views
Skip to first unread message

Greg Fuller

unread,
Mar 1, 2009, 11:45:58 AM3/1/09
to web2py Web Framework
Web2Py is fantastic for packaging your application into a trial
version that can just be downloaded, unpacked and run - without
dependencies. No other framework I'm aware of can do this.

The one snag is PIL. The applications I write usually require an
imaging library. I know that PIL is not pure python, and requires a
compile step because of the C code. But I have also been able to find
binary distributions for the platforms I've worked on - OS/X and
Windows. I would think there is also a Linux binary distribution
available. But, no problem there -- PIL has been available on the
Linux platforms I've deployed on (like webfaction).

If I'm reading the PIL license correctly on pythonware.com, it can be
distributed. So, are there any technical difficulties or licensing
reasons why a PIL binaries should not be included in a distribution?

Thanks,

--greg--

mdipierro

unread,
Mar 1, 2009, 11:52:08 AM3/1/09
to web2py Web Framework
I agree with you that PIL is very useful.
The issue is we need to draw a line somewhere.
Lots of people need additional packages and we cannot include them
all.
After all, why is PIL not included in Python?

If we were to include PIL in web2py we would have to take care of
updates and binaries and we would have to guarantee backward
compatibility of a third party package. Things will become un-
manageble fast.

This is not a straight NO. This is a NO for now and a call for
comments.

Massimo

Greg Fuller

unread,
Mar 1, 2009, 12:05:52 PM3/1/09
to web2py Web Framework
I intentionally left it open as to whether I was talking about a
web2py distribution or an application package or an application
package with web2py included :)

I would like to see it in web2py, but if not, I would probably try to
bundle it myself.

If I'm not mistaken python does bundle cpickle, but cpickle is just a
fast clone of pickle. I think there is no python only version of
PIL. Anyway, Web2Py has different priorities than Python.

IMHO, I would be a great benefit to web2py to have PIL included if it
could be done with good success rate - not even 100%. Maybe it could
initially be included as an "experimental" capability or something.

--greg--

Markus Gritsch

unread,
Mar 1, 2009, 2:54:14 PM3/1/09
to web...@googlegroups.com
On Sun, Mar 1, 2009 at 6:05 PM, Greg Fuller <greg...@gmail.com> wrote:
>
> IMHO, I would be a great benefit to web2py to have PIL included if it
> could be done with good success rate - not even 100%.  Maybe it could
> initially be included as an "experimental" capability or something.

Massimo is right with his arguments agaimst inclusion. The next would
come and would like to have NumPy or some other big Package included.
Let's keep the binary package reasonably small, and not create a
monster which would be hard to maintain.

Markus

Greg Fuller

unread,
Mar 1, 2009, 2:59:42 PM3/1/09
to web2py Web Framework
I've noticed a good number, and probably a sizable percentage, of
web2py applications are using PIL. Same with Django. I'm not sure
that's true of NumPy or any other external app. But I do see the
point.

On Mar 1, 1:54 pm, Markus Gritsch <m.grit...@gmail.com> wrote:

Yarko Tymciurak

unread,
Mar 1, 2009, 3:15:27 PM3/1/09
to web...@googlegroups.com
since YOU can package your distribution for a target environment (and are free to include what additional libraries your application for your client needs), it seems to me no reason to load down a base distribution with other than what is always used, and base development support.

Greg Fuller

unread,
Mar 1, 2009, 3:30:23 PM3/1/09
to web2py Web Framework
True enough. Could probably do a plugin which would test for the
environment, import as, etc. Then the work could still be shared
without loading down the base.

But darnit, I was hoping all 842 members would raise their voices in
unison for this idea. :)

--greg--

On Mar 1, 2:15 pm, Yarko Tymciurak <yark...@gmail.com> wrote:
> since YOU can package your distribution for a target environment (and are
> free to include what additional libraries your application for your client
> needs), it seems to me no reason to load down a base distribution with other
> than what is always used, and base development support.
>

Jason Brower

unread,
Mar 1, 2009, 3:43:35 PM3/1/09
to web...@googlegroups.com
I just used pil today, and I don't think it's a good idea. I think if
we keep it as small as possible we can really make a powerful system.
A plugin system would be nice for non python OS's for example mac and
windows, it would be easier to use the import tools in python to get
PIL, for example. But in linux distros almost always have packages to
handle this stuff. You may get an uproar if you skipped the distros way
of installing new python libraries.
Regards,
Jason

Greg Fuller

unread,
Mar 1, 2009, 3:52:14 PM3/1/09
to web2py Web Framework
You're right. I don't see this for production. But it would be nice
to distribute a "fully" self contained trial version of an app for
non-python-literate, non-developer, potential app users, to take for
a spin on localhost. At any rate, it's something I'll explore on my
own.

Pedro

unread,
Mar 1, 2009, 3:58:36 PM3/1/09
to web2py Web Framework
I am not sure what point is discussed in here. What's the advantage of
including it in web2py if you can simply drop it in the modules
folder?

Greg Fuller

unread,
Mar 1, 2009, 4:08:29 PM3/1/09
to web2py Web Framework
It may benefit from a little glue code since there are different
binaries for different platforms. To check for environment, import
as, or try/except, etc. But maybe not - I could be making it more
complex than it needs to be. I do that sometimes.

mdipierro

unread,
Mar 1, 2009, 6:22:18 PM3/1/09
to web2py Web Framework
I think what we really need is package easy_install with web2py.

If your app needs PIL, it will check if it is there else call
easy_install. It would work with every python module.

If anybody could send me a patch or an example to make this work
programmatically I will include it.

Massimo

Greg Fuller

unread,
Mar 1, 2009, 7:47:20 PM3/1/09
to web2py Web Framework
This might work smoothly for pure python modules, but....

When I tried to easy_install PIL on my mac, -- I think I remember
correctly -- it failed to build because xcode was not available. When
I installed xcode, it still would not build. So I tried a ports
package and that did not work. I finally found a pre-compiled binary.

This whole area of builds and such is hazy to me - it was a struggle
for me to get it working. I found lots of others who had the same
problem. But maybe that was because they were just as unfamiliar with
the territory as I was.

I admit I don't fully understand this -- but if easy_install depends
on the right compilers being available for non-pure-python packages,
then the easy_install solution might be iffy at best.

--greg--

Yarko Tymciurak

unread,
Mar 2, 2009, 1:10:08 AM3/2/09
to web...@googlegroups.com
I also think for linux sites (ubuntu, fedora, centos, etc.)  you would use the yum / apt-get / rpm installation methods in preference to easy_install...

I think this - and particularly this on shared hosts - might be a reason to perhaps _not_ do this (unless we supply this only for mac and pc)

Wes James

unread,
Mar 2, 2009, 5:25:32 PM3/2/09
to web...@googlegroups.com
On Sun, Mar 1, 2009 at 5:47 PM, Greg Fuller <greg...@gmail.com> wrote:
>
> This might work smoothly for pure python modules, but....
>
> When I tried to easy_install PIL on my mac, -- I think I remember
> correctly -- it failed to build because xcode was not available. When
> I installed xcode, it still would not build. So I tried a ports
> package and that did not work. I finally found a pre-compiled binary.

Follow these to manual install PIL:

PIL - http://www.pythonware.com/products/pil/
freetype - http://www.freetype.org/
jpegsrc - http://www.ijg.org/
libpng - http://www.libpng.org/pub/png/libpng.html

Install libpng:

1. tar -jxf libpng-1.2.16.tar.bz2
2. cd libpng-1.2.16
3. ./configure
4. make install

Install jpegsrc:

1. tar -zxf jpegsrc.v6b.tar.gz
2. cd jpeg-6b'
3. ./configure
4. make install
5. make install-lib

Install freetype (optional):

1. tar -jxf freetype-2.3.1.tar.bz2
2. cd freetype-2.3.1
3. ./configure
4. make install

Install PIL:

1. tar -zxf Imaging-1.1.6.tar.gz
2. cd Imaging-1.1.6
3. python setup.py build
4. Should get this output
--------------------------------------------------------------------
--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok
--------------------------------------------------------------------
5. now run: python setup.py install


-wj

Jonathan B

unread,
Mar 3, 2009, 3:51:48 AM3/3/09
to web2py Web Framework
I'm with Massimo and Yarko on this one.

A big part of what makes web2py great is the fact that you can just
download it and run it, with no dependencies. This was the #1 feature
that got me to use web2py. I took a look at Django and saw how much
effort it would be to set it up on my home computer (which uses
Windows). Instead, I downloaded web2py and ran it, and it worked. It
was an easy decision.

Every dependancy we add to web2py makes this feature harder to
maintain. Any platform-dependant (i.e. not pure Python) dependancy
puts this feature at serious risk.

I don't think it's very onerous to expect the app developer to find
and include all of the additional dependencies in their package. (1)
They need to find the dependencies anyway to do their development
work, (2) they know which platforms they're targeting, which may be a
small subset of all of the platforms supported by web2py.

As a community, we can help out in our FAQ and help documentation by
listing all of the common external packages, and how to find them and
package them with web2py.

--Jonathan

Maurice Ling

unread,
Mar 5, 2009, 6:43:59 AM3/5/09
to web2py Web Framework
Sorry for the very late reply...
I've also needed a number of 3rd party modules for my application and
what I did is to run web2py through a shell script... for example, in
Windows...

set python_directory=c:\Python25

python ez_setup.py

if errorlevel 1 goto setpath
if errorlevel 0 goto check_python_modules

:setpath
set PATH=%PATH%;%python_directory%;%python_directory%/Scripts
python ez_setup.py
goto check_python_modules

:check_python_modules
easy_install "biopython==1.49"
goto run_web2py

:run_web2py
python web2py.py --ip=localhost --port=8000 --password=admin

works well....
Maurice

Maurice Ling

unread,
Mar 5, 2009, 7:13:46 AM3/5/09
to web2py Web Framework
Sorry for the very late reply...
I've also needed a number of 3rd party modules for my application and
what I did is to run web2py through a shell script... for example, in
Windows...

set python_directory=c:\Python25

python ez_setup.py

if errorlevel 1 goto setpath
if errorlevel 0 goto check_python_modules

:setpath
set PATH=%PATH%;%python_directory%;%python_directory%/Scripts
python ez_setup.py
goto check_python_modules

:check_python_modules
easy_install "biopython==1.49"
goto run_web2py

:run_web2py
python web2py.py --ip=localhost --port=8000 --password=admin

works well....
Maurice

AchipA

unread,
Mar 6, 2009, 1:45:31 PM3/6/09
to web2py Web Framework
Including everything is bloat. Making implementing a distribution
system is an overkill. The first thing we could do, however is
introduce a way for the apps to signal the framework what modules do
they need (esp with regard to versions). Sometimes just a note in the
admin about these dependencies would be helpful and make it easier to
avoid trial-and-error installs of applications with a lot of
dependancies.

Another issue, somewhat linked to this is the version of web2py
itself. Is there a way for the app to detect that the web2py version
it is run on is older than it requires ?

Jonathan B

unread,
Mar 8, 2009, 1:42:31 AM3/8/09
to web2py Web Framework


On Mar 6, 9:45 pm, AchipA <attila.cs...@gmail.com> wrote:
> Another issue, somewhat linked to this is the version of web2py
> itself. Is there a way for the app to detect that the web2py version
> it is run on is older than it requires ?

From checking the Admin application code (web2py\web2py\applications
\admin\controllers\default.py):


WEB2PY_VERSION_URL = 'http://mdp.cti.depaul.edu/examples/default/
version'


myversion = request.env.web2py_version
version = urllib.urlopen(WEB2PY_VERSION_URL).read()

if version > myversion:
return A(T('A new version of web2py is available'),
_href=WEB2PY_URL)
else:
return A(T('web2py is up to date'), _href=WEB2PY_URL)

mdipierro

unread,
Mar 8, 2009, 11:39:51 AM3/8/09
to web2py Web Framework
Yes, request.env.web2py_version contains the current version

AchipA

unread,
Mar 8, 2009, 3:33:15 PM3/8/09
to web2py Web Framework
I haven't been clear enough. You can check/install stuff yourself
based on detected versions (you could try/catch for PIL and install it
from your app but that would feel wrong, wouldn't it ?). There is no
way to 'suggest' or help installations by dependancies (either
external like PIL, or internal like the web2py version or T2/T3).

For example, when generating/compiling the application bundle, the
web2py version could be included in the application, so when you
deploy, you get a notification if the application was originally
created on a newer web2py version. Not sure how feasible it is, but a
simple scan of import statements in controllers and modules could also
build a checklist which in turn could be validated in the admin. Oh,
and this would be yet another candidate for the 'nobody else does it'
category :)
Reply all
Reply to author
Forward
0 new messages