Repost from Unix & Linux Stack Exchange:
The original problem:
$ pyenv install
Downloading Python-3.8.10.tar.xz...
-> https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tar.xz
Installing Python-3.8.10...
BUILD FAILED (NixOS 21.05.1555.6b940846e99 using python-build 20180424)
Inspect or clean up the working tree at /tmp/python-build.20210722134513.93343
Results logged to /tmp/python-build.20210722134513.93343.log
Last 10 log lines:
File "/tmp/python-build.20210722134513.93343/Python-3.8.10/Lib/ensurepip/__init__.py", line 206, in _main
return _bootstrap(
File "/tmp/python-build.20210722134513.93343/Python-3.8.10/Lib/ensurepip/__init__.py", line 125, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/tmp/python-build.20210722134513.93343/Python-3.8.10/Lib/ensurepip/__init__.py", line 34, in _run_pip
return subprocess.run([sys.executable, "-c", code], check=True).returncode
File "/tmp/python-build.20210722134513.93343/Python-3.8.10/Lib/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/python-build.20210722134513.93343/Python-3.8.10/python', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmp4bavyai1/setuptools-56.0.0-py3-none-any.whl\', \'/tmp/tmp4bavyai1/pip-21.1.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmp4bavyai1\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [Makefile:1198: install] Error 1
The log file shows the following error:
ModuleNotFoundError: No module named 'zlib'
The zlib package is installed.
I tried a portable version of this suggestion:
CPPFLAGS="-I$(nix eval --raw nixos.zlib.outPath)/include" LDFLAGS="-L$(nix eval --raw nixos.zlib.outPath)/lib" pyenv install
But that didn’t help. Presumably because there is no “include” directory in the zlib package root. There also doesn’t seem to be any zlib-dev package, so I’m not sure where that is meant to come from.
I’m also open to suggestions involving building a custom derivation, with the caveat that I can’t simply use the “python38” package because the project depends on a specific patch version.