Repository: spack/spack

Issue:
fenics install fails due to cmake python ply issue
I have come across a new error when installing fenics with spack. This seems like a similar issue to https://github.com/spack/spack/issues/13397.

I am installing spack with the following command:
`spack install fenics~hdf5 ^openmpi+pmi schedulers=slurm`

I run into cmake issues at the final step. Specifically it cannot locate py-ply and site.py
```
1 error found in build log:
     147      Ignoring EXACT since no version is requested.
     148    This warning is for project developers.  Use -Wno-dev to suppress it.
     149
     150    -- Found PythonLibs: /cm/shared/apps/spack-pkgs/linux-centos7-zen/gcc-8.2.0/python-3.8.6-u7px4ssttiqjhc6q2arrww4wqceck7nk/lib/libpython3.8.so (found versio
            n "3.8.6")
     151    ImportError: No module named site
     152    -- Could NOT find PY_ply (missing: PY_PLY_path)
  >> 153    CMake Error at CMakeLists.txt:438 (message):
     154      Required Python module 'ply' (http://www.dabeaz.com/ply/) could not be
     155      found.  Install ply or set DOLFIN_ENABLE_PYTHON to false.
     156
     157
     158    -- Configuring incomplete, errors occurred!
     159    See also "/home/apal/.spack_root/stage/spack-stage-fenics-2016.1.0-mgupwbojaxav4wuo63yfu6gv7oiy5jdn/spack-build-mgupwbo/CMakeFiles/CMakeOutput.log".

See build log for details:
  /home/apal/.spack_root/stage/spack-stage-fenics-2016.1.0-mgupwbojaxav4wuo63yfu6gv7oiy5jdn/spack-build-out.txt
```
I have verified that py-ply is in PYTHONPATH. I have explicitly spack-loaded python3 and py-ply.
```
[root@L01 tarballs]# spack find --loaded
==> 18 installed packages
-- linux-centos7-zen / gcc@8.2.0 --------------------------------
bzip2@1.0.8   gdbm@1.18.1   libbsd@0.10.0  libiconv@1.16  libxml2@2.9.10  openssl@1.1.1h  python@3.8.6  sqlite@3.33.0  xz@5.2.5
expat@2.2.10  gettext@0.21  libffi@3.3     libuuid@1.0.3  ncurses@6.2     py-ply@3.11     readline@8.0  tar@1.32       zlib@1.2.11
[root@L01 tarballs]#
[root@L01 tarballs]# python -c "import re, ply, site; print(re.compile('/__init__.py.*').sub('',ply.__file__))"
/cm/shared/apps/spack-pkgs/linux-centos7-zen/gcc-8.2.0/py-ply-3.11-fpyplf44xgseqlpml5vxvs4r7bxv4c53/lib/python3.8/site-packages/ply
[root@L01 tarballs]# python -c "import re, ply, site; print(re.compile('/__init__.py.*').sub('',site.__file__))"
/cm/shared/apps/spack-pkgs/linux-centos7-zen/gcc-8.2.0/python-3.8.6-u7px4ssttiqjhc6q2arrww4wqceck7nk/lib/python3.8/site.py
[root@L01 tarballs]# sed 's/:/\n/g' <<< "$PYTHONPATH"
/cm/shared/apps/spack-pkgs/linux-centos7-zen/gcc-8.2.0/py-ply-3.11-fpyplf44xgseqlpml5vxvs4r7bxv4c53/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/linux-centos7-zen/gcc-8.2.0/py-ply-3.11-fpyplf44xgseqlpml5vxvs4r7bxv4c53/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/linux-centos7-zen/gcc-8.2.0/python-3.8.6-u7px4ssttiqjhc6q2arrww4wqceck7nk/lib/python3.8
```
Any ideas how to circumvent this issue? Thank you for your attention. Regards.


Discussion:
Note that `spack install` won't use modifications you make to your shell with `spack load` - that command modifies the shell to aid usage of Spack packages outside of calls to Spack (e.g. if you want to do builds without Spack).

If `py-ply` is listed as a dependency of `fenics` then Spack will add it to PYTHONPATH for `spack install fenics`. I don't immediately see it listed as a dependency of `fenics` (or `py-fenics`): could you add the output of `spack spec fenics~hdf5 ^openmpi+pmi schedulers=slurm`?


```
[root@L01 tarballs]# spack spec fenics~hdf5 ^openmpi+pmi schedulers=slurm

Input spec
--------------------------------
fenics~hdf5
    ^openmpi+pmi schedulers=slurm

Concretized
--------------------------------
fenics@2016.1.0%gcc@8.2.0~doc~hdf5~ipo+mpi+openmp+parmetis+petsc~qt+scotch+shared+slepc+suite-sparse+trilinos~vtk build_type=RelWithDebInfo patches=8de9625a4ba4d27801bde734f744c96efcce57ecdec63556a5f6e2c28d4af532 arch=linux-centos7-zen
    ^boost@1.74.0%gcc@8.2.0+atomic+chrono~clanglibcpp~container~context~coroutine+date_time~debug+exception~fiber+filesystem+graph~icu+iostreams+locale+log+math~mpi+multithreaded~numpy~pic+program_options~python+random+regex+serialization+shared+signals~singlethreaded+system~taggedlayout+test+thread+timer~versionedlayout+wave cxxstd=98 visibility=hidden arch=linux-centos7-zen
        ^bzip2@1.0.8%gcc@8.2.0+shared arch=linux-centos7-zen
            ^diffutils@3.7%gcc@8.2.0 arch=linux-centos7-zen
                ^libiconv@1.16%gcc@8.2.0 arch=linux-centos7-zen
        ^zlib@1.2.11%gcc@8.2.0+optimize+pic+shared arch=linux-centos7-zen
    ^cmake@3.18.4%gcc@8.2.0~doc+ncurses+openssl+ownlibs~qt patches=bf695e3febb222da2ed94b3beea600650e4318975da90e4a71d6f31a6d5d8c3d arch=linux-centos7-zen
        ^ncurses@6.2%gcc@8.2.0~symlinks+termlib arch=linux-centos7-zen
            ^pkgconf@1.7.3%gcc@8.2.0 arch=linux-centos7-zen
        ^openssl@1.1.1h%gcc@8.2.0+systemcerts arch=linux-centos7-zen
            ^perl@5.32.0%gcc@8.2.0+cpanm+shared+threads arch=linux-centos7-zen
                ^berkeley-db@18.1.40%gcc@8.2.0 arch=linux-centos7-zen
                ^gdbm@1.18.1%gcc@8.2.0 arch=linux-centos7-zen
                    ^readline@8.0%gcc@8.2.0 arch=linux-centos7-zen
    ^eigen@3.3.8%gcc@8.2.0~ipo build_type=RelWithDebInfo patches=62590e9b33a8f72b608a72b87147a306e7cb20766ea53c6b8e0a183fa6cb7635 arch=linux-centos7-zen
    ^metis@5.1.0%gcc@8.2.0~gdb~int64+real64+shared build_type=Release patches=4991da938c1d3a1d3dea78e49bbebecba00273f98df2a656e38b83d55b281da1,b1225da886605ea558db7ac08dd8054742ea5afe5ed61ad4d0fe7a495b1270d2 arch=linux-centos7-zen
    ^openmpi@3.1.6%gcc@8.2.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~lustre~memchecker+pmi~singularity~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=slurm arch=linux-centos7-zen
        ^hwloc@1.11.11%gcc@8.2.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-centos7-zen
            ^libpciaccess@0.16%gcc@8.2.0 arch=linux-centos7-zen
                ^libtool@2.4.6%gcc@8.2.0 arch=linux-centos7-zen
                    ^m4@1.4.18%gcc@8.2.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-centos7-zen
                        ^libsigsegv@2.12%gcc@8.2.0 arch=linux-centos7-zen
                ^util-macros@1.19.1%gcc@8.2.0 arch=linux-centos7-zen
            ^libxml2@2.9.10%gcc@8.2.0~python arch=linux-centos7-zen
                ^xz@5.2.5%gcc@8.2.0~pic arch=linux-centos7-zen
            ^numactl@2.0.14%gcc@8.2.0 patches=4e1d78cbbb85de625bad28705e748856033eaafab92a66dffd383a3d7e00cc94 arch=linux-centos7-zen
                ^autoconf@2.69%gcc@8.2.0 arch=linux-centos7-zen
                ^automake@1.16.2%gcc@8.2.0 arch=linux-centos7-zen
        ^slurm@18.08.9%gcc@8.2.0~gtk~hdf5~hwloc~mariadb~pmix+readline~restd sysconfdir=PREFIX/etc arch=linux-centos7-zen
    ^parmetis@4.0.3%gcc@8.2.0~gdb~int64~ipo+shared build_type=RelWithDebInfo patches=4f892531eb0a807eb1b82e683a416d3e35154a455274cf9b162fb02054d11a5b,50ed2081bc939269689789942067c58b3e522c269269a430d5d34c00edbc5870,704b84f7c7444d4372cb59cca6e1209df4ef3b033bc4ee3cf50f369bce972a9d arch=linux-centos7-zen
    ^petsc@3.14.1%gcc@8.2.0~X~batch~cgns~complex~cuda~debug+double~exodusii~fftw~giflib+hdf5+hypre~int64~jpeg~knl~libpng~libyaml~memkind+metis~moab~mpfr+mpi~mumps~p4est~random123~saws+shared~suite-sparse+superlu-dist~trilinos~valgrind clanguage=C arch=linux-centos7-zen
        ^hdf5@1.10.7%gcc@8.2.0~cxx~debug~fortran+hl~java+mpi+pic+shared~szip~threadsafe api=none arch=linux-centos7-zen
        ^hypre@2.20.0%gcc@8.2.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist patches=6e3336b1d62155f6350dfe42b0f9ea25d4fa0af60c7e540959139deb93a26059 arch=linux-centos7-zen
            ^openblas@0.3.12%gcc@8.2.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-centos7-zen
        ^python@3.8.6%gcc@8.2.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib patches=0d98e93189bc278fbc37a50ed7f183bd8aaf249a8e1670a465f0db6bb4f8cf87 arch=linux-centos7-zen
            ^expat@2.2.10%gcc@8.2.0+libbsd arch=linux-centos7-zen
                ^libbsd@0.10.0%gcc@8.2.0 arch=linux-centos7-zen
            ^gettext@0.21%gcc@8.2.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-centos7-zen
                ^tar@1.32%gcc@8.2.0 arch=linux-centos7-zen
            ^libffi@3.3%gcc@8.2.0 patches=26f26c6f29a7ce9bf370ad3ab2610f99365b4bdd7b82e7c31df41a3370d685c0 arch=linux-centos7-zen
            ^libuuid@1.0.3%gcc@8.2.0 arch=linux-centos7-zen
            ^sqlite@3.33.0%gcc@8.2.0+column_metadata+fts~functions~rtree arch=linux-centos7-zen
        ^superlu-dist@6.4.0%gcc@8.2.0~cuda~int64~ipo~openmp+shared build_type=RelWithDebInfo cuda_arch=none arch=linux-centos7-zen
    ^py-numpy@1.19.4%gcc@8.2.0+blas+lapack arch=linux-centos7-zen
        ^py-cython@0.29.21%gcc@8.2.0 arch=linux-centos7-zen
            ^py-setuptools@50.3.2%gcc@8.2.0 arch=linux-centos7-zen
    ^py-ply@3.11%gcc@8.2.0 arch=linux-centos7-zen
    ^py-six@1.14.0%gcc@8.2.0 arch=linux-centos7-zen
    ^py-sympy@1.4%gcc@8.2.0 arch=linux-centos7-zen
        ^py-mpmath@1.1.0%gcc@8.2.0 arch=linux-centos7-zen
    ^scotch@6.0.10%gcc@8.2.0+compression~esmumps~int64~metis+mpi+shared arch=linux-centos7-zen
        ^bison@3.6.4%gcc@8.2.0 arch=linux-centos7-zen
            ^help2man@1.47.11%gcc@8.2.0 arch=linux-centos7-zen
        ^flex@2.6.4%gcc@8.2.0+lex patches=09c22e5c6fef327d3e48eb23f0d610dcd3a35ab9207f12e0f875701c677978d3 arch=linux-centos7-zen
            ^findutils@4.6.0%gcc@8.2.0 patches=84b916c0bf8c51b7e7b28417692f0ad3e7030d1f3c248ba77c42ede5c1c5d11e,bd9e4e5cc280f9753ae14956c4e4aa17fe7a210f55dd6c84aa60b12d106d47a2 arch=linux-centos7-zen
                ^texinfo@6.5%gcc@8.2.0 patches=12f6edb0c6b270b8c8dba2ce17998c580db01182d871ee32b7b6e4129bd1d23a,1732115f651cff98989cb0215d8f64da5e0f7911ebf0c13b064920f088f2ffe1 arch=linux-centos7-zen
    ^slepc@3.14.0%gcc@8.2.0+arpack~blopex arch=linux-centos7-zen
        ^arpack-ng@3.7.0%gcc@8.2.0+mpi+shared arch=linux-centos7-zen
    ^suite-sparse@5.8.1%gcc@8.2.0~cuda~openmp+pic~tbb arch=linux-centos7-zen
        ^gmp@6.1.2%gcc@8.2.0 arch=linux-centos7-zen
        ^mpfr@4.0.2%gcc@8.2.0 patches=3f80b836948aa96f8d1cb9cc7f3f55973f19285482a96f9a4e1623d460bcccf0 arch=linux-centos7-zen
            ^autoconf-archive@2019.01.06%gcc@8.2.0 arch=linux-centos7-zen
    ^swig@4.0.2%gcc@8.2.0 arch=linux-centos7-zen
        ^pcre@8.44%gcc@8.2.0~jit+multibyte+utf arch=linux-centos7-zen
    ^trilinos@13.0.1%gcc@8.2.0~adios2~alloptpkgs+amesos+amesos2+anasazi+aztec+belos+boost~cgns~chaco~complex~cuda~debug~dtk+epetra+epetraext+exodus+explicit_template_instantiation~float+fortran+glm+gtest+hdf5~hwloc+hypre+ifpack+ifpack2~intrepid~intrepid2~ipo~isorropia+kokkos+matio~mesquite+metis~minitensor+ml+mpi+muelu+mumps+netcdf~nox~openmp~phalanx~piro~pnetcdf~python~rol~rythmos+sacado~shards+shared~shylu~stk~stratimikos~strumpack+suite-sparse~superlu~superlu-dist~teko~tempus+teuchos+tpetra~wrapper~x11~xsdkflags~zlib+zoltan+zoltan2 build_type=RelWithDebInfo cuda_arch=none cxxstd=11 gotype=long arch=linux-centos7-zen
        ^glm@0.9.7.1%gcc@8.2.0~ipo build_type=RelWithDebInfo arch=linux-centos7-zen
        ^matio@1.5.17%gcc@8.2.0+hdf5+shared+zlib arch=linux-centos7-zen
        ^mumps@5.3.3%gcc@8.2.0+complex+double+float~int64~metis+mpi~parmetis~ptscotch~scotch+shared arch=linux-centos7-zen
            ^netlib-scalapack@2.1.0%gcc@8.2.0~ipo~pic+shared build_type=Release patches=1c9ce5fee1451a08c2de3cc87f446aeda0b818ebbce4ad0d980ddf2f2a0b2dc4,f2baedde688ffe4c20943c334f580eb298e04d6f35c86b90a1f4e8cb7ae344a2 arch=linux-centos7-zen
        ^netcdf-c@4.7.4%gcc@8.2.0~dap~hdf4~jna+mpi~parallel-netcdf+pic+shared arch=linux-centos7-zen

```
To get what Spack sets up for PYTHONPATH when it attempts the install, can you also run `spack build-env fenics~hdf5 ^openmpi+pmi schedulers=slurm`? That will output all the shell variable settings. I'm specifically interested in what Spack sets for PYTHONPATH (if anything).
I get a hypre error:
```
[root@L01 tarballs]# spack build-env fenics~hdf5 ^openmpi+pmi schedulers=slurm
==> Warning: gcc@8.2.0 cannot build optimized binaries for "zen2". Using best target possible: "zen"
==> Error: Query of package 'hypre' for 'libs' failed
        prefix : /cm/shared/apps/spack-pkgs/linux-centos7-zen/gcc-8.2.0/hypre-2.20.0-6trxs7aapswkx6zg36veelg5r4b2vdhk
        spec : hypre@2.20.0%gcc@8.2.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist patches=6e3336b1d62155f6350dfe42b0f9ea25d4fa0af60c7e540959139deb93a26059 arch=linux-centos7-zen ^autoconf@2.69%gcc@8.2.0 arch=linux-centos7-zen ^automake@1.16.2%gcc@8.2.0 arch=linux-centos7-zen ^berkeley-db@18.1.40%gcc@8.2.0 arch=linux-centos7-zen ^gdbm@1.18.1%gcc@8.2.0 arch=linux-centos7-zen ^hwloc@1.11.11%gcc@8.2.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-centos7-zen ^libiconv@1.16%gcc@8.2.0 arch=linux-centos7-zen ^libpciaccess@0.16%gcc@8.2.0 arch=linux-centos7-zen ^libsigsegv@2.12%gcc@8.2.0 arch=linux-centos7-zen ^libtool@2.4.6%gcc@8.2.0 arch=linux-centos7-zen ^libxml2@2.9.10%gcc@8.2.0~python arch=linux-centos7-zen ^m4@1.4.18%gcc@8.2.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-centos7-zen ^ncurses@6.2%gcc@8.2.0~symlinks+termlib arch=linux-centos7-zen ^numactl@2.0.14%gcc@8.2.0 patches=4e1d78cbbb85de625bad28705e748856033eaafab92a66dffd383a3d7e00cc94 arch=linux-centos7-zen ^openblas@0.3.12%gcc@8.2.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-centos7-zen ^openmpi@3.1.6%gcc@8.2.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~lustre~memchecker~pmi~singularity~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=none arch=linux-centos7-zen ^perl@5.32.0%gcc@8.2.0+cpanm+shared+threads arch=linux-centos7-zen ^pkgconf@1.7.3%gcc@8.2.0 arch=linux-centos7-zen ^readline@8.0%gcc@8.2.0 arch=linux-centos7-zen ^util-macros@1.19.1%gcc@8.2.0 arch=linux-centos7-zen ^xz@5.2.5%gcc@8.2.0~pic arch=linux-centos7-zen ^zlib@1.2.11%gcc@8.2.0+optimize+pic+shared arch=linux-centos7-zen
        queried as : hypre
        extra parameters : []

[root@L01 tarballs]#
[root@L01 tarballs]#
[root@L01 tarballs]# spack spec --install-status hypre
Input spec
--------------------------------
 -   hypre

Concretized
--------------------------------
==> Warning: gcc@8.2.0 cannot build optimized binaries for "zen2". Using best target possible: "zen"
 -   hypre@2.20.0%gcc@8.2.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist patches=6e3336b1d62155f6350dfe42b0f9ea25d4fa0af60c7e540959139deb93a26059 arch=linux-centos7-zen
[+]      ^openblas@0.3.12%gcc@8.2.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-centos7-zen
 -       ^openmpi@3.1.6%gcc@8.2.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~lustre~memchecker~pmi~singularity~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=none arch=linux-centos7-zen
[+]          ^hwloc@1.11.11%gcc@8.2.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-centos7-zen
[+]              ^libpciaccess@0.16%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^libtool@2.4.6%gcc@8.2.0 arch=linux-centos7-zen
[+]                      ^m4@1.4.18%gcc@8.2.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-centos7-zen
[+]                          ^libsigsegv@2.12%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^pkgconf@1.7.3%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^util-macros@1.19.1%gcc@8.2.0 arch=linux-centos7-zen
[+]              ^libxml2@2.9.10%gcc@8.2.0~python arch=linux-centos7-zen
[+]                  ^libiconv@1.16%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^xz@5.2.5%gcc@8.2.0~pic arch=linux-centos7-zen
[+]                  ^zlib@1.2.11%gcc@8.2.0+optimize+pic+shared arch=linux-centos7-zen
[+]              ^numactl@2.0.14%gcc@8.2.0 patches=4e1d78cbbb85de625bad28705e748856033eaafab92a66dffd383a3d7e00cc94 arch=linux-centos7-zen
[+]                  ^autoconf@2.69%gcc@8.2.0 arch=linux-centos7-zen
[+]                      ^perl@5.32.0%gcc@8.2.0+cpanm+shared+threads arch=linux-centos7-zen
[+]                          ^berkeley-db@18.1.40%gcc@8.2.0 arch=linux-centos7-zen
[+]                          ^gdbm@1.18.1%gcc@8.2.0 arch=linux-centos7-zen
[+]                              ^readline@8.0%gcc@8.2.0 arch=linux-centos7-zen
[+]                                  ^ncurses@6.2%gcc@8.2.0~symlinks+termlib arch=linux-centos7-zen
[+]                  ^automake@1.16.2%gcc@8.2.0 arch=linux-centos7-zen

```
This is confusing: `hypre` is a transitive dependency of `fenics` but hasn't been installed yet: can you run `spack spec -I fenics~hdf5 ^openmpi+pmi schedulers=slurm` (the extra `-I` option will check what dependencies of `fenics` have been installed).

