You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "rok (via GitHub)" <gi...@apache.org> on 2026/03/04 20:17:47 UTC
[PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
rok opened a new pull request, #49453:
URL: https://github.com/apache/arrow/pull/49453
### Rationale for this change
Warning: should not be merged before https://github.com/apache/arrow/pull/49259.
See https://github.com/apache/arrow/issues/49452 and https://github.com/apache/arrow/pull/48618
### What changes are included in this PR?
Adds a wheel build time script to populate stubfiles with runtime docstrings.
### Are these changes tested?
Not yet.
### Are there any user-facing changes?
Users will get docstrings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2927416533
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
+ so that pyarrow can be imported from the parent directory of pyarrow_pkg.
+ """
+ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
Review Comment:
As per 🤖 :
`sysconfig.get_config_var("EXT_SUFFIX")` returns the platform-specific extension suffix (e.g. `.cpython-313-x86_64-linux-gnu.so` on Linux, `.cpython-313-darwin.so` on macOS, `.pyd` on Windows). We need it to correctly identify compiled extension modules vs other files in the install directory — a plain `".so"` check would miss the full CPython-tagged suffixes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4031186505
Revision: 10509c4165fd7df4bac81b54600078a257c63676
Submitted crossbow builds: [ursacomputing/crossbow @ actions-f3f679ce77](https://github.com/ursacomputing/crossbow/branches/all?query=actions-f3f679ce77)
|Task|Status|
|----|------|
|wheel-macos-monterey-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417740/job/66455537083)|
|wheel-macos-monterey-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417170/job/66455535208)|
|wheel-macos-monterey-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417165/job/66455535101)|
|wheel-macos-monterey-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417018/job/66455534465)|
|wheel-manylinux-2-28-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903416741/job/66455533712)|
|wheel-manylinux-2-28-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417830/job/66455537239)|
|wheel-manylinux-2-28-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417418/job/66455535829)|
|wheel-manylinux-2-28-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417570/job/66455536293)|
|wheel-musllinux-1-2-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903416744/job/66455533696)|
|wheel-musllinux-1-2-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417634/job/66455537255)|
|wheel-musllinux-1-2-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417234/job/66455535213)|
|wheel-musllinux-1-2-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903416754/job/66455533798)|
|wheel-windows-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417132/job/66455534874)|
|wheel-windows-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22903417221/job/66455535259)|
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4030489044
@github-actions crossbow submit wheel*-cp313-*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2925234679
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
Review Comment:
What does `Populate pyarrow_pkg` mean? I am not sure I understand what is `pyarrow_pkg` here. Is it the source tree? Are we copying the Arrow shared objects around to populate the stubs? Otherwise I am unsure what are we copying/linking. Isn't this what `PYARROW_BUNDLE_ARROW_CPP` does? Maybe we have to build after CMake runs the copy for `PYARROW_BUNDLE_ARROW_CPP`?
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
+ so that pyarrow can be imported from the parent directory of pyarrow_pkg.
+ """
+ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
Review Comment:
Is this `EXT_SUFFIX` env var necessary? doesn't seem to be used anywhere apart from this line
##########
python/CMakeLists.txt:
##########
@@ -1025,3 +1025,54 @@ if(PYARROW_BUILD_PARQUET)
target_link_libraries(_parquet_encryption PRIVATE arrow_python_parquet_encryption)
endif()
endif()
+
+#
+# Type stubs with docstring injection
+#
+# Stubs live in pyarrow-stubs/pyarrow/ during development but are installed
+# alongside the package so type checkers can find them (PEP 561).
+set(PYARROW_REQUIRE_STUB_DOCSTRINGS OFF)
+if(DEFINED SKBUILD_STATE
+ AND SKBUILD_STATE STREQUAL "wheel"
+ AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten"
+ AND DEFINED ENV{CI}
Review Comment:
If I understand this correctly this will default to `ON` on wheels and only on CI, otherwise is off and we have to turn it on manually, i.e. testing locally?
Is this logic necessary? Should we just remove all that, add the option and enable it as part of the wheel build scripts by setting an env var? We can add `PYARROW_REQUIRE_STUB_DOCSTRINGS` as a possible option on our pyproject.toml:
`PYARROW_REQUIRE_STUB_DOCSTRINGS = {env = "PYARROW_REQUIRE_STUB_DOCSTRINGS", default = "OFF"}` similar to `PYARROW_BUNDLE_ARROW_CPP`
##########
python/CMakeLists.txt:
##########
@@ -1025,3 +1025,54 @@ if(PYARROW_BUILD_PARQUET)
target_link_libraries(_parquet_encryption PRIVATE arrow_python_parquet_encryption)
endif()
endif()
+
+#
+# Type stubs with docstring injection
+#
+# Stubs live in pyarrow-stubs/pyarrow/ during development but are installed
+# alongside the package so type checkers can find them (PEP 561).
+set(PYARROW_REQUIRE_STUB_DOCSTRINGS OFF)
+if(DEFINED SKBUILD_STATE
+ AND SKBUILD_STATE STREQUAL "wheel"
+ AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten"
+ AND DEFINED ENV{CI}
+ AND NOT "$ENV{CI}" STREQUAL "")
+ set(PYARROW_REQUIRE_STUB_DOCSTRINGS ON)
+endif()
+
+set(PYARROW_STUBS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pyarrow-stubs/pyarrow")
+if(EXISTS "${PYARROW_STUBS_SOURCE_DIR}")
+ install(DIRECTORY "${PYARROW_STUBS_SOURCE_DIR}/"
+ DESTINATION "."
+ FILES_MATCHING
+ PATTERN "*.pyi")
+
+ if(DEFINED SKBUILD_STATE
+ AND SKBUILD_STATE STREQUAL "wheel"
+ AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
Review Comment:
isn't this?
```suggestion
if(PYARROW_REQUIRE_STUB_DOCSTRINGS)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4046614859
@raulcd any we could get this reviewed by end of week?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4031415925
Revision: e4903ebbed2c3f5839d2e901b4ebf1dd2e1d7683
Submitted crossbow builds: [ursacomputing/crossbow @ actions-a33b20ecd0](https://github.com/ursacomputing/crossbow/branches/all?query=actions-a33b20ecd0)
|Task|Status|
|----|------|
|wheel-macos-monterey-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904938553/job/66460916132)|
|wheel-macos-monterey-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904939842/job/66460919871)|
|wheel-macos-monterey-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904939028/job/66460917353)|
|wheel-macos-monterey-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904938557/job/66460916249)|
|wheel-manylinux-2-28-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904939472/job/66460919007)|
|wheel-manylinux-2-28-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904939454/job/66460918814)|
|wheel-manylinux-2-28-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904939350/job/66460918460)|
|wheel-manylinux-2-28-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904939602/job/66460919759)|
|wheel-musllinux-1-2-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904938789/job/66460917122)|
|wheel-musllinux-1-2-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904938782/job/66460916807)|
|wheel-musllinux-1-2-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904938547/job/66460915952)|
|wheel-musllinux-1-2-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904938845/job/66460916838)|
|wheel-windows-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904938564/job/66460916089)|
|wheel-windows-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22904939938/job/66460920394)|
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4049716692
@kou could you do a pass here too? Especially feedback on CMake changes would be valuable :).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2930239569
##########
python/CMakeLists.txt:
##########
@@ -1025,3 +1025,39 @@ if(PYARROW_BUILD_PARQUET)
target_link_libraries(_parquet_encryption PRIVATE arrow_python_parquet_encryption)
endif()
endif()
+
+#
+# Type stubs with docstring injection
+#
+# Stubs live in pyarrow-stubs/pyarrow/ during development but are installed
+# alongside the package so type checkers can find them (PEP 561).
+set(PYARROW_STUBS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pyarrow-stubs/pyarrow")
+if(EXISTS "${PYARROW_STUBS_SOURCE_DIR}")
+ install(DIRECTORY "${PYARROW_STUBS_SOURCE_DIR}/"
+ DESTINATION "."
+ FILES_MATCHING
+ PATTERN "*.pyi")
+
+ if(PYARROW_REQUIRE_STUB_DOCSTRINGS)
+ install(CODE "
+ execute_process(
+ COMMAND \"${Python3_EXECUTABLE}\"
+ \"${CMAKE_CURRENT_SOURCE_DIR}/scripts/update_stub_docstrings.py\"
+ \"${CMAKE_INSTALL_PREFIX}\"
+ \"${CMAKE_CURRENT_SOURCE_DIR}\"
+ RESULT_VARIABLE _pyarrow_stub_docstrings_result
+ )
+ if(NOT _pyarrow_stub_docstrings_result EQUAL 0)
+ message(FATAL_ERROR \"Stub docstring injection failed (exit code: \${_pyarrow_stub_docstrings_result})\")
+ endif()
+ ")
+ endif()
+else()
+ if(PYARROW_REQUIRE_STUB_DOCSTRINGS)
+ message(FATAL_ERROR "PyArrow stub source directory not found at ${PYARROW_STUBS_SOURCE_DIR}; "
+ "cannot build wheel without .pyi files.")
+ else()
+ message(WARNING "PyArrow stub source directory not found at ${PYARROW_STUBS_SOURCE_DIR}; "
+ "wheel will be built without .pyi files.")
Review Comment:
Good point! I removed the else clause now, so we don't get too much noise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4054033148
Thanks for reviews @raulcd @kou! Will merge when CI passes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4056712467
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 0a2a0c75f9e8106d0ad7e53d2e3183a89c043620.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/66992306836) has more details. It also includes information about 37 possible false positives for unstable benchmarks that are known to sometimes produce them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2930091610
##########
python/CMakeLists.txt:
##########
@@ -1025,3 +1025,39 @@ if(PYARROW_BUILD_PARQUET)
target_link_libraries(_parquet_encryption PRIVATE arrow_python_parquet_encryption)
endif()
endif()
+
+#
+# Type stubs with docstring injection
+#
+# Stubs live in pyarrow-stubs/pyarrow/ during development but are installed
+# alongside the package so type checkers can find them (PEP 561).
+set(PYARROW_STUBS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pyarrow-stubs/pyarrow")
+if(EXISTS "${PYARROW_STUBS_SOURCE_DIR}")
+ install(DIRECTORY "${PYARROW_STUBS_SOURCE_DIR}/"
+ DESTINATION "."
+ FILES_MATCHING
+ PATTERN "*.pyi")
+
+ if(PYARROW_REQUIRE_STUB_DOCSTRINGS)
+ install(CODE "
+ execute_process(
+ COMMAND \"${Python3_EXECUTABLE}\"
+ \"${CMAKE_CURRENT_SOURCE_DIR}/scripts/update_stub_docstrings.py\"
+ \"${CMAKE_INSTALL_PREFIX}\"
+ \"${CMAKE_CURRENT_SOURCE_DIR}\"
+ RESULT_VARIABLE _pyarrow_stub_docstrings_result
+ )
+ if(NOT _pyarrow_stub_docstrings_result EQUAL 0)
+ message(FATAL_ERROR \"Stub docstring injection failed (exit code: \${_pyarrow_stub_docstrings_result})\")
+ endif()
+ ")
+ endif()
+else()
+ if(PYARROW_REQUIRE_STUB_DOCSTRINGS)
+ message(FATAL_ERROR "PyArrow stub source directory not found at ${PYARROW_STUBS_SOURCE_DIR}; "
+ "cannot build wheel without .pyi files.")
+ else()
+ message(WARNING "PyArrow stub source directory not found at ${PYARROW_STUBS_SOURCE_DIR}; "
+ "wheel will be built without .pyi files.")
Review Comment:
This will happen for everything not only for wheels, I am wondering whether we want this warning at all we already have the checks for the wheels and we are setting `PYARROW_REQUIRE_STUB_DOCSTRINGS` on those. The validation of the wheel will fail if files are not present and this warning will appear every time we build locally now. Probably we can just remove the `else` case here?
```suggestion
message(WARNING "PyArrow stub source directory not found at ${PYARROW_STUBS_SOURCE_DIR}; "
"PyArrow will be built without .pyi files.")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2927148978
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
+ so that pyarrow can be imported from the parent directory of pyarrow_pkg.
+ """
+ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
Review Comment:
Sorry, I meant whether it can be something different than the default "*.so". I'm not sure is necessary to be able to override as an env variable, what's the use case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok merged PR #49453:
URL: https://github.com/apache/arrow/pull/49453
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4000032109
:warning: GitHub issue #49452 **has been automatically assigned in GitHub** to PR creator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4031418589
@raulcd the docstring presence check was apparently too strict. I think this is ready for review now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4048860217
Thanks for the review @raulcd, I've pushed some changes, can you check if this now makes sense?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2927416533
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
+ so that pyarrow can be imported from the parent directory of pyarrow_pkg.
+ """
+ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
Review Comment:
`sysconfig.get_config_var("EXT_SUFFIX")` returns the platform-specific extension suffix (e.g. `.cpython-313-x86_64-linux-gnu.so` on Linux, `.cpython-313-darwin.so` on macOS, `.pyd` on Windows). We need it to correctly identify compiled extension modules vs other files in the install directory — a plain `".so"` check would miss the full CPython-tagged suffixes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2927547770
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
+ so that pyarrow can be imported from the parent directory of pyarrow_pkg.
+ """
+ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
Review Comment:
I'll just try copying everything but `.pyi` files as this really is unnecessarily complicaated. Sorry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4030504634
Revision: f885111a427b36c803b25f37316ec912e864e893
Submitted crossbow builds: [ursacomputing/crossbow @ actions-c1678cd8dd](https://github.com/ursacomputing/crossbow/branches/all?query=actions-c1678cd8dd)
|Task|Status|
|----|------|
|wheel-macos-monterey-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983431/job/66440369546)|
|wheel-macos-monterey-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983248/job/66440368946)|
|wheel-macos-monterey-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983107/job/66440368593)|
|wheel-macos-monterey-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983214/job/66440368942)|
|wheel-manylinux-2-28-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898982784/job/66440367595)|
|wheel-manylinux-2-28-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898982984/job/66440368070)|
|wheel-manylinux-2-28-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898982951/job/66440367882)|
|wheel-manylinux-2-28-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983699/job/66440370361)|
|wheel-musllinux-1-2-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898982796/job/66440367564)|
|wheel-musllinux-1-2-cp313-cp313-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983245/job/66440369129)|
|wheel-musllinux-1-2-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983518/job/66440369952)|
|wheel-musllinux-1-2-cp313-cp313t-arm64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898982882/job/66440367607)|
|wheel-windows-cp313-cp313-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983270/job/66440369108)|
|wheel-windows-cp313-cp313t-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/22898983444/job/66440369477)|
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4031158630
@github-actions crossbow submit wheel*-cp313-*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4026220307
@raulcd this is ready for review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #49453:
URL: https://github.com/apache/arrow/pull/49453#discussion_r2926332184
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
+ so that pyarrow can be imported from the parent directory of pyarrow_pkg.
+ """
+ ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
Review Comment:
It is used below as:
```python
is_extension = ext_suffix in artifact.name or artifact.suffix == ".pyd"
```
##########
python/CMakeLists.txt:
##########
@@ -1025,3 +1025,54 @@ if(PYARROW_BUILD_PARQUET)
target_link_libraries(_parquet_encryption PRIVATE arrow_python_parquet_encryption)
endif()
endif()
+
+#
+# Type stubs with docstring injection
+#
+# Stubs live in pyarrow-stubs/pyarrow/ during development but are installed
+# alongside the package so type checkers can find them (PEP 561).
+set(PYARROW_REQUIRE_STUB_DOCSTRINGS OFF)
+if(DEFINED SKBUILD_STATE
+ AND SKBUILD_STATE STREQUAL "wheel"
+ AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten"
+ AND DEFINED ENV{CI}
Review Comment:
Ok, let me try that. Do we want to enable `PYARROW_REQUIRE_STUB_DOCSTRINGS` at dev time?
##########
python/scripts/update_stub_docstrings.py:
##########
@@ -198,31 +203,77 @@ def add_docstrings_to_stubs(stubs_dir):
stub_file.write_text(modified.code)
-def add_docstrings_from_build(stubs_dir, build_lib):
- """
- Entry point for setup.py: update docstrings using pyarrow from build directory.
+def _link_or_copy(source, destination):
+ if sys.platform != "win32":
+ try:
+ os.symlink(source, destination)
+ return
+ except OSError:
+ pass
+
+ if source.is_dir():
+ shutil.copytree(source, destination, symlinks=(sys.platform != "win32"))
+ else:
+ shutil.copy2(source, destination)
+
- During the build process, pyarrow is not installed in the system Python.
- We need to temporarily add the build directory to sys.path so we can
- import pyarrow and extract docstrings from it.
+def _create_importable_pyarrow(pyarrow_pkg, source_dir, install_pyarrow_dir):
"""
- stubs_dir, build_lib = Path(stubs_dir), Path(build_lib)
+ Populate pyarrow_pkg with source Python modules and installed binary artifacts
Review Comment:
The idea is that `pyarrow_pkg` is a folder where we can import pyarrow from, so we can grab runtime docstrings from it. Updating comment to make it clearer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-49452: [Python] Reintroduce docstring injection for stubfiles [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #49453:
URL: https://github.com/apache/arrow/pull/49453#issuecomment-4031400054
@github-actions crossbow submit wheel*-cp313-*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org