[PATCH 04 of 10] demandimport: don't delay _distutils_hack import
Mads Kiilerich
mads at kiilerich.com
Wed Jun 28 00:06:49 UTC 2023
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1687908670 -7200
# Wed Jun 28 01:31:10 2023 +0200
# Branch stable
# Node ID 8687d17528a1fe764572c402f2d0198d5a6c8fbc
# Parent deb45f7a7f7bdc36c36f7bfb63c36701b44972ab
demandimport: don't delay _distutils_hack import
test-demandimport.py would fail on 'import distutils.msvc9compiler' because
warnings:
/usr/lib/python3.11/site-packages/_distutils_hack/__init__.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
warnings.warn(
/usr/lib/python3.11/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Telling demandimport to ignore this module will allow the hack to work as
intended.
Note:
The test for distutils.msvc9compiler comes from 2205d00b6d2b. But since then,
distutils is going away, and setuptools has moved forward and is replacing it.
It is unclear exactly what is being tested here and how setuptools should
depended on msvc9compiler. The test might no longer be relevant.
diff --git a/hgdemandimport/__init__.py b/hgdemandimport/__init__.py
--- a/hgdemandimport/__init__.py
+++ b/hgdemandimport/__init__.py
@@ -55,6 +55,9 @@ IGNORES = {
'builtins',
'urwid.command_map', # for pudb
'lzma',
+ # setuptools uses this hack to inject it's own distutils at import time
+ 'setuptools',
+ '_distutils_hack.override',
}
_pypy = '__pypy__' in sys.builtin_module_names
More information about the Mercurial-devel
mailing list