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

Pillow should require NumPy >= 1.23 #6588

Closed
hroskes opened this issue Sep 16, 2022 · 4 comments · Fixed by #6594
Closed

Pillow should require NumPy >= 1.23 #6588

hroskes opened this issue Sep 16, 2022 · 4 comments · Fixed by #6594
Labels

Comments

@hroskes
Copy link

hroskes commented Sep 16, 2022

What did you do?

I opened a truncated image file and converted it to an array to check the validity of the file. (The equivalent of this test, though my file was a tiff.)

What did you expect to happen?

OSError

What actually happened?

It returned an actual array. I didn't imshow it to see what was in the place of the missing bytes.

What are your OS, Python and Pillow versions?

  • OS: ubuntu:20.04 from dockerhub
  • Python: 3.8.10
  • Pillow: 9.2.0
  • Numpy: 1.19.5

I think it would be better to either (a) keep the workaround for old numpy versions or (b) require a numpy version that works in setup.py. The current setup is not self consistent.

@radarhere radarhere changed the title PIL 9.2.0 should require numpy >= 1.23 Pillow 9.2.0 should require numpy >= 1.23 Sep 16, 2022
@radarhere
Copy link
Member

radarhere commented Sep 16, 2022

Just for context, the reason you are specifying Pillow 9.2.0 is because of #6394.

Can I ask, what is it that lead you to update Pillow to the latest version, but not NumPy?

@radarhere radarhere changed the title Pillow 9.2.0 should require numpy >= 1.23 Pillow 9.2.0 should require NumPy >= 1.23 Sep 16, 2022
@hroskes
Copy link
Author

hroskes commented Sep 16, 2022

I'm not entirely sure which dependency caused it, but this was the result when I installed my package with pip. I assume one of my other dependencies defaulted to an older NumPy version, but I'm not sure which one. I'm still digging through to figure out a self consistent setup.

Regardless, in principle there doesn't have to be a particular reason - somebody could have an older NumPy installed already but no Pillow, and then run pip install pillow, and as it currently stands they would get Pillow 9.2.0 while keeping their old NumPy. They would then get bitten by this issue like I was.

@radarhere radarhere changed the title Pillow 9.2.0 should require NumPy >= 1.23 Pillow should require NumPy >= 1.23 Sep 16, 2022
@radarhere
Copy link
Member

NumPy is an optional dependency of Pillow. Performing a quick Google search, I don't think that an optional dependency can have a minimum version. Correct me if I missed something.

I then considered the possibility of raising an error if NumPy is too old in __array_interface__... but the problem in the first place (#5084) is that __array_interface__ can't raise anything except for a RecursionError or MemoryError.

So I don't think that b) is possible.

As for a), keeping the workaround, I'm not keen on introducing a change (#5379), reverting that change (#6394), and then re-introducing it... I think that's off-putting to users, who would prefer a consistent experience - whether or not an error is raised is not the only difference. See #6581.

What if we instead raised a warning when an error is triggered with older NumPy versions? I've created PR #6594 for this.

@hroskes
Copy link
Author

hroskes commented Sep 18, 2022

Ah, I see. That makes sense to me, thank you!

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

Successfully merging a pull request may close this issue.

2 participants