Installing Python on Mohave with pyenv

I use pyenv to manage Python versions on my Mac. I recently have gotten errors like

WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?


zipimport.ZipImportError: can't decompress data; zlib not available

The solution seems to be setting LDFLAGS and CPPFLAGS to point to the sqlite3 and zlib libraries, e.g.:

brew install sqlite3
brew install zlib

export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/sqlite/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/sqlite/include"
pyenv install 3.7.0