Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xtexx/8a6bc8fbe96a10f6d88143dafbbcaa99 to your computer and use it in GitHub Desktop.
Save xtexx/8a6bc8fbe96a10f6d88143dafbbcaa99 to your computer and use it in GitHub Desktop.
Tentative fix for pbr + setuptools 80.3.0
From 4dcf7ef954eddc0584a8abe8b71f6b432bb74583 Mon Sep 17 00:00:00 2001
From: xtex <[email protected]>
Date: Sun, 4 May 2025 17:23:33 +0800
Subject: [PATCH] AOSCOS: Replace setuptools.easy_install usages
X-Developer-Signature: v=1; a=openpgp-sha256; l=4166; [email protected];
h=from:subject; bh=jCM4ZlNLWIP77wQ7vAuZFBeEj0UvNqtzSIJ9PSgRBJ0=;
b=owGbwMvMwCW2U4Ij7wZL9ETG02pJDBnixjoTzvxdGxl38pUVR9NmGctdxlG6oev2ylwL4mH/t
8Iy7Ut7RykLgxgXg6yYIkuRYYM3q046v+iyclmYOaxMIEMYuDgFYCKXOhj+mU4UmaGT77zYxrbQ
1WR3rUNxSfxFnwXZF7xEhXRvq5XPYWS47Hx2s/Tua3O+RM9rO/nr1H2BNZM/CmQ+i5qlYbr8kGc
mAwA=
X-Developer-Key: [email protected]; a=openpgp;
fpr=7231804B052C670F15A6771DB918086ED8045B91
Link: https://github.com/pypa/setuptools/pull/4963
Link: https://github.com/pypa/setuptools/issues/4976
Signed-off-by: xtex <[email protected]>
---
pbr/hooks/commands.py | 4 ----
pbr/packaging.py | 25 ++++++++-----------------
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/pbr/hooks/commands.py b/pbr/hooks/commands.py
index 913193029d6b..19c7a929f2a2 100644
--- a/pbr/hooks/commands.py
+++ b/pbr/hooks/commands.py
@@ -15,8 +15,6 @@
import os
-from setuptools.command import easy_install
-
from pbr.hooks import base
from pbr import options
from pbr import packaging
@@ -44,8 +42,6 @@ class CommandsConfig(base.BaseConfig):
self.add_command('pbr.packaging.LocalDevelop')
self.add_command('pbr.packaging.LocalRPMVersion')
self.add_command('pbr.packaging.LocalDebVersion')
- if os.name != 'nt':
- easy_install.get_script_args = packaging.override_get_script_args
if os.path.exists('.testr.conf') and packaging.have_testr():
# There is a .testr.conf file. We want to use it.
diff --git a/pbr/packaging.py b/pbr/packaging.py
index b816b94bb3e7..3f9bfdafd0b5 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -41,8 +41,8 @@ import warnings
import pkg_resources
import setuptools
+from setuptools import _scripts
from setuptools.command import develop
-from setuptools.command import easy_install
from setuptools.command import egg_info
from setuptools.command import install
from setuptools.command import install_scripts
@@ -433,11 +433,7 @@ def generate_script(group, entry_point, header, template):
def override_get_script_args(
dist, executable=os.path.normpath(sys.executable)):
"""Override entrypoints console_script."""
- # get_script_header() is deprecated since Setuptools 12.0
- try:
- header = easy_install.ScriptWriter.get_header("", executable)
- except AttributeError:
- header = easy_install.get_script_header("", executable)
+ header = _scripts.ScriptWriter.get_header("", executable)
for group, template in ENTRY_POINTS_MAP.items():
for name, ep in dist.get_entry_map(group).items():
yield (name, generate_script(group, ep, header, template))
@@ -460,11 +456,7 @@ class LocalInstallScripts(install_scripts.install_scripts):
command_name = 'install_scripts'
def _make_wsgi_scripts_only(self, dist, executable):
- # get_script_header() is deprecated since Setuptools 12.0
- try:
- header = easy_install.ScriptWriter.get_header("", executable)
- except AttributeError:
- header = easy_install.get_script_header("", executable)
+ header = _scripts.ScriptWriter.get_header("", executable)
wsgi_script_template = ENTRY_POINTS_MAP['wsgi_scripts']
for name, ep in dist.get_entry_map('wsgi_scripts').items():
content = generate_script(
@@ -489,7 +481,10 @@ class LocalInstallScripts(install_scripts.install_scripts):
)
bs_cmd = self.get_finalized_command('build_scripts')
executable = getattr(
- bs_cmd, 'executable', easy_install.sys_executable)
+ bs_cmd,
+ "executable",
+ os.environ.get("__PYVENV_LAUNCHER__", os.path.normpath(sys.executable)),
+ )
if 'bdist_wheel' in self.distribution.have_run:
# We're building a wheel which has no way of generating mod_wsgi
# scripts for us. Let's build them.
@@ -503,11 +498,7 @@ class LocalInstallScripts(install_scripts.install_scripts):
# entry-points listed for this package.
return
- if os.name != 'nt':
- get_script_args = override_get_script_args
- else:
- get_script_args = easy_install.get_script_args
- executable = '"%s"' % executable
+ get_script_args = override_get_script_args
for args in get_script_args(dist, executable):
self.write_script(*args)
base-commit: 5d4a1815afa920cf20e889be20617105446f7ce2
--
2.49.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment