From 32e2369d2f3fff275332514b498365ffac90c4b0 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Fri, 6 Sep 2024 09:46:15 -0500 Subject: [PATCH] Handle DISTUTILS_DEBUG environment variable (#55) This variable causes setuptools/distutils to output more information to stdout than this extension is expecting to parse. Rather than update the parser to handle it, it's far more simple to simply suppress the verbose output during the calls which try to parse output. --- .../package_identification/python_setup_py.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/colcon_python_setup_py/package_identification/python_setup_py.py b/colcon_python_setup_py/package_identification/python_setup_py.py index 7a513a0..466e68d 100644 --- a/colcon_python_setup_py/package_identification/python_setup_py.py +++ b/colcon_python_setup_py/package_identification/python_setup_py.py @@ -212,6 +212,11 @@ def get_setup_arguments_with_context(setup_py, env): # invoke get_setup_arguments() in a separate interpreter cmd = [sys.executable, '-c', ';'.join(code_lines)] + if env is None: + env = os.environ + if 'DISTUTILS_DEBUG' in env: + env = dict(env) + env.pop('DISTUTILS_DEBUG') result = subprocess.run( cmd, stdout=subprocess.PIPE, env=env, check=True) output = result.stdout.decode('utf-8') @@ -236,6 +241,9 @@ def get_setup_information(setup_py, *, env=None): global _setup_information_cache if env is None: env = os.environ + if 'DISTUTILS_DEBUG' in env: + env = dict(env) + env.pop('DISTUTILS_DEBUG') hashable_env = (setup_py, ) + tuple(sorted(env.items())) if hashable_env not in _setup_information_cache: _setup_information_cache[hashable_env] = _get_setup_information(