Repository: spack/spack

Issue:
Installation issue: py-torchvision
### Steps to reproduce the issue

```console
$ spack spec -I py-torchvision
Input spec
--------------------------------
 -   py-torchvision

Concretized
--------------------------------
 -   py-torchvision@0.16.2%apple-clang@14.0.0~ffmpeg~jpeg~nvjpeg~png~video_codec build_system=python_pip arch=darwin-ventura-m1
[+]      ^ninja@1.11.1%apple-clang@14.0.0+re2c build_system=generic arch=darwin-ventura-m1
[+]          ^python@3.10.10%apple-clang@14.0.0+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=0d98e93,7d40923,f2fd060 arch=darwin-ventura-m1
[e]              ^apple-libuuid@1353.100.2%apple-clang@14.0.0 build_system=bundle arch=darwin-ventura-m1
[+]          ^re2c@2.2%apple-clang@14.0.0 build_system=generic arch=darwin-ventura-m1
[+]      ^py-numpy@1.26.2%apple-clang@14.0.0 build_system=python_pip patches=873745d arch=darwin-ventura-m1
[+]          ^ninja@1.11.1%apple-clang@14.0.0+re2c build_system=generic arch=darwin-ventura-m1
[+]              ^re2c@2.2%apple-clang@14.0.0 build_system=generic arch=darwin-ventura-m1
[+]          ^openblas@0.3.21%apple-clang@14.0.0~bignuma~consistent_fpcsr+fortran~ilp64+locking+pic+shared build_system=makefile patches=114f95f,d3d9b15 symbol_suffix=none threads=none arch=darwin-ventura-m1
[+]              ^perl@5.36.0%apple-clang@14.0.0+cpanm+open+shared+threads build_system=generic arch=darwin-ventura-m1
[+]                  ^berkeley-db@18.1.40%apple-clang@14.0.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-ventura-m1
[+]          ^pkgconf@1.8.0%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]              ^gnuconfig@2022-09-17%apple-clang@14.0.0 build_system=generic arch=darwin-ventura-m1
[+]          ^py-cython@3.0.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-pyproject-metadata@0.7.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-packaging@23.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]      ^py-pillow@10.0.0%apple-clang@14.0.0~freetype~imagequant+jpeg~jpeg2000~lcms~raqm~tiff~webp~xcb+zlib build_system=python_pip arch=darwin-ventura-m1
[+]          ^libjpeg-turbo@2.1.4%apple-clang@14.0.0~ipo~jpeg8+shared+static build_system=cmake build_type=RelWithDebInfo arch=darwin-ventura-m1
[+]              ^cmake@3.25.2%apple-clang@14.0.0~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=darwin-ventura-m1
[+]              ^nasm@2.15.05%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]          ^zlib@1.2.13%apple-clang@14.0.0+optimize+pic+shared build_system=makefile arch=darwin-ventura-m1
[+]      ^py-pip@23.1.2%apple-clang@14.0.0 build_system=generic arch=darwin-ventura-m1
[+]      ^py-requests@2.31.0%apple-clang@14.0.0~socks build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-certifi@2023.7.22%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-charset-normalizer@3.3.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-idna@3.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-flit-core@3.9.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-urllib3@2.1.0%apple-clang@14.0.0~brotli~socks build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-hatchling@1.18.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-editables@0.3%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-pathspec@0.11.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-pluggy@1.0.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-trove-classifiers@2023.8.7%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                      ^py-calver@2022.6.26%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]      ^py-setuptools@68.0.0%apple-clang@14.0.0 build_system=generic arch=darwin-ventura-m1
[+]      ^py-torch@2.1.2%apple-clang@14.0.0~caffe2~cuda~debug~distributed+fbgemm+kineto+metal~mkldnn+mps+numpy+onnx_ml+openmp~qnnpack~rocm~test+xnnpack build_system=python_pip arch=darwin-ventura-m1
[+]          ^cmake@3.26.3%apple-clang@14.0.0~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=darwin-ventura-m1
[+]          ^eigen@3.4.0%apple-clang@14.0.0~ipo build_system=cmake build_type=RelWithDebInfo generator=make arch=darwin-ventura-m1
[+]          ^fp16@2020-05-14%apple-clang@14.0.0~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-ventura-m1
[+]          ^fxdiv@2020-04-17%apple-clang@14.0.0~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-ventura-m1
[+]          ^llvm-openmp@14.0.6%apple-clang@14.0.0~ipo~multicompat build_system=cmake build_type=RelWithDebInfo arch=darwin-ventura-m1
[+]          ^protobuf@3.21.12%apple-clang@14.0.0~ipo+shared build_system=cmake build_type=Release generator=make arch=darwin-ventura-m1
[+]          ^psimd@2020-05-17%apple-clang@14.0.0~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-ventura-m1
[+]          ^pthreadpool@2021-04-13%apple-clang@14.0.0~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-ventura-m1
[+]          ^py-astunparse@1.6.3%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-six@1.16.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-filelock@3.12.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-hatch-vcs@0.3.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-fsspec@2023.10.0%apple-clang@14.0.0+http build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-aiohttp@3.8.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-aiosignal@1.2.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-async-timeout@4.0.2%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-attrs@23.1.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                      ^py-hatch-fancy-pypi-readme@23.1.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-frozenlist@1.3.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-multidict@6.0.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-yarl@1.9.2%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-jinja2@3.1.2%apple-clang@14.0.0~i18n build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-markupsafe@2.1.3%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-networkx@3.1%apple-clang@14.0.0+default~extra build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-matplotlib@3.8.2%apple-clang@14.0.0~animation~fonts~latex~movies backend=macosx build_system=python_pip arch=darwin-ventura-m1
[+]                  ^freetype@2.11.1%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                  ^libpng@1.6.37%apple-clang@14.0.0 build_system=autotools libs=shared,static arch=darwin-ventura-m1
[+]                  ^py-contourpy@1.0.7%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-cycler@0.11.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-fonttools@4.39.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-kiwisolver@1.4.5%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                      ^py-cppy@1.2.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-pyparsing@3.0.9%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-python-dateutil@2.8.2%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^qhull@2020.2%apple-clang@14.0.0~ipo build_system=cmake build_type=RelWithDebInfo arch=darwin-ventura-m1
[+]              ^py-pandas@2.1.4%apple-clang@14.0.0~excel build_system=python_pip arch=darwin-ventura-m1
[+]                  ^meson@1.2.1%apple-clang@14.0.0 build_system=python_pip patches=0f0b1bd,ae59765 arch=darwin-ventura-m1
[+]                  ^py-bottleneck@1.3.7%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-meson-python@0.13.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-numba@0.58.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                      ^py-llvmlite@0.41.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                          ^binutils@2.41%apple-clang@14.0.0~gas~gprofng~headers~interwork~ld~libiberty~lto~nls~pgo+plugins build_system=autotools compress_debug_sections=zlib libs=shared,static arch=darwin-ventura-m1
[+]                          ^llvm@14.0.6%apple-clang@14.0.0+clang~code_signing~cuda~flang~gold~ipo~libomptarget~libomptarget_debug~link_llvm_dylib+lld+lldb+llvm_dylib+lua~mlir+polly~python~split_dwarf~z3 build_system=cmake build_type=Release compiler-rt=runtime generator=ninja libcxx=runtime libunwind=runtime openmp=runtime patches=1f42874,25bc503,8248141,b216cff,cb8e645,e95255b shlib_symbol_version=none targets=all version_suffix=none arch=darwin-ventura-m1
[+]                              ^hwloc@2.9.0%apple-clang@14.0.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl~pci~rocm build_system=autotools libs=shared,static arch=darwin-ventura-m1
[+]                              ^lua@5.3.6%apple-clang@14.0.0~pcfile+shared build_system=makefile fetcher=curl arch=darwin-ventura-m1
[+]                                  ^unzip@6.0%apple-clang@14.0.0 build_system=makefile arch=darwin-ventura-m1
[+]                              ^perl-data-dumper@2.173%apple-clang@14.0.0 build_system=perl arch=darwin-ventura-m1
[+]                              ^swig@4.0.2-fortran%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                                  ^pcre@8.45%apple-clang@14.0.0~jit+multibyte+utf build_system=autotools arch=darwin-ventura-m1
[+]                  ^py-numexpr@2.8.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-pytz@2023.3%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-tzdata@2023.3%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-versioneer@0.29%apple-clang@14.0.0+toml build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-scipy@1.11.4%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                  ^py-pythran@0.12.2%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                      ^py-beniget@0.4.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                      ^py-gast@0.5.3%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]                      ^py-ply@3.11%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-protobuf@3.20.3%apple-clang@14.0.0~cpp build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-pybind11@2.11.0%apple-clang@14.0.0~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-ventura-m1
[+]          ^py-pyyaml@6.0%apple-clang@14.0.0+libyaml build_system=python_pip arch=darwin-ventura-m1
[+]              ^libyaml@0.2.5%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]              ^py-cython@0.29.36%apple-clang@14.0.0 build_system=python_pip patches=c4369ad arch=darwin-ventura-m1
[+]          ^py-sympy@1.11.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-mpmath@1.2.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-tqdm@4.66.1%apple-clang@14.0.0~notebook~telegram build_system=python_pip arch=darwin-ventura-m1
[+]              ^py-setuptools-scm@7.1.0%apple-clang@14.0.0+toml build_system=python_pip arch=darwin-ventura-m1
[+]                  ^git@2.42.0%apple-clang@14.0.0+man+nls+perl+subtree~svn~tcltk build_system=autotools arch=darwin-ventura-m1
[+]                      ^autoconf@2.69%apple-clang@14.0.0 build_system=autotools patches=35c4492,7793209,a49dd5b arch=darwin-ventura-m1
[+]                      ^automake@1.16.5%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                      ^curl@8.0.1%apple-clang@14.0.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=secure_transport arch=darwin-ventura-m1
[+]                          ^nghttp2@1.52.0%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                      ^libidn2@2.3.4%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                          ^libunistring@1.1%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                      ^libtool@2.4.7%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                      ^m4@1.4.19%apple-clang@14.0.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=darwin-ventura-m1
[+]                          ^libsigsegv@2.14%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                      ^openssh@9.3p1%apple-clang@14.0.0+gssapi build_system=autotools arch=darwin-ventura-m1
[+]                          ^krb5@1.20.1%apple-clang@14.0.0+shared build_system=autotools arch=darwin-ventura-m1
[+]                              ^bison@3.8.2%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                          ^libedit@3.1-20210216%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]                      ^pcre2@10.42%apple-clang@14.0.0~jit+multibyte build_system=autotools arch=darwin-ventura-m1
[+]                  ^py-tomli@2.0.1%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]          ^py-typing-extensions@4.8.0%apple-clang@14.0.0 build_system=python_pip arch=darwin-ventura-m1
[+]      ^py-wheel@0.41.2%apple-clang@14.0.0 build_system=generic arch=darwin-ventura-m1
[+]      ^python@3.11.6%apple-clang@14.0.0+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,ebdca64,f2fd060 arch=darwin-ventura-m1
[e]          ^apple-libuuid@1353.100.2%apple-clang@14.0.0 build_system=bundle arch=darwin-ventura-m1
[+]          ^bzip2@1.0.8%apple-clang@14.0.0~debug~pic+shared build_system=generic arch=darwin-ventura-m1
[+]              ^diffutils@3.8%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]          ^expat@2.5.0%apple-clang@14.0.0~libbsd build_system=autotools arch=darwin-ventura-m1
[+]          ^gdbm@1.23%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]          ^gettext@0.21.1%apple-clang@14.0.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=darwin-ventura-m1
[+]              ^libiconv@1.17%apple-clang@14.0.0 build_system=autotools libs=shared,static arch=darwin-ventura-m1
[+]              ^libxml2@2.10.3%apple-clang@14.0.0~python build_system=autotools arch=darwin-ventura-m1
[+]              ^tar@1.34%apple-clang@14.0.0 build_system=autotools zip=pigz arch=darwin-ventura-m1
[+]                  ^pigz@2.7%apple-clang@14.0.0 build_system=makefile arch=darwin-ventura-m1
[+]                  ^zstd@1.5.2%apple-clang@14.0.0+programs build_system=makefile compression=none libs=shared,static arch=darwin-ventura-m1
[+]          ^gmake@4.4.1%apple-clang@14.0.0~guile build_system=autotools arch=darwin-ventura-m1
[+]          ^libffi@3.4.4%apple-clang@14.0.0 build_system=autotools arch=darwin-ventura-m1
[+]          ^libxcrypt@4.4.33%apple-clang@14.0.0~obsolete_api build_system=autotools arch=darwin-ventura-m1
[+]          ^ncurses@6.4%apple-clang@14.0.0~symlinks+termlib abi=none build_system=autotools arch=darwin-ventura-m1
[+]          ^openssl@1.1.1t%apple-clang@14.0.0~docs~shared build_system=generic certs=mozilla arch=darwin-ventura-m1
[+]              ^ca-certificates-mozilla@2023-01-10%apple-clang@14.0.0 build_system=generic arch=darwin-ventura-m1
[+]          ^readline@8.2%apple-clang@14.0.0 build_system=autotools patches=bbf97f1 arch=darwin-ventura-m1
[+]          ^sqlite@3.40.1%apple-clang@14.0.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=darwin-ventura-m1
[+]          ^xz@5.4.1%apple-clang@14.0.0~pic build_system=autotools libs=shared,static arch=darwin-ventura-m1
```


### Error message

<details><summary>Error message</summary>

<pre>
Python 3.11.6 (main, Dec 18 2023, 16:15:27) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
/Users/yc/spack/var/spack/environments/dali/.spack-env/._view/bkvc3ag5nesq5ctel3ivbuhfhfz6qq4c/lib/python3.11/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
</pre></details>


### Information on your system

* **Spack:** 0.22.0.dev0 (0f74f796de4545513a59a6609dd42aa99a6abca5)
* **Python:** 3.9.6
* **Platform:** darwin-ventura-m1
* **Concretizer:** clingo

### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/13776722/spack-build-out.txt)
Maintainer: @adamjstewart 

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
Commented on https://github.com/pytorch/vision/issues/7151

For now, either ignore the warning (it's harmless if you aren't planning on using `torchvision.io`) or install `py-torchvision+png` or `py-torchvision+jpeg`.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/py-torchvision/package.py b/var/spack/repos/builtin/packages/py-torchvision/package.py
--- a/var/spack/repos/builtin/packages/py-torchvision/package.py
+++ b/var/spack/repos/builtin/packages/py-torchvision/package.py
@@ -47,8 +47,8 @@ class PyTorchvision(PythonPackage):
     version("0.5.0", sha256="eb9afc93df3d174d975ee0914057a9522f5272310b4d56c150b955c287a4d74d")
 
     desc = "Enable support for native encoding/decoding of {} formats in torchvision.io"
-    variant("png", default=False, description=desc.format("PNG"))
-    variant("jpeg", default=False, description=desc.format("JPEG"))
+    variant("png", default=True, description=desc.format("PNG"))
+    variant("jpeg", default=True, description=desc.format("JPEG"))
     variant("nvjpeg", default=False, description=desc.format("JPEG"))
     variant("ffmpeg", default=False, description=desc.format("FFMPEG"))
     variant("video_codec", default=False, description=desc.format("video_codec"))


Test patch: