From fbf87239b1bf937625ca6db450e8dfac410471e4 Mon Sep 17 00:00:00 2001 From: Abderrahim Kitouni Date: Sun, 4 May 2025 16:11:29 +0100 Subject: [PATCH 1/2] Upgrade setuptools version --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index afc4674f8..7c6008b57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,8 +13,8 @@ # [build-system] requires = [ - # We need at least version 36.6.0 that introduced "build_meta" - "setuptools>=36.6.0", + # We need at least version 41.2.0 to support python 3.9 + "setuptools>=41.2.0", # In order to build wheels, and as required by PEP 517 "wheel", # Require a new enough cython for the python versions we support From 3eb32c78906d84f06b93d029f81443920bf775c6 Mon Sep 17 00:00:00 2001 From: Abderrahim Kitouni Date: Sun, 4 May 2025 16:14:44 +0100 Subject: [PATCH 2/2] Stop monkey patching ScriptWriter It's no longer used (for as long back as I could see) and was removed in setuptools 80. --- setup.py | 45 --------------------------------------------- 1 file changed, 45 deletions(-) diff --git a/setup.py b/setup.py index 17707454c..1e5887fec 100755 --- a/setup.py +++ b/setup.py @@ -52,7 +52,6 @@ try: from setuptools import setup, find_packages, Command, Extension - from setuptools.command.easy_install import ScriptWriter except ImportError: print( "BuildStream requires setuptools in order to build. Install it using" @@ -156,50 +155,6 @@ def list_testing_datafiles(): return [str(f) for f in data_dir.rglob("*")] -##################################################### -# Monkey-patching setuptools for performance # -##################################################### -# -# The template of easy_install.ScriptWriter is inefficient in our case as it -# imports pkg_resources. Patching the template only doesn't work because of the -# old string formatting used (%). This forces us to overwrite the class function -# as well. -# -# The patch was inspired from https://github.com/ninjaaron/fast-entry_points -# which we believe was also inspired from the code from `setuptools` project. -# -# This also sets an environment variable to disable gRPC fork support as it -# can cause problems in certain environments and BuildStream doesn't need it. -TEMPLATE = """\ -# -*- coding: utf-8 -*- -import os -import sys - -from {0} import {1} - -if __name__ == '__main__': - os.environ['GRPC_ENABLE_FORK_SUPPORT'] = '0' - sys.exit({2}())""" - - -# Modify the get_args() function of the ScriptWriter class -# Note: the pylint no-member warning has been disabled as the functions: get_header(), -# ensure_safe_name() and _get_script_args() are all members of this class. -# pylint: disable=no-member -@classmethod -def get_args(cls, dist, header=None): - if header is None: - header = cls.get_header() - for name, ep in dist.get_entry_map("console_scripts").items(): - cls._ensure_safe_name(name) - script_text = TEMPLATE.format(ep.module_name, ep.attrs[0], ".".join(ep.attrs)) - args = cls._get_script_args("console", name, header, script_text) - yield from args - - -ScriptWriter.get_args = get_args - - ##################################################### # gRPC command for code generation # #####################################################