From 98e30ff0cf84d40dedca6726409304105c1390e5 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Mon, 11 Mar 2024 12:38:01 -0500 Subject: [PATCH] Suppress setup.py deprecation warnings during build This warning is legitimate and something that developers should be aware of, but at present, the replacement does not provide all of the functionality necessary to support the currently available features in colcon. When that changes, we'll communicate the upgrade path to users and re-enable the deprecation warning. --- colcon_core/task/python/build.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/colcon_core/task/python/build.py b/colcon_core/task/python/build.py index 5dc89e442..442d5a620 100644 --- a/colcon_core/task/python/build.py +++ b/colcon_core/task/python/build.py @@ -8,7 +8,6 @@ from pathlib import Path import shutil import sys -from sys import executable from colcon_core.environment import create_environment_hooks from colcon_core.environment import create_environment_scripts @@ -26,6 +25,12 @@ logger = colcon_logger.getChild(__name__) +_PYTHON_CMD = [ + sys.executable, + '-W', + 'ignore:setup.py install is deprecated', +] + def _get_install_scripts(path): setup_cfg_path = os.path.join(path, 'setup.cfg') @@ -92,7 +97,7 @@ async def build(self, *, additional_hooks=None): # noqa: D102 # invoke `setup.py install` step with lots of arguments # to avoid placing any files in the source space - cmd = [executable, 'setup.py'] + cmd = _PYTHON_CMD + ['setup.py'] if 'egg_info' in available_commands: # `setup.py egg_info` requires the --egg-base to exist os.makedirs(args.build_base, exist_ok=True) @@ -139,8 +144,8 @@ async def build(self, *, additional_hooks=None): # noqa: D102 try: # --editable causes this to skip creating/editing the # easy-install.pth file - cmd = [ - executable, 'setup.py', + cmd = _PYTHON_CMD + [ + 'setup.py', 'develop', '--editable', '--build-directory', @@ -181,7 +186,7 @@ async def build(self, *, additional_hooks=None): # noqa: D102 async def _get_available_commands(self, path, env): output = await check_output( - [executable, 'setup.py', '--help-commands'], cwd=path, env=env) + _PYTHON_CMD + ['setup.py', '--help-commands'], cwd=path, env=env) commands = set() for line in output.splitlines(): if not line.startswith(b' '): @@ -208,8 +213,8 @@ async def _undo_develop(self, pkg, args, env): args.build_base, '%s.egg-info' % pkg.name.replace('-', '_')) setup_py_build_space = os.path.join(args.build_base, 'setup.py') if os.path.exists(egg_info) and os.path.islink(setup_py_build_space): - cmd = [ - executable, 'setup.py', + cmd = _PYTHON_CMD + [ + 'setup.py', 'develop', '--uninstall', '--editable', '--build-directory', os.path.join(args.build_base, 'build')