Index: setuptools-69.0.2/setuptools/_distutils/command/install_lib.py =================================================================== --- setuptools-69.0.2.orig/setuptools/_distutils/command/install_lib.py +++ setuptools-69.0.2/setuptools/_distutils/command/install_lib.py @@ -133,6 +133,12 @@ class install_lib(Command): # should at least generate usable bytecode in RPM distributions. install_root = self.get_finalized_command('install').root + # UGLY HACK WARNING. Indirect compilation requires distutils, which + # means Python 3.11 or less. If and only if an environment variable + # is set, do we force direct compilation. + # See also https://github.com/pypa/setuptools/issues/4164 + direct = os.environ.get('SETUPTOOLS_FORCE_DIRECT', None) + if self.compile: byte_compile( files, @@ -140,6 +146,7 @@ class install_lib(Command): force=self.force, prefix=install_root, dry_run=self.dry_run, + direct=direct, ) if self.optimize > 0: byte_compile( @@ -149,6 +156,7 @@ class install_lib(Command): prefix=install_root, verbose=self.verbose, dry_run=self.dry_run, + direct=direct, ) # -- Utility methods -----------------------------------------------