I didn't figure out how to build an RPM, but it turns out it's good enough just to build with --prefix=/opt/python37 and then tar that up. On the target machine, untar and add the shared lib to ld.so.conf and it works fine.
I need to make a python3.7 installation for CentOS8, so I can install that via rpm/yum rather than building from source on the target machine (need to avoid installing gcc and other build deps there).
Is that a reasonable possibility? I'm comfortable building python from source, but I don't know how to package up the resulting install in a portable way (portable to other machines running the same OS). RPM would be ideal but I'd be happy with a tgz and a known set of yum runtime dependencies.
Note that there is no official CentOS8 python 3.7, only 3.6 and 3.8. I specifically need 3.7.
Googling for "build python distribution" or "build python RPM" just shows how to build python modules for distribution, not python itself.
(I know miniconda/miniforge is an alternative way to get this done, but I'd prefer to do the build myself.)
How can I build an rpm or tgz of a particular python version, specifically python3.7 for CentOS8