Also, while at first glance it doesn't seem related, there is a `fenics` PR at https://github.com/spack/spack/pull/25864 which may help.
Thank you. I shall look into #25864
```
[root@L01 tarballs]# spack spec -I fenics~hdf5 ^openmpi+pmi schedulers=slurm

Input spec
--------------------------------
 -   fenics~hdf5
 -       ^openmpi+pmi schedulers=slurm

Concretized
--------------------------------
 -   fenics@2016.1.0%gcc@8.2.0~doc~hdf5~ipo+mpi+openmp+parmetis+petsc~qt+scotch+shared+slepc+suite-sparse+trilinos~vtk build_type=RelWithDebInfo patches=8de9625a4ba4d27801bde734f744c96efcce57ecdec63556a5f6e2c28d4af532 arch=linux-centos7-zen
[+]      ^boost@1.74.0%gcc@8.2.0+atomic+chrono~clanglibcpp~container~context~coroutine+date_time~debug+exception~fiber+filesystem+graph~icu+iostreams+locale+log+math~mpi+multithreaded~numpy~pic+program_options~python+random+regex+serialization+shared+signals~singlethreaded+system~taggedlayout+test+thread+timer~versionedlayout+wave cxxstd=98 visibility=hidden arch=linux-centos7-zen
[+]          ^bzip2@1.0.8%gcc@8.2.0+shared arch=linux-centos7-zen
[+]              ^diffutils@3.7%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^libiconv@1.16%gcc@8.2.0 arch=linux-centos7-zen
[+]          ^zlib@1.2.11%gcc@8.2.0+optimize+pic+shared arch=linux-centos7-zen
[+]      ^cmake@3.18.4%gcc@8.2.0~doc+ncurses+openssl+ownlibs~qt patches=bf695e3febb222da2ed94b3beea600650e4318975da90e4a71d6f31a6d5d8c3d arch=linux-centos7-zen
[+]          ^ncurses@6.2%gcc@8.2.0~symlinks+termlib arch=linux-centos7-zen
[+]              ^pkgconf@1.7.3%gcc@8.2.0 arch=linux-centos7-zen
[+]          ^openssl@1.1.1h%gcc@8.2.0+systemcerts arch=linux-centos7-zen
[+]              ^perl@5.32.0%gcc@8.2.0+cpanm+shared+threads arch=linux-centos7-zen
[+]                  ^berkeley-db@18.1.40%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^gdbm@1.18.1%gcc@8.2.0 arch=linux-centos7-zen
[+]                      ^readline@8.0%gcc@8.2.0 arch=linux-centos7-zen
[+]      ^eigen@3.3.8%gcc@8.2.0~ipo build_type=RelWithDebInfo patches=62590e9b33a8f72b608a72b87147a306e7cb20766ea53c6b8e0a183fa6cb7635 arch=linux-centos7-zen
[+]      ^metis@5.1.0%gcc@8.2.0~gdb~int64+real64+shared build_type=Release patches=4991da938c1d3a1d3dea78e49bbebecba00273f98df2a656e38b83d55b281da1,b1225da886605ea558db7ac08dd8054742ea5afe5ed61ad4d0fe7a495b1270d2 arch=linux-centos7-zen
[+]      ^openmpi@3.1.6%gcc@8.2.0~atomics~cuda~cxx~cxx_exceptions+gpfs~java~legacylaunchers~lustre~memchecker+pmi~singularity~sqlite3+static~thread_multiple+vt+wrapper-rpath fabrics=none schedulers=slurm arch=linux-centos7-zen
[+]          ^hwloc@1.11.11%gcc@8.2.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml+pci+shared arch=linux-centos7-zen
[+]              ^libpciaccess@0.16%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^libtool@2.4.6%gcc@8.2.0 arch=linux-centos7-zen
[+]                      ^m4@1.4.18%gcc@8.2.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-centos7-zen
[+]                          ^libsigsegv@2.12%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^util-macros@1.19.1%gcc@8.2.0 arch=linux-centos7-zen
[+]              ^libxml2@2.9.10%gcc@8.2.0~python arch=linux-centos7-zen
[+]                  ^xz@5.2.5%gcc@8.2.0~pic arch=linux-centos7-zen
[+]              ^numactl@2.0.14%gcc@8.2.0 patches=4e1d78cbbb85de625bad28705e748856033eaafab92a66dffd383a3d7e00cc94 arch=linux-centos7-zen
[+]                  ^autoconf@2.69%gcc@8.2.0 arch=linux-centos7-zen
[+]                  ^automake@1.16.2%gcc@8.2.0 arch=linux-centos7-zen
[+]          ^slurm@18.08.9%gcc@8.2.0~gtk~hdf5~hwloc~mariadb~pmix+readline~restd sysconfdir=PREFIX/etc arch=linux-centos7-zen
[+]      ^parmetis@4.0.3%gcc@8.2.0~gdb~int64~ipo+shared build_type=RelWithDebInfo patches=4f892531eb0a807eb1b82e683a416d3e35154a455274cf9b162fb02054d11a5b,50ed2081bc939269689789942067c58b3e522c269269a430d5d34c00edbc5870,704b84f7c7444d4372cb59cca6e1209df4ef3b033bc4ee3cf50f369bce972a9d arch=linux-centos7-zen
[+]      ^petsc@3.14.1%gcc@8.2.0~X~batch~cgns~complex~cuda~debug+double~exodusii~fftw~giflib+hdf5+hypre~int64~jpeg~knl~libpng~libyaml~memkind+metis~moab~mpfr+mpi~mumps~p4est~random123~saws+shared~suite-sparse+superlu-dist~trilinos~valgrind clanguage=C arch=linux-centos7-zen
[+]          ^hdf5@1.10.7%gcc@8.2.0~cxx~debug~fortran+hl~java+mpi+pic+shared~szip~threadsafe api=none arch=linux-centos7-zen
[+]          ^hypre@2.20.0%gcc@8.2.0~complex~debug~int64~internal-superlu~mixedint+mpi~openmp+shared~superlu-dist patches=6e3336b1d62155f6350dfe42b0f9ea25d4fa0af60c7e540959139deb93a26059 arch=linux-centos7-zen
[+]              ^openblas@0.3.12%gcc@8.2.0~consistent_fpcsr~ilp64+pic+shared threads=none arch=linux-centos7-zen
[+]          ^python@3.8.6%gcc@8.2.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib patches=0d98e93189bc278fbc37a50ed7f183bd8aaf249a8e1670a465f0db6bb4f8cf87 arch=linux-centos7-zen
[+]              ^expat@2.2.10%gcc@8.2.0+libbsd arch=linux-centos7-zen
[+]                  ^libbsd@0.10.0%gcc@8.2.0 arch=linux-centos7-zen
[+]              ^gettext@0.21%gcc@8.2.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-centos7-zen
[+]                  ^tar@1.32%gcc@8.2.0 arch=linux-centos7-zen
[+]              ^libffi@3.3%gcc@8.2.0 patches=26f26c6f29a7ce9bf370ad3ab2610f99365b4bdd7b82e7c31df41a3370d685c0 arch=linux-centos7-zen
[+]              ^libuuid@1.0.3%gcc@8.2.0 arch=linux-centos7-zen
[+]              ^sqlite@3.33.0%gcc@8.2.0+column_metadata+fts~functions~rtree arch=linux-centos7-zen
[+]          ^superlu-dist@6.4.0%gcc@8.2.0~cuda~int64~ipo~openmp+shared build_type=RelWithDebInfo cuda_arch=none arch=linux-centos7-zen
[+]      ^py-numpy@1.19.4%gcc@8.2.0+blas+lapack arch=linux-centos7-zen
[+]          ^py-cython@0.29.21%gcc@8.2.0 arch=linux-centos7-zen
[+]              ^py-setuptools@50.3.2%gcc@8.2.0 arch=linux-centos7-zen
[+]      ^py-ply@3.11%gcc@8.2.0 arch=linux-centos7-zen
[+]      ^py-six@1.14.0%gcc@8.2.0 arch=linux-centos7-zen
[+]      ^py-sympy@1.4%gcc@8.2.0 arch=linux-centos7-zen
[+]          ^py-mpmath@1.1.0%gcc@8.2.0 arch=linux-centos7-zen
[+]      ^scotch@6.0.10%gcc@8.2.0+compression~esmumps~int64~metis+mpi+shared arch=linux-centos7-zen
[+]          ^bison@3.6.4%gcc@8.2.0 arch=linux-centos7-zen
[+]              ^help2man@1.47.11%gcc@8.2.0 arch=linux-centos7-zen
[+]          ^flex@2.6.4%gcc@8.2.0+lex patches=09c22e5c6fef327d3e48eb23f0d610dcd3a35ab9207f12e0f875701c677978d3 arch=linux-centos7-zen
[+]              ^findutils@4.6.0%gcc@8.2.0 patches=84b916c0bf8c51b7e7b28417692f0ad3e7030d1f3c248ba77c42ede5c1c5d11e,bd9e4e5cc280f9753ae14956c4e4aa17fe7a210f55dd6c84aa60b12d106d47a2 arch=linux-centos7-zen
[+]                  ^texinfo@6.5%gcc@8.2.0 patches=12f6edb0c6b270b8c8dba2ce17998c580db01182d871ee32b7b6e4129bd1d23a,1732115f651cff98989cb0215d8f64da5e0f7911ebf0c13b064920f088f2ffe1 arch=linux-centos7-zen
[+]      ^slepc@3.14.0%gcc@8.2.0+arpack~blopex arch=linux-centos7-zen
[+]          ^arpack-ng@3.7.0%gcc@8.2.0+mpi+shared arch=linux-centos7-zen
[+]      ^suite-sparse@5.8.1%gcc@8.2.0~cuda~openmp+pic~tbb arch=linux-centos7-zen
[+]          ^gmp@6.1.2%gcc@8.2.0 arch=linux-centos7-zen
[+]          ^mpfr@4.0.2%gcc@8.2.0 patches=3f80b836948aa96f8d1cb9cc7f3f55973f19285482a96f9a4e1623d460bcccf0 arch=linux-centos7-zen
[+]              ^autoconf-archive@2019.01.06%gcc@8.2.0 arch=linux-centos7-zen
[+]      ^swig@4.0.2%gcc@8.2.0 arch=linux-centos7-zen
[+]          ^pcre@8.44%gcc@8.2.0~jit+multibyte+utf arch=linux-centos7-zen
[+]      ^trilinos@13.0.1%gcc@8.2.0~adios2~alloptpkgs+amesos+amesos2+anasazi+aztec+belos+boost~cgns~chaco~complex~cuda~debug~dtk+epetra+epetraext+exodus+explicit_template_instantiation~float+fortran+glm+gtest+hdf5~hwloc+hypre+ifpack+ifpack2~intrepid~intrepid2~ipo~isorropia+kokkos+matio~mesquite+metis~minitensor+ml+mpi+muelu+mumps+netcdf~nox~openmp~phalanx~piro~pnetcdf~python~rol~rythmos+sacado~shards+shared~shylu~stk~stratimikos~strumpack+suite-sparse~superlu~superlu-dist~teko~tempus+teuchos+tpetra~wrapper~x11~xsdkflags~zlib+zoltan+zoltan2 build_type=RelWithDebInfo cuda_arch=none cxxstd=11 gotype=long arch=linux-centos7-zen
[+]          ^glm@0.9.7.1%gcc@8.2.0~ipo build_type=RelWithDebInfo arch=linux-centos7-zen
[+]          ^matio@1.5.17%gcc@8.2.0+hdf5+shared+zlib arch=linux-centos7-zen
[+]          ^mumps@5.3.3%gcc@8.2.0+complex+double+float~int64~metis+mpi~parmetis~ptscotch~scotch+shared arch=linux-centos7-zen
[+]              ^netlib-scalapack@2.1.0%gcc@8.2.0~ipo~pic+shared build_type=Release patches=1c9ce5fee1451a08c2de3cc87f446aeda0b818ebbce4ad0d980ddf2f2a0b2dc4,f2baedde688ffe4c20943c334f580eb298e04d6f35c86b90a1f4e8cb7ae344a2 arch=linux-centos7-zen
[+]          ^netcdf-c@4.7.4%gcc@8.2.0~dap~hdf4~jna+mpi~parallel-netcdf+pic+shared arch=linux-centos7-zen

```
What version of Spack are you using (can you run `spack debug report`)?

I do not see `py-ply` as a dependency in 5fddd48f801616326b5dd6acb9e14879affb8da5 (Spack develop as of today).
```
[root@L01 tarballs]# spack debug report
* **Spack:** 0.16.2
* **Python:** 3.8.6
* **Platform:** linux-centos7-zen2
```
@scheibelp - note that #25864 is for `fenicsx`, which is quite different from legacy `fenics` package
@scheibelp 
I was able to see the PYTHONPATH that spack uses during build-env
```
[root@L01 software]# spack build-env fenics | grep PYTHONPATH | sed 's/:/\n/g'
==> Warning: gcc@8.2.0 cannot build optimized binaries for "zen2". Using best target possible: "zen"
PYTHONPATH=/cm/shared/apps/spack-pkgs/fenics/2016.1.0-hhcr4l3qjmadirzbyzcksxlynzxqye55/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/fenics/2016.1.0-hhcr4l3qjmadirzbyzcksxlynzxqye55/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-numpy/1.19.4-kqhki5eafkdrtt3xj3opla5dins7uqpg/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-numpy/1.19.4-kqhki5eafkdrtt3xj3opla5dins7uqpg/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-cython/0.29.21-aj6nww3fm7udn7euq3uf3jtxaeq4ofey/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-cython/0.29.21-aj6nww3fm7udn7euq3uf3jtxaeq4ofey/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-setuptools/50.3.2-lmbfsmftmbkpbhr6hxdo2herlq2xqbpn/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-setuptools/50.3.2-lmbfsmftmbkpbhr6hxdo2herlq2xqbpn/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-ply/3.11-fpyplf44xgseqlpml5vxvs4r7bxv4c53/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-ply/3.11-fpyplf44xgseqlpml5vxvs4r7bxv4c53/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-six/1.14.0-me3k65ic2t5it7npzrsaddtsxzgvmzxz/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-six/1.14.0-me3k65ic2t5it7npzrsaddtsxzgvmzxz/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-sympy/1.4-kvteabovy66apdhesr7yrajlnqbmgfdu/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-sympy/1.4-kvteabovy66apdhesr7yrajlnqbmgfdu/lib64/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-mpmath/1.1.0-srq4iwf4q7ki25t4lpjllf4j5chfuc2f/lib/python3.8/site-packages
/cm/shared/apps/spack-pkgs/py-mpmath/1.1.0-srq4iwf4q7ki25t4lpjllf4j5chfuc2f/lib64/python3.8/site-packages
```
It appears py-ply is being loaded. But cmake fails just as before:
```
1 error found in build log:
     147      Ignoring EXACT since no version is requested.
     148    This warning is for project developers.  Use -Wno-dev to suppress i
            t.
     149
     150    -- Found PythonLibs: /cm/shared/apps/spack-pkgs/python/3.8.6-u7px4s
            sttiqjhc6q2arrww4wqceck7nk/lib/libpython3.8.so (found version "3.8.
            6")
     151    ImportError: No module named site
     152    -- Could NOT find PY_ply (missing: PY_PLY_path)
  >> 153    CMake Error at CMakeLists.txt:438 (message):
     154      Required Python module 'ply' (http://www.dabeaz.com/ply/) could n
            ot be
     155      found.  Install ply or set DOLFIN_ENABLE_PYTHON to false.
     156
     157
     158    -- Configuring incomplete, errors occurred!
     159    See also "/home/apal/.spack_root/stage/spack-stage-fenics-2016.1.0-
            hhcr4l3qjmadirzbyzcksxlynzxqye55/spack-build-hhcr4l3/CMakeFiles/CMa
            keOutput.log".

See build log for details:
  /home/apal/.spack_root/stage/spack-stage-fenics-2016.1.0-hhcr4l3qjmadirzbyzcksxlynzxqye55/spack-build-out.txt

```
I discovered that cmake is using python2 as the PYTHON_EXECUTABLE rather than python3. The CMakeCache.txt in the build folder reads the following. I shall try to figure out how to get spack/cmake to use python3 instead of python2.
```
//Path to a program.
PYTHON_EXECUTABLE:FILEPATH=/bin/python2

//Path to a file.
PYTHON_INCLUDE_DIR:PATH=/cm/shared/apps/spack-pkgs/python/3.8.6-u7px4ssttiqjhc6q2arrww4wqceck7nk/include/python3.8

//Path to a library.
PYTHON_LIBRARY:FILEPATH=/cm/shared/apps/spack-pkgs/python/3.8.6-u7px4ssttiqjhc6q2arrww4wqceck7nk/lib/libpython3.8.so
```

Thanks for that extra info! Based on https://github.com/spack/spack/issues/25877#issuecomment-917741099, I think the issue is that `fenics` needs to set `PYTHON_EXECUTABLE` in its `cmake_args` method (`llvm` has an example), would you be able to try that (and possibly create a PR for Spack if that works)?
Thank you. That fixed the issue. Now the fenics install progresses to a new error: **ufc.h not found.**
This appears to be similar to #5693, which is currently being addressed.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/fenics/package.py b/var/spack/repos/builtin/packages/fenics/package.py
--- a/var/spack/repos/builtin/packages/fenics/package.py
+++ b/var/spack/repos/builtin/packages/fenics/package.py
@@ -122,7 +122,7 @@ class Fenics(CMakePackage):
     depends_on('py-sphinx@1.0.1:', when='+doc', type='build')
 
     def cmake_args(self):
-        return [
+        args = [
             self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
             self.define('DOLFIN_SKIP_BUILD_TESTS', True),
             self.define_from_variant('DOLFIN_ENABLE_OPENMP', 'openmp'),
@@ -146,6 +146,12 @@ def cmake_args(self):
             self.define_from_variant('DOLFIN_ENABLE_ZLIB', 'zlib'),
         ]
 
+        if '+python' in self.spec:
+            args.append(self.define(
+                'PYTHON_EXECUTABLE', self.spec['python'].command.path))
+
+        return args
+
     # set environment for bulding python interface
     def setup_build_environment(self, env):
         env.set('DOLFIN_DIR', self.prefix)


Test patch: