Repository navigation
Closed
Labels
Description
I was trying to figure out which version of pillow (PIL) is installed, and stumbled on this:
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> PIL.version
<module 'PIL.version' from 'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\PIL\\version.py'>
>>> help(PIL.version)
Help on module PIL.version in PIL:
NAME
PIL.version - # Master version for Pillow
VERSION
5.1.0
FILE
c:\users\me\appdata\local\programs\python\python36\lib\site-packages\pil\version.py
>>> help(PIL)
Help on package PIL:
NAME
PIL
DESCRIPTION
# The Python Imaging Library.
# $Id$
#
# package placeholder
#
# Copyright (c) 1999 by Secret Labs AB.
#
# See the README file for information on usage and redistribution.
#
PACKAGE CONTENTS
BdfFontFile
BlpImagePlugin
...
>>> PIL.VERSION
'1.1.7'
>>> PIL.version.__version__
'5.1.0'
>>> PIL.PILLOW_VERSION
'5.1.0'
>>> PIL.__version__
'5.1.0'
>>>- it's confusing that PIL.VERSION returns the version string of the former PIL instead of Pillow's
- there does not seem to be documentation on this version number (why this, will it ever change, ..) e.g. at https://pillow.readthedocs.io/en/5.1.x/about.html#why-a-fork
- it's confusing that PIL.version is a module and does not return the version information directly or hints on how to get it
- the package information header is essentially useless (placeholder, does not even mention Pillow, nor the version)
- PIL.version module documentation comment could explain how to access the version information
Others also have trouble finding it: https://stackoverflow.com/questions/44739775/how-to-get-python-pil-version
Source files:
Activity
aclark4life commentedon Apr 8, 2018
@gnbl A fork, by definition, is confusing. We're open to considering any specific changes you suggest to make Pillow versioning less confusing (preferably in the form of a pull request!) As far as I know, it's possible we could drop the 1.1.7 at some point. At least, I can't think of any specific reason why we couldn't do that…
gnbl commentedon Apr 9, 2018
@aclark4life And there I thought you would be happy if someone took the time to point out an issue (admittedly less pressing) in your project ("All contributions are welcome."). I also thought I was quite specific and that potential minimum required changes to dust off the docstrings were obvious.
:-)But, I also understand that you life would be easier if the solution was provided directly.
Let's meet halfway:
I've messed with your code a little, but that is on
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32so it might break for earlier versions, and it's also probably not pythonic, and I don't know how to run the build tests, so no pull-request yet, but have a look for yourself: master...gnbl:gnbl_version_docChanges:
"""docstrings"""instead of line-comments. Using__doc__.format()to include version string!__init__.pyfromversion.pyabout.rstLet me know if this would work for you and I'll be glad to create a pull-request.
Cheers!
The changes would then produce:
For some reason the help system does not produce a VERSION from__version__for the package, like it does for a module.Edit: Never mind, it does actually, after listing the PACKAGE CONTENTS, e.g.
(
docmodule()does it: https://github.com/python/cpython/blob/3.6/Lib/pydoc.py#L1098)homm commentedon Apr 9, 2018
The right place is
PIL.PILLOW_VERSION.PIL.VERSION (not PIL.version) was there before forking, so we should pretend to be compliant.
You are right,
PIL.PILLOW_VERSIONisn't mentioned in the docs, this should be fixed.I believe it should be renamed to
_version.gnbl commentedon Apr 9, 2018
@homm Fixed my typo in the OP. Was not sure where this would fit into the docs, so I did not proceed. The
versionmodule does not seem to be documented at all.If the
__doc__.format()is acceptable, one could also include the actual location of the readme, in addition to "See the README file for more information.".hugovk commentedon Apr 9, 2018
We're happy for both issues and pull requests! PRs are good to get the conversation going and also you don't need to worry about testing locally as the CIs will do it for us. :)
In general, master...gnbl:gnbl_version_doc looks like a step in the right direction to clarify the confusion.
The reason for version.py is to have a single source of truth for the Pillow version, so we don't need to update both setup.py and Image.py when making a release (https://packaging.python.org/guides/single-sourcing-package-version/).
PILLOW_VERSIONused to be in Image.py, but was moved so it can be imported by Image.py and also read by setup.py.So I'd keep
PILLOW_VERSIONin version.py. If we want them both together, I'd also put the PIL version in version.py and have Image.py import it.Let's revisit this. Is there any point people reporting things back upstream to https://bitbucket.org/effbot/pil-2009-raclette/issues?
Also, do we still need to report 1.1.7 as the PIL version? I don't think we really care about it at this point and can't think of a great reason to keep it as 1.1.7. It's extremely unlikely at this point there'll be a 1.1.8, and there's been many here changes in the past 10 years.
Should we put the current Pillow version in
PIL.VERSIONas well?We could even clean up and have a single version variable (eg. ditch
PILLOW_VERSION) but this would be a breaking change as there may be some user code out there checking it. Perhaps that could wait until the next major release. Thoughts?homm commentedon Apr 9, 2018
My suggestion (without documentation): #3083
aclark4life commentedon Apr 9, 2018
@gnbl Definitely happy to have this issue addressed! Thanks all
hugovk commentedon Apr 9, 2018
And #3085 is another suggestion that can be used as well as or instead of #3083.
wiredfool commentedon Apr 11, 2018
IIRC, there were tests for some package out there that was relying on the PIL 1.1.7 version. Removing/changing that at this point should be considered a major change.
The version submodule is an implementation detail, it exists solely to provide a side-effect free simple import of the version number at build time so that we can have the one source of truth for the python and c code.
homm commentedon Apr 11, 2018
@gnbl Do you think this fix is enough?
gnbl commentedon Apr 11, 2018
@homm Thanks for the quick work on this! It's never enough ;-)
It looks like the suggestions regarding the docstrings (master...gnbl:gnbl_version_doc) have not yet found their way into 096a81b in some form. Maybe, "while you're at it", you could update these to eliminate the
package placeholderetc. as well?aclark4life commentedon Jun 30, 2018
@gnbl @homm @hugovk I can't tell if we are done or if there's more to do?
hugovk commentedon Jul 1, 2018
There's been several things done, here's a final PR to close this that updates some docs: #3218.