Skip to content

How to do custom build.build and build_ext.build_ext classes in Python 3.12 (i.e., without the stdlib distutils)? #4062

Answered by abravalheri
mcepl asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mcepl,

My understanding of how this works is the following:

  1. setuptools._distutils is private for a reason and should not be imported.
    Indeed as discussed in #3743, importing directly from setuptools._distutils will actively break your code.
    This happens because setuptools._distutils is not implemented in such a way that it can be imported directly, but instead it needs to go through a custom MetaPathFinder implemented by setuptools.

  2. The statement in:

    ... the solution there (“just import directly from the stdlib distutils”) is obviously not applicable any more for 3.12+.

    is not "completely" valid. Note that the solution presented in the other discussion was never "import directly…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mcepl
Comment options

Answer selected by mcepl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants