From 57cdf3ebfb71616cacbede6363c83c6110e03cba Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Tue, 5 Sep 2023 11:08:10 -0500 Subject: [PATCH] Don't pass COV_CORE_SOURCE to python build subprocess It appears that when this varible is set, pytest-cov will import modules during the interpreter initialization before the sitecustomize hook runs. Among the modules imported is sysconfig, which caches its global state before we're able to modify it, thus rendering the entire hook unusable. The documentation for the 'site' module has more details here, but I wasn't able to find a more aggressive way to prioritize our hook over others. For now, we should suppress COV_CORE_SOURCE to unblock new tests in colcon itself. --- colcon_core/task/python/build.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/colcon_core/task/python/build.py b/colcon_core/task/python/build.py index c177b809..097b9ed9 100644 --- a/colcon_core/task/python/build.py +++ b/colcon_core/task/python/build.py @@ -76,6 +76,8 @@ async def build(self, *, additional_hooks=None): # noqa: D102 env = dict(env) env['PYTHONPATH'] = str(prefix_override) + os.pathsep + \ python_lib + os.pathsep + env.get('PYTHONPATH', '') + # coverage capture interferes with sitecustomize + env.pop('COV_CORE_SOURCE') # determine if setuptools specific commands are available available_commands = await self._get_available_commands(