From b3ad530badcf538a979f703ff0eb9b0299b9d233 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Sun, 22 Feb 2026 15:35:22 -0400 Subject: [PATCH] Remove deprecated setup_requires in favor of PEP 517 build-system.requires setup.py passed setup_requires=['Cython>=3.0.11,<4'] to setup(), which triggers a deprecation warning on setuptools>=70: setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. Since pyproject.toml already declares Cython in [build-system].requires, the setup_requires is redundant. Remove it along with the supporting pre_build_check() function, the egg_info bypass, and the CASS_DRIVER_ALLOWED_CYTHON_VERSION env var handling. Users who need a specific Cython version can use UV_CONSTRAINT, PIP_CONSTRAINT, or pre-install it before building. Fixes #694 --- pyproject.toml | 1 - setup.py | 71 -------------------------------------------------- 2 files changed, 72 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b19b38934c..7f60ed0b2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,7 +110,6 @@ cache-keys = [ { env = "CASS_DRIVER_NO_CYTHON" }, { env = "CASS_DRIVER_BUILD_CONCURRENCY" }, { env = "CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST" }, - { env = "CASS_DRIVER_ALLOWED_CYTHON_VERSION" }, # used by setuptools_scm { git = { commit = true, tags = true } }, diff --git a/setup.py b/setup.py index 340ded87ed..52e04a63e5 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,6 @@ # limitations under the License. import os -import shutil import sys import json import warnings @@ -201,8 +200,6 @@ def eval_env_var_as_array(varname): try_murmur3 = try_extensions and "--no-murmur3" not in sys.argv try_libev = try_extensions and "--no-libev" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_LIBEV') try_cython = try_extensions and "--no-cython" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_CYTHON') -try_cython &= 'egg_info' not in sys.argv # bypass setup_requires for pip egg_info calls, which will never have --install-option"--no-cython" coming fomr pip - sys.argv = [a for a in sys.argv if a not in ("--no-murmur3", "--no-libev", "--no-cython", "--no-extensions")] build_concurrency = int(os.environ.get('CASS_DRIVER_BUILD_CONCURRENCY', '0')) @@ -358,80 +355,12 @@ def fix_extension_class(ext: Extension) -> Extension: return ext -def pre_build_check(): - """ - Try to verify build tools - """ - if os.environ.get('CASS_DRIVER_NO_PRE_BUILD_CHECK'): - return True - - try: - from setuptools._distutils.ccompiler import new_compiler - from setuptools._distutils.sysconfig import customize_compiler - from setuptools.dist import Distribution - - # base build_ext just to emulate compiler option setup - be = build_ext(Distribution()) - be.initialize_options() - be.finalize_options() - - # First, make sure we have a Python include directory - have_python_include = any(os.path.isfile(os.path.join(p, 'Python.h')) for p in be.include_dirs) - if not have_python_include: - sys.stderr.write("Did not find 'Python.h' in %s.\n" % (be.include_dirs,)) - return False - - compiler = new_compiler(compiler=be.compiler) - customize_compiler(compiler) - - try: - # We must be able to initialize the compiler if it has that method - if hasattr(compiler, "initialize"): - compiler.initialize() - except: - return False - - executables = [] - if compiler.compiler_type in ('unix', 'cygwin'): - executables = [compiler.executables[exe][0] for exe in ('compiler_so', 'linker_so')] - elif compiler.compiler_type == 'nt': - executables = [getattr(compiler, exe) for exe in ('cc', 'linker')] - - if executables: - for exe in executables: - if not shutil.which(exe): - sys.stderr.write("Failed to find %s for compiler type %s.\n" % (exe, compiler.compiler_type)) - return False - - except Exception as exc: - sys.stderr.write('%s\n' % str(exc)) - sys.stderr.write("Failed pre-build check. Attempting anyway.\n") - - # if we are unable to positively id the compiler type, or one of these assumptions fails, - # just proceed as we would have without the check - return True - - def run_setup(extensions): kw = {'cmdclass': {'doc': DocCommand}} kw['cmdclass']['build_ext'] = build_extensions kw['ext_modules'] = [Extension('DUMMY', [])] # dummy extension makes sure build_ext is called for install - if try_cython: - # precheck compiler before adding to setup_requires - # we don't actually negate try_cython because: - # 1.) build_ext eats errors at compile time, letting the install complete while producing useful feedback - # 2.) there could be a case where the python environment has cython installed but the system doesn't have build tools - if pre_build_check(): - cython_dep = 'Cython>=3.0.11,<4' - user_specified_cython_version = os.environ.get('CASS_DRIVER_ALLOWED_CYTHON_VERSION') - if user_specified_cython_version is not None: - cython_dep = 'Cython==%s' % (user_specified_cython_version,) - kw['setup_requires'] = [cython_dep] - else: - sys.stderr.write("Bypassing Cython setup requirement\n") - setup(**kw) run_setup(None)