Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __main__.py to output basic format and support information #3870

Merged
merged 1 commit into from Jun 19, 2019

Conversation

Projects
None yet
3 participants
@jdufresne
Copy link
Contributor

commented May 25, 2019

I recently came across a scenario where Pillow was installed in a VM
with limited OS libraries. To help debug, I was curious what formats
were supported. I think the following feature be useful for such scenarios:

If you like the idea, but want some alterations in the output format, let me know. I'm happy to adjust it.


To help debug and show supported formats, users can run:

$ python -m PIL

to get basic format and support information about the installed version
of Pillow.

The new feature works as follows:

$ python -m PIL
Pillow 6.1.0.dev0
Platform linux 3.7.3 (default, May 11 2019, 00:38:04)
         [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]

Supported formats:

BLP
  Extensions: .blp
  Features: open

BMP (image/bmp)
  Extensions: .bmp
  Features: open, save

BUFR
  Extensions: .bufr
  Features: open, save

…

@jdufresne jdufresne force-pushed the jdufresne:main branch 3 times, most recently from 2a904d5 to 80e21c4 May 25, 2019

@hugovk

This comment has been minimized.

Copy link
Member

commented May 27, 2019

Good stuff! I've been thinking of something like this that we could ask people to run to help deal with issues.

Sometimes it's not always clear which Python or Pillow installation is running on the command line versus from a script.

  • Would it be possible to make it so that it can be run programmatically from a script?

  • And print the Pillow installation directory?

  • @radarhere Can you think of any other useful info that could be included?

  • Would any of the output of python selftest.py be useful?

@radarhere

This comment has been minimized.

Copy link
Member

commented May 27, 2019

No, no other ideas from me. I was going to comment that the word 'Python' should come before the version string, but it actually does in the code, so maybe that's something that was updated after original post.

@jdufresne jdufresne force-pushed the jdufresne:main branch 4 times, most recently from 273bd32 to 45fb23d May 28, 2019

Add __main__.py to output basic format and support information
To help debug and show supported formats, users can run:

    $ python -m PIL

to get basic format and support information about the installed version
of Pillow.

The new feature works as follows:

    $ python -m PIL
    --------------------------------------------------------------------
    Pillow 6.1.0.dev0
    --------------------------------------------------------------------
    Python modules loaded from .../Pillow/src/PIL
    Binary modules loaded from .../Pillow/src/PIL
    --------------------------------------------------------------------
    Python 3.7.3 (default, May 11 2019, 00:38:04)
           [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
    --------------------------------------------------------------------
    --- PIL CORE support ok
    --- TKINTER support ok
    --- FREETYPE2 support ok
    --- LITTLECMS2 support ok
    --- WEBP support ok
    --- WEBP Transparency support ok
    --- WEBPMUX support ok
    --- WEBP Animation support ok
    --- JPEG support ok
    --- OPENJPEG (JPEG2000) support ok
    --- ZLIB (PNG/ZIP) support ok
    --- LIBTIFF support ok
    --- RAQM (Bidirectional Text) support ok
    --------------------------------------------------------------------
    BLP
    Extensions: .blp
    Features: open
    --------------------------------------------------------------------
    BMP image/bmp
    Extensions: .bmp
    Features: open, save
    --------------------------------------------------------------------
    BUFR
    Extensions: .bufr
    Features: open, save
    --------------------------------------------------------------------
    …

@jdufresne jdufresne force-pushed the jdufresne:main branch from 45fb23d to 1008644 May 28, 2019

@jdufresne

This comment has been minimized.

Copy link
Contributor Author

commented May 28, 2019

Changes:

  • Moved to a function: PIL.features.pilinfo(). This can be called programmatically to write to a file like object. Opinions on this as an API are welcome.
  • Adjusted the output to include the header and output from selftest.py. This includes the PIL installation directory.The rest of the output has been modified to match this style. Opinions on this style welcome. It now looks like:
$ python -m PIL
--------------------------------------------------------------------
Pillow 6.1.0.dev0
--------------------------------------------------------------------
Python modules loaded from .../Pillow/src/PIL
Binary modules loaded from .../Pillow/src/PIL
--------------------------------------------------------------------
Python 3.7.3 (default, May 11 2019, 00:38:04)
       [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- FREETYPE2 support ok
--- LITTLECMS2 support ok
--- WEBP support ok
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok
--- OPENJPEG (JPEG2000) support ok
--- ZLIB (PNG/ZIP) support ok
--- LIBTIFF support ok
--- RAQM (Bidirectional Text) support ok
--------------------------------------------------------------------
BLP
Extensions: .blp
Features: open
--------------------------------------------------------------------
BMP image/bmp
Extensions: .bmp
Features: open, save
--------------------------------------------------------------------
BUFR
Extensions: .bufr
Features: open, save
--------------------------------------------------------------------
…

@hugovk

hugovk approved these changes Jun 5, 2019

Copy link
Member

left a comment

Unless anyone has comments about the API/naming, let's merge this for the next release.

@hugovk hugovk merged commit be1b551 into python-pillow:master Jun 19, 2019

17 checks passed

codecov/patch 98% of diff hit (target 85.12%)
Details
codecov/project 85.15% (+0.02%) compared to 65f3e44
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
python-pillow.Pillow Build #20190528.5 succeeded
Details
python-pillow.Pillow (Lint Python37) Lint Python37 succeeded
Details
python-pillow.Pillow (alpine) alpine succeeded
Details
python-pillow.Pillow (amazon_1_amd64) amazon_1_amd64 succeeded
Details
python-pillow.Pillow (amazon_2_amd64) amazon_2_amd64 succeeded
Details
python-pillow.Pillow (arch) arch succeeded
Details
python-pillow.Pillow (centos_6_amd64) centos_6_amd64 succeeded
Details
python-pillow.Pillow (centos_7_amd64) centos_7_amd64 succeeded
Details
python-pillow.Pillow (debian_stretch_x86) debian_stretch_x86 succeeded
Details
python-pillow.Pillow (fedora_29_amd64) fedora_29_amd64 succeeded
Details
python-pillow.Pillow (fedora_30_amd64) fedora_30_amd64 succeeded
Details
python-pillow.Pillow (ubuntu_16_04_xenial_amd64) ubuntu_16_04_xenial_amd64 succeeded
Details
python-pillow.Pillow (ubuntu_18_04_bionic_amd64) ubuntu_18_04_bionic_amd64 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.