Repository: spack/spack

Issue:
file too short when building with Python 10
In case there is insight here, I wanted to open an issue. Flux core failed building tonight because of:

```console
 ==> Warning: Module file /opt/spack/share/spack/modules/linux-ubuntu22.04-x86_64_v4/openssl-1.1.1s-gcc-12.1.0-uafqtva exists and will not be overwritten
==> Error: ProcessError: Command exited with status 2:
    'make' '-j2' 'install'

2 errors found in build log:
     1299    if test "3.10" != "3.10"; then \
     1300    	if test -f /opt/spack/opt/spack/linux-ubuntu22.04-x86_64_v4/gcc-1
             2.1.0/python-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/bin/python3.1
             0 -o -h /opt/spack/opt/spack/linux-ubuntu22.04-x86_64_v4/gcc-12.1.
             0/python-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/bin/python3.10; \
     1301    	then rm -f /opt/spack/opt/spack/linux-ubuntu22.04-x86_64_v4/gcc-1
             2.1.0/python-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/bin/python3.1
             0; \
     1302    	fi; \
     1303    	(cd /opt/spack/opt/spack/linux-ubuntu22.04-x86_64_v4/gcc-12.1.0/p
             ython-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/bin; ln python3.10 p
             ython3.10); \
     1304    fi
  >> 1305    ./python: error while loading shared libraries: /opt/spack/opt/spa
             ck/linux-ubuntu22.04-x86_64_v4/gcc-12.1.0/python-3.10.8-vyifnzccjm
             6iquatjeiig4fbm4gcjlsb/lib/libpython3.10.so.1.0: file too short
  >> 1306    make: *** [Makefile:637: sharedmods] Error 127
     1307    make: *** Waiting for unfinished jobs....
     1308    if test "x" != "x" ; then \
     1309    	rm -f /opt/spack/opt/spack/linux-ubuntu22.04-x86_64_v4/gcc-12.1.0
             /python-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/binpython3.10-32; 
             \
     1310    	lipo  \
     1311    		-output /opt/spack/opt/spack/linux-ubuntu22.04-x86_64_v4/gcc-12.
             1.0/python-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/bin/python3.10-
             32 \
     1312    		/opt/spack/opt/spack/linux-ubuntu22.04-x86_64_v4/gcc-12.1.0/pyth
             on-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/bin/python3.10; \

See build log for details:
  /tmp/runner/spack-stage/spack-stage-python-3.10.8-vyifnzccjm6iquatjeiig4fbm4gcjlsb/spack-build-out.txt
```
It's a weird error - "file too short" and looks like it happens during the install phase:

https://github.com/flux-framework/spack/actions/runs/3616888046/jobs/6096151257

Could it be ephemeral - something with the runner or download? I'm too tired to debug now. Does spack not support Python 3.10 yet?


Discussion:
> Does spack not support Python 3.10 yet?

Spack supports Python 3.10 and 3.11. I exclusively use Python 3.10 to run Spack, and Spack to install Python 3.10.
Gotcha. So this is an actual bug. I was poking around the internets last night and the most similar I found was more than one process trying to download / build a file, and it was corrupt (and then that message showing).
Yeah, it's a pretty obscure bug, the message comes from the dynamic linker. It's most likely a corrupted file. How it's corrupted is very hard to say... It seems like Python was built from sources? That rules out corruption due to relocation code.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -587,7 +587,8 @@ def install(self, spec, prefix):
             if sys.platform == "win32":
                 self.win_installer(prefix)
             else:
-                make(*self.install_targets)
+                # See https://github.com/python/cpython/issues/102007
+                make(*self.install_targets, parallel=False)
 
     @run_after("install")
     def filter_compilers(self):


Test patch: