pygame icon indicating copy to clipboard operation
pygame copied to clipboard

`distutils.ccompiler.spawn` is no longer available

Open frenzymadness opened this issue 1 year ago • 2 comments

When building pygame with the latest setuptools/distutils, this line:

https://github.com/pygame/pygame/blob/79807da84c9bacf8df5a177763e14c924e3b15e2/setup.py#L126

fails with:

AttributeError: module 'distutils.ccompiler' has no attribute 'spawn'

frenzymadness avatar Mar 15 '25 09:03 frenzymadness

Workaround: sed -i "s/distutils.ccompiler.spawn/distutils.spawn.spawn/" setup.py

frenzymadness avatar Mar 15 '25 09:03 frenzymadness

sed -i "s/distutils.ccompiler.spawn/distutils.spawn.spawn/" setup.p

Hello! I'm new to coding and have run into an issue. How do I apply this workaround? The code I have is from online, so I don't have prior experience with Pygame.

rexxxxer avatar Mar 19 '25 04:03 rexxxxer

Workaround: sed -i "s/distutils.ccompiler.spawn/distutils.spawn.spawn/" setup.py

how to do that if adding it via uv? or I guess: which distutils to install in the uv venv?

tyoc213 avatar Aug 08 '25 22:08 tyoc213

Workaround: sed -i "s/distutils.ccompiler.spawn/distutils.spawn.spawn/" setup.py

how to do that if adding it via uv? or I guess: which distutils to install in the uv venv?

You cannot do it during the installation, if that's what you are asking about. You can clone/download the code, fix it, and then install it from the updated source.

frenzymadness avatar Aug 11 '25 08:08 frenzymadness

Thanks for the sed command. Using uv:

git clone --depth=1 https://github.com/pygame/pygame
cd pygame
uv venv
source .venv/bin/activate
uv pip install setuptools
sed -i "s/distutils.ccompiler.spawn/distutils.spawn.spawn/" setup.py
PYGAME_DETECT_AVX2=1 python3 setup.py -config -auto
PYGAME_DETECT_AVX2=1 python3 setup.py build
PYGAME_DETECT_AVX2=1 python3 setup.py install --user
uv pip install .
python3 -m pygame.examples.aliens

brccabral avatar Sep 18 '25 18:09 brccabral