Skip to content

Commit

Permalink
Suppress setup.py deprecation warnings during build (#626)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cottsay authored Mar 11, 2024
1 parent c7d8194 commit a6631ed
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions colcon_core/task/python/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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' '):
Expand All @@ -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')
Expand Down

0 comments on commit a6631ed

Please sign in to comment.