From 971e17893475cec940c826eb94765f880768c257 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Tue, 11 Nov 2025 06:04:09 -0800 Subject: [PATCH] remove .egg-info and setup.cfg from sdist --- dev/.rat-excludes | 2 -- setup.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dev/.rat-excludes b/dev/.rat-excludes index 27c1dc31fc..16e996dba8 100644 --- a/dev/.rat-excludes +++ b/dev/.rat-excludes @@ -5,5 +5,3 @@ build .gitignore uv.lock mkdocs/* -setup.cfg -(^|.*/)[^/]*\.egg-info(/.*)?$ diff --git a/setup.py b/setup.py index 6f05a300fd..34eee94bbd 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,23 @@ import os from setuptools import Extension, find_packages, setup +from setuptools.command.sdist import sdist as _sdist + + +class sdist(_sdist): + """Custom sdist that excludes .egg-info and setup.cfg.""" + + def make_release_tree(self, base_dir: str, files: list[str]) -> None: + # Filter egg-info from the file manifest + files = [f for f in files if ".egg-info" not in f] + + super().make_release_tree(base_dir, files) + + # Remove setup.cfg after setuptools creates it + setup_cfg = os.path.join(base_dir, "setup.cfg") + if os.path.exists(setup_cfg): + os.remove(setup_cfg) + allowed_to_fail = os.environ.get("CIBUILDWHEEL", "0") != "1" @@ -69,4 +86,5 @@ }, include_package_data=True, ext_modules=ext_modules, + cmdclass={"sdist": sdist}, )