Skip to content

Remove deprecated setup_requires in favor of PEP 517#711

Merged
dkropachev merged 1 commit intomasterfrom
fix/remove-setup-requires-deprecation
Feb 23, 2026
Merged

Remove deprecated setup_requires in favor of PEP 517#711
dkropachev merged 1 commit intomasterfrom
fix/remove-setup-requires-deprecation

Conversation

@dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Feb 22, 2026

Summary

Removes the deprecated setup_requires mechanism from setup.py in favor of the PEP 517 build system already configured in pyproject.toml.

Background

PEP 517 standardized how Python packages declare build dependencies via pyproject.toml's [build-system].requires. Before PEP 517, setup_requires in setup() was the way to pull in build-time dependencies like Cython. setuptools implemented this through fetch_build_eggs, which downloaded eggs at build time — bypassing pip's dependency resolver and causing various issues.

Starting with setuptools 70, using setup_requires emits a deprecation warning:

setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer.

Our pyproject.toml already declares Cython as a PEP 517 build dependency:

[build-system]
requires = ["setuptools>=70", "Cython"]

This means any PEP 517 compliant installer (pip, uv, build) will install Cython before setup.py runs, making setup_requires redundant.

Changes

  • Remove setup_requires=['Cython>=3.0.11,<4'] from the setup() call in run_setup() — redundant with [build-system].requires and the source of the deprecation warning
  • Remove pre_build_check() function — only existed to gate setup_requires; compiler availability is still handled gracefully by build_extensions.build_extension() which catches and reports compilation failures
  • Remove egg_info bypass (try_cython &= 'egg_info' not in sys.argv) — existed to prevent setup_requires from triggering during pip's metadata phase, no longer relevant
  • Remove CASS_DRIVER_ALLOWED_CYTHON_VERSION env var — only affected the setup_requires Cython version pin; users who need a specific Cython version can use UV_CONSTRAINT, PIP_CONSTRAINT, or pre-install it before building

What stays the same

  • The build_extensions class and _setup_extensions() — these dynamically discover and compile Cython extensions at build time, which works fine under PEP 517
  • The try_cython flag and CASS_DRIVER_NO_CYTHON env var — still controls whether Cython modules are built
  • The dummy extension trick (ext_modules=[Extension('DUMMY', [])]) — still needed so setuptools invokes build_ext

Fixes #694

Test plan

  • uv sync completes without PEP 517 deprecation warning
  • python setup.py build_ext --inplace completes without deprecation warning
  • Unit tests pass (590 passed, pre-existing failures unrelated)

…uires

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
@dkropachev dkropachev marked this pull request as ready for review February 22, 2026 20:38
@dkropachev dkropachev self-assigned this Feb 22, 2026
Copy link

@Lorak-mmk Lorak-mmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@dkropachev dkropachev merged commit 1206f35 into master Feb 23, 2026
26 checks passed
@dkropachev dkropachev deleted the fix/remove-setup-requires-deprecation branch February 23, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PEP517 warning when compiling Cython

2 participants