From a44c4926f22e8ccab8c015d81f3cbfea08566d03 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 31 Oct 2025 11:14:59 +0000 Subject: [PATCH] Don't wrap develop on newer setuptools This distutils command is going away in a future setuptools version, and in recent versions it is effectively a wrapper around pip calls [1]. We should not use it. [1] https://github.com/pypa/setuptools/blob/v80.9.0/setuptools/command/develop.py#L30-L39 Change-Id: I20b394a4db66f4576386097f6d333406a1f1ab5e Signed-off-by: Stephen Finucane Closes-bug: #2107732 --- pbr/_compat/command_hooks.py | 6 +++++- pbr/_compat/commands.py | 27 ++++++++++++++++----------- pbr/_compat/versions.py | 19 +++++++++++++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 pbr/_compat/versions.py diff --git a/pbr/_compat/command_hooks.py b/pbr/_compat/command_hooks.py index 0f5025c1..0a8ec05b 100644 --- a/pbr/_compat/command_hooks.py +++ b/pbr/_compat/command_hooks.py @@ -16,6 +16,7 @@ from __future__ import absolute_import from __future__ import print_function +import pbr._compat.versions from pbr.hooks import base from pbr import options @@ -39,9 +40,12 @@ class CommandsConfig(base.BaseConfig): self.add_command('pbr._compat.commands.LocalEggInfo') self.add_command('pbr._compat.commands.LocalSDist') self.add_command('pbr._compat.commands.LocalInstallScripts') - self.add_command('pbr._compat.commands.LocalDevelop') self.add_command('pbr._compat.commands.LocalRPMVersion') self.add_command('pbr._compat.commands.LocalDebVersion') + + if pbr._compat.versions.setuptools_has_develop_command: + self.add_command('pbr._compat.commands.LocalDevelop') + use_egg = options.get_boolean_option( self.pbr_config, 'use-egg', 'PBR_USE_EGG' ) diff --git a/pbr/_compat/commands.py b/pbr/_compat/commands.py index 7a085a6f..9753bebb 100644 --- a/pbr/_compat/commands.py +++ b/pbr/_compat/commands.py @@ -22,7 +22,6 @@ import os import sys import setuptools -from setuptools.command import develop from setuptools.command import egg_info from setuptools.command import install from setuptools.command import install_scripts @@ -30,24 +29,30 @@ from setuptools.command import sdist import pbr._compat.easy_install import pbr._compat.metadata +import pbr._compat.versions from pbr import extra_files from pbr import git from pbr import options from pbr import version -class LocalDevelop(develop.develop): +if pbr._compat.versions.setuptools_has_develop_command: + from setuptools.command import develop - command_name = 'develop' + class LocalDevelop(develop.develop): - def install_wrapper_scripts(self, dist): - if sys.platform == 'win32': - return develop.develop.install_wrapper_scripts(self, dist) - if not self.exclude_scripts: - for args in pbr._compat.easy_install.ScriptWriter.get_script_args( - dist - ): - self.write_script(*args) + command_name = 'develop' + + def install_wrapper_scripts(self, dist): + if sys.platform == 'win32': + return develop.develop.install_wrapper_scripts(self, dist) + if not self.exclude_scripts: + for ( + args + ) in pbr._compat.easy_install.ScriptWriter.get_script_args( + dist + ): + self.write_script(*args) class LocalInstallScripts(install_scripts.install_scripts): diff --git a/pbr/_compat/versions.py b/pbr/_compat/versions.py new file mode 100644 index 00000000..781b2934 --- /dev/null +++ b/pbr/_compat/versions.py @@ -0,0 +1,19 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from pbr import version + +setuptools_version = version.VersionInfo('setuptools').semantic_version() + +setuptools_has_develop_command = setuptools_version < version.SemanticVersion( + 80, 0, 0 +)