Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress setup.py deprecation warnings during build #626

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading