Skip to content

build: replace distutils imports with setuptools in setup.py - #321

Open
n24q02m wants to merge 1 commit into
apache:mainfrom
n24q02m:build/replace-distutils-with-setuptools
Open

n24q02m wants to merge 1 commit into
apache:mainfrom
n24q02m:build/replace-distutils-with-setuptools

Conversation

@n24q02m

@n24q02m n24q02m commented Dec 1, 2026

Copy link
Copy Markdown

Problem

setup.py still imports Extension and build_ext from the deprecated distutils package (removed from the Python standard library in Python 3.12 via PEP 632):

  • from distutils.core import Extension
  • from distutils.command import build_ext

On Python 3.12–3.15, these imports only resolve today because from setuptools import setup activates setuptools' internal _distutils_hack shim. Importing directly from setuptools removes the unnecessary dependency on distutils compatibility shims.

Changes

  • setup.py:
    • Replaced from distutils.core import Extension and from distutils.command import build_ext with from setuptools import Extension, setup and from setuptools.command import build_ext.
    • Audited build-support/, pkg/, and .github/workflows/ and confirmed no other files reference distutils, and all wheel build paths already install/use setuptools.

Verification

  • Verified rg --hidden -n "distutils" . finds zero remaining distutils references in tracked source/build/workflow files.
  • Verified python3 -m py_compile setup.py succeeds on Python 3.12.16.
  • Verified setup.py --name --version outputs pulsar-client / 3.13.0a1 with setuptools 82.0.1.
  • Verified issubclass(my_build_ext, setuptools.command.build_ext.build_ext) is True.
  • Verified isolated setup.py build_ext and setup.py bdist_wheel runs copy _pulsar.so via my_build_ext.build_extension and produce a valid .whl containing _pulsar.cpython-312-x86_64-linux-gnu.so and all pulsar packages.
  • Verified git diff --check is clean.

Signed-off-by: Nguyen Quang Minh <135627235+n24q02m@users.noreply.github.com>
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.

1 participant