Disallow missing image libraries during setup?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
To customize the installation, we have a few environment variables, e.g.
https://github.com/pytorch/vision/blob/6a85ef24ba7a5d5879c4bd795972881ef5001c9b/setup.py#L146-L149
As can be seen above, by default they are set to 1, which indicates that the user wants to build torchvision with PNG and JPEG support. However, we don't require the dependencies, namely libpng and libjpeg to be present:
https://github.com/pytorch/vision/blob/6a85ef24ba7a5d5879c4bd795972881ef5001c9b/setup.py#L256-L259
https://github.com/pytorch/vision/blob/6a85ef24ba7a5d5879c4bd795972881ef5001c9b/setup.py#L291-L292
Only if one of the two is present, we simply build the image extension:
https://github.com/pytorch/vision/blob/6a85ef24ba7a5d5879c4bd795972881ef5001c9b/setup.py#L332-L335
However, if users import torchvision after successful installation, they are met with this warning:
UserWarning: Failed to load image Python extension:
Unless they want to use the image functionality from torchvision.io, this is not an issue and #7150 is trying to fix that.
In the mean time, the behavior described above can lead to issues like #7036. Plus, there is also this really long thread in the user forum also reporting this (I'm aware that there are reports of this warning popping up from an official nightly release, but there are also people that face this after building from source).
IMO, we should discuss if we should accept that one of the image libraries is not available during build. Meaning, by default the libraries are required and the setup could simply fail if they are not found. If the user doesn't care about the I/O functionality they need to explicitly set USE_PNG=0 USE_JPEG=0 python setup.py install.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with setup.py at the linked environment-variable and dependency checks around lines 146-149, 256-259, 291-292, and 332-335. Review the related issues and forum thread, then determine the agreed default behavior and verify installation with and without libpng/libjpeg, including the explicit USE_PNG=0 USE_JPEG=0 path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, computer-vision
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100