Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ModuleNotFoundError for _distutils/util.py:byte_compile #4484

Closed
wants to merge 1 commit into from

Conversation

kfollesdal
Copy link

Summary of changes

Solve ModuleNotfoundError 'No module named 'distutils' for function _distutils/util.py:byte_compile. By adding import setuptools to the script in byte_complie, distutils will be available.

The python package thrift is broken for python 3.12 in nixpkgs, since distutils was removed in python 3.12. The thrift python package use setuptools/distutils to build.

The build process use the function _distutils/util.py:byte_compile, that run a python script in a subprocess. Problem is that we get error:

       >   File "/build/tmpgob9mq6_.py", line 1, in <module>
       >     from distutils.util import byte_compile
       > ModuleNotFoundError: No module named 'distutils'

when it try to build. Problem is that in the subprocess the setuptool is not imported and therefore are distutils not available.

This PR solve the problem by import setuptools first in the script.

Solve ModuleNotfoundError 'No module named 'distutils' for function
_distutils/util.py:byte_compile. By adding 'import setuptools' to the
script in byte_complie, distutils will be available.
@kfollesdal
Copy link
Author

Discovered that it is a duplicate of #4229

@kfollesdal
Copy link
Author

Maybe relevant? pypa/distutils#224

@kfollesdal
Copy link
Author

Close since duplicate of #4229

Found a solutions by modify PYTHONPATH before build:

DISTUTILS=$(mktemp -d)
ln -s ${setuptools}/${python.sitePackages}/setuptools/_distutils "$DISTUTILS/distutils"
PYTHONPATH="$PYTHONPATH:$DISTUTILS"

@kfollesdal kfollesdal closed this Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant