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

10.0.0 ~regression~ deprecation: ImageDraw' object has no attribute 'textsize' #7277

Closed
marc-hb opened this issue Jul 11, 2023 · 6 comments
Closed

Comments

@marc-hb
Copy link

marc-hb commented Jul 11, 2023

I don't have time to isolate the issue and file a "great" bug report sorry. However this is hopefully a "decent" bug report because everything required to reproduce should be found at thesofproject/sof-docs#472

The moment pillow 10.0.0 was released on PyPI, our build started failing with this warning:

WARNING: dot code 'blockdiag edf_scheduling {\n\n\tnode_width = 250;\n\tnode_height = 120;\n\tdefault_fontsize = 16;\n\n\tComp_1 -> Comp_2\n\tcomment_1 -> Comp_2 [style=dashed]\n\tComp_2 -> Comp_3\n\tcomment_2 -> Comp_3 [style=dashed]\n\tComp_3 -> Comp_4\n\tcomment_3 -> Comp_4 [style=dashed]\n\tComp_4 -> sink\n\tcomment_4 -> sink [style=dashed]\n\n\tComp_1 [label="DP component 1\n\n\t\tprocessing period\n\n\t\tcompute requirement"]\n\tComp_2 [label="DP component 2\n\n\t\tprocessing period\n\n\t\tcompute requirement"]\n\tComp_3 [label="DP component 3\n\n\t\tprocessing period\n\n\t\tcompute requirement"]\n\tComp_4 [label="DP component 4\n\n\t\tprocessing period\n\n\t\tcompute requirement"]\n\n\tsink [label="real time sink", shape=endpoint, fontsize = 16]\n\n\tcomment_1 [label="DP1 to deliver data let\n\n\t\tDP2 meet its objective"]\n\tcomment_2 [label="DP2 to deliver data let\n\n\t\tDP3 meet its objective"]\n\tcomment_3 [label="DP3 to deliver data let\n\n\t\tDP4 meet its objective"]\n\tcomment_4 [label="DP4 to deliver data\n\n\t\tto real time-sink"]\n}\n': 'ImageDraw' object has no attribute 'textsize'
generating indices... genindex done

Downgrading to 9.5.0 immediately solved the issue.

@marc-hb
Copy link
Author

marc-hb commented Jul 11, 2023

I suspect the current sphinxcontrib-blockdiag could simply be incompatible with 10.0.0?

@flajann2
Copy link

streamdeck_ui was broken by the removal of "textsize". I fixed the problem by backrevving, but I would imagine many other applications that rely on your library are also broken.

@hugovk
Copy link
Member

hugovk commented Jul 11, 2023

We aim to deprecate for at least a year, with deprecation warnings, so people have notice and plenty of time to upgrade. And then remove the deprecations in major releases, following SemVer.

ImageDraw.textsize was deprecated in Pillow 9.2.0 with deprecation warnings, which was released a year ago, on 1st July 2022:

And it was removed in Pillow 10.0.0, released on 1st July 2023:

Python 3.11.4 (v3.11.4:d2340ef257, Jun  6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image, ImageDraw
>>> Image.__version__
'9.5.0'
>>> im = Image.new("RGB", (100, 100))
>>> draw = ImageDraw.Draw(im)
>>> draw.textsize("Hello")
<stdin>:1: DeprecationWarning: textsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use textbbox or textlength instead.
(30, 11)
>>>

Please report to the relevant upstream projects.

I see there's already one for streamdeck_ui:

And for sphinxcontrib-blockdiag, the sof-docs dependency:

@marc-hb marc-hb changed the title 10.0.0 regression: ImageDraw' object has no attribute 'textsize' 10.0.0 ~regression~ deprecation: ImageDraw' object has no attribute 'textsize' Jul 11, 2023
@marc-hb
Copy link
Author

marc-hb commented Jul 11, 2023

ImageDraw.textsize was deprecated in Pillow 9.2.0 with deprecation warnings,

Thanks, this is typically why we run sphinx-build -W which turns warnings into errors: for CI to warn us about problems like this ahead of time.

But in this case it makes no difference because sphinx-build does not care at all about warnings like this one.

Worse: sphinx-build somehow hides this warning. I tried sphinx-build -W -v -v and I got 600+ lines of sphinx-build therapy (when rebuilding just this one file!) but only 10 lines about rebuilding this file and none with anything remotely related to this deprecation:

+docnames to write: architectures/firmware/sof-zephyr/mpp_layer/mpp_scheduling
+preparing documents... done
+[app] emitting event: 'doctree-resolved'(<document: <target...><section "media processing pipelines layer; m ...>, 'architectures/firmware/s
+[app] emitting event: 'html-page-context'('architectures/firmware/sof-zephyr/mpp_layer/index', 'page.html', {'embedded': False, 'project': 'S
+writing output... [ 50%] architectures/firmware/sof-zephyr/mpp_layer/mpp_scheduling
+[app] emitting event: 'doctree-resolved'(<document: <target...><section "mpp scheduling; sof-zephyr_mpp_sche ...>, 'architectures/firmware/s
+writing output... [100%] index
+[app] emitting event: 'doctree-resolved'(<document: <target...><section "sof project documentation; sof_home ...>, 'index')
+
+waiting for workers...
+[app] emitting event: 'html-page-context'('index', 'page.html', {'embedded': False, 'project': 'SOF Project', 'release': '2.5.0', 'version': 
+[app] emitting event: 'html-page-context'('architectures/firmware/sof-zephyr/mpp_layer/mpp_scheduling', 'page.html', {'embedded': False, 'pro
+generating indices... genindex [app] emitting event: 'html-page-context'('genindex', 'genindex.html', {'embedded': False, 'project': 'SOF Project', 'release': '2.5.0', 'ver
+done
+[app] emitting event: 'html-collect-pages'()
+writing additional pages... search [app] emitting event: 'html-page-context'('search', 'search.html', {'embedded': False, 'project': 'SOF Project', 'release': '2.5.0', 'version

Is such a warning even printed on stderr?

@hugovk
Copy link
Member

hugovk commented Jul 12, 2023

Deprecation warnings are printed to stderr during normal execution:

cat 1.py
from PIL import Image, ImageDraw
print(Image.__version__)
im = Image.new("RGB", (100, 100))
draw = ImageDraw.Draw(im)
draw.textsize("Hello")python 1.py
9.5.0
/private/tmp/1.py:5: DeprecationWarning: textsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use textbbox or textlength instead.
  draw.textsize("Hello")python 1.py > 1.txt
/private/tmp/1.py:5: DeprecationWarning: textsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use textbbox or textlength instead.
  draw.textsize("Hello")

And they're printed to sdtout in a special warnings summary by pytest:

cat test_1.py
def test_1():
    from PIL import Image, ImageDraw
    print(Image.__version__)
    im = Image.new("RGB", (100, 100))
    draw = ImageDraw.Draw(im)
    draw.textsize("Hello")pytest test_1.py
============================================================================================ test session starts ============================================================================================
platform darwin -- Python 3.11.3, pytest-7.4.0, pluggy-1.2.0
rootdir: /private/tmp
plugins: flaky-3.7.0, timeout-2.1.0, cov-4.1.0, respx-0.20.1, xdist-3.3.1, anyio-3.6.2, lazy-fixture-0.6.3
collected 1 item

test_1.py .                                                                                                                                                                                           [100%]

============================================================================================= warnings summary ==============================================================================================
test_1.py::test_1
  /private/tmp/test_1.py:6: DeprecationWarning: textsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use textbbox or textlength instead.
    draw.textsize("Hello")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================================= 1 passed, 1 warning in 0.03s ========================================================================================pytest test_1.py > 1.txt

I've not checked Sphinx.

@marc-hb
Copy link
Author

marc-hb commented Jul 12, 2023

Thanks @hugovk for all the information and pointers, which is exactly what I was hoping to get when I opened this issue. Closing it, we can still discuss and add more pointers after it's closed but it looks like there's nothing required on the pillow side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants