Skip to content

Comments

GH-49273: [Python] Move stub docstring script to _build_utils with gr…#49354

Closed
vanshaj2023 wants to merge 1 commit intoapache:mainfrom
vanshaj2023:fix-stub-docstrings-build-utils
Closed

GH-49273: [Python] Move stub docstring script to _build_utils with gr…#49354
vanshaj2023 wants to merge 1 commit intoapache:mainfrom
vanshaj2023:fix-stub-docstrings-build-utils

Conversation

@vanshaj2023
Copy link

@vanshaj2023 vanshaj2023 commented Feb 21, 2026

Rationale for this change

Follow-up to #49235 and #49273. The update_stub_docstrings.py script was added to MANIFEST.in to fix nightly sdist builds, but it used a fragile importlib.util.spec_from_file_location pattern and forced libcst as a hard build dependency. This gives the script a proper home and makes builds more robust for users on exotic platforms who may not have libcst.

What changes are included in this PR?

  • Move scripts/update_stub_docstrings.py to pyarrow/_build_utils/update_stub_docstrings.py
  • _build_utils is auto-included in sdist via existing graft pyarrow, excluded from wheels via setuptools.packages.find.exclude
  • Replace importlib.util.spec_from_file_location in setup.py with a normal import wrapped in try/except ImportError
  • Make libcst a soft build dependency in pyproject.toml (CI still installs it via requirements-build.txt)
  • Add PYARROW_SKIP_STUB_DOCSTRINGS env var for explicit opt-out
  • Keep scripts/update_stub_docstrings.py as a thin CLI wrapper

Are these changes tested?

No new tests. Verified that all modified files pass flake8, graceful degradation catches ImportError cleanly, and CI requirements files still include libcst so official wheels get docstrings.

Are there any user-facing changes?

No. Users building from sdist without libcst will now get stubs without docstrings instead of a build failure.

…ith graceful degradation

Move update_stub_docstrings.py from scripts/ to pyarrow/_build_utils/
so it is automatically included in sdist via the existing "graft pyarrow"
directive and excluded from wheels via setuptools packages.find.exclude.

The setup.py build_ext now uses a normal import instead of the fragile
importlib.util.spec_from_file_location hack, wrapped in try/except so
builds degrade gracefully when libcst is not installed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant