Skip to content

Commit 1206f35

Browse files
committed
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
1 parent 0b1802b commit 1206f35

2 files changed

Lines changed: 0 additions & 72 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ cache-keys = [
110110
{ env = "CASS_DRIVER_NO_CYTHON" },
111111
{ env = "CASS_DRIVER_BUILD_CONCURRENCY" },
112112
{ env = "CASS_DRIVER_BUILD_EXTENSIONS_ARE_MUST" },
113-
{ env = "CASS_DRIVER_ALLOWED_CYTHON_VERSION" },
114113

115114
# used by setuptools_scm
116115
{ git = { commit = true, tags = true } },

setup.py

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import os
16-
import shutil
1716
import sys
1817
import json
1918
import warnings
@@ -201,8 +200,6 @@ def eval_env_var_as_array(varname):
201200
try_murmur3 = try_extensions and "--no-murmur3" not in sys.argv
202201
try_libev = try_extensions and "--no-libev" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_LIBEV')
203202
try_cython = try_extensions and "--no-cython" not in sys.argv and not is_pypy and not os.environ.get('CASS_DRIVER_NO_CYTHON')
204-
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
205-
206203
sys.argv = [a for a in sys.argv if a not in ("--no-murmur3", "--no-libev", "--no-cython", "--no-extensions")]
207204

208205
build_concurrency = int(os.environ.get('CASS_DRIVER_BUILD_CONCURRENCY', '0'))
@@ -358,80 +355,12 @@ def fix_extension_class(ext: Extension) -> Extension:
358355
return ext
359356

360357

361-
def pre_build_check():
362-
"""
363-
Try to verify build tools
364-
"""
365-
if os.environ.get('CASS_DRIVER_NO_PRE_BUILD_CHECK'):
366-
return True
367-
368-
try:
369-
from setuptools._distutils.ccompiler import new_compiler
370-
from setuptools._distutils.sysconfig import customize_compiler
371-
from setuptools.dist import Distribution
372-
373-
# base build_ext just to emulate compiler option setup
374-
be = build_ext(Distribution())
375-
be.initialize_options()
376-
be.finalize_options()
377-
378-
# First, make sure we have a Python include directory
379-
have_python_include = any(os.path.isfile(os.path.join(p, 'Python.h')) for p in be.include_dirs)
380-
if not have_python_include:
381-
sys.stderr.write("Did not find 'Python.h' in %s.\n" % (be.include_dirs,))
382-
return False
383-
384-
compiler = new_compiler(compiler=be.compiler)
385-
customize_compiler(compiler)
386-
387-
try:
388-
# We must be able to initialize the compiler if it has that method
389-
if hasattr(compiler, "initialize"):
390-
compiler.initialize()
391-
except:
392-
return False
393-
394-
executables = []
395-
if compiler.compiler_type in ('unix', 'cygwin'):
396-
executables = [compiler.executables[exe][0] for exe in ('compiler_so', 'linker_so')]
397-
elif compiler.compiler_type == 'nt':
398-
executables = [getattr(compiler, exe) for exe in ('cc', 'linker')]
399-
400-
if executables:
401-
for exe in executables:
402-
if not shutil.which(exe):
403-
sys.stderr.write("Failed to find %s for compiler type %s.\n" % (exe, compiler.compiler_type))
404-
return False
405-
406-
except Exception as exc:
407-
sys.stderr.write('%s\n' % str(exc))
408-
sys.stderr.write("Failed pre-build check. Attempting anyway.\n")
409-
410-
# if we are unable to positively id the compiler type, or one of these assumptions fails,
411-
# just proceed as we would have without the check
412-
return True
413-
414-
415358
def run_setup(extensions):
416359

417360
kw = {'cmdclass': {'doc': DocCommand}}
418361
kw['cmdclass']['build_ext'] = build_extensions
419362
kw['ext_modules'] = [Extension('DUMMY', [])] # dummy extension makes sure build_ext is called for install
420363

421-
if try_cython:
422-
# precheck compiler before adding to setup_requires
423-
# we don't actually negate try_cython because:
424-
# 1.) build_ext eats errors at compile time, letting the install complete while producing useful feedback
425-
# 2.) there could be a case where the python environment has cython installed but the system doesn't have build tools
426-
if pre_build_check():
427-
cython_dep = 'Cython>=3.0.11,<4'
428-
user_specified_cython_version = os.environ.get('CASS_DRIVER_ALLOWED_CYTHON_VERSION')
429-
if user_specified_cython_version is not None:
430-
cython_dep = 'Cython==%s' % (user_specified_cython_version,)
431-
kw['setup_requires'] = [cython_dep]
432-
else:
433-
sys.stderr.write("Bypassing Cython setup requirement\n")
434-
435364
setup(**kw)
436365

437366
run_setup(None)

0 commit comments

Comments
 (0)