Skip to content

Commit d7641dc

Browse files
authored
apacheGH-44614: [Python][C++] Add version suffix to libarrow_python* libraries (apache#44702)
### Rationale for this change We are currently not setting library version suffixes for arrow python C++ libraries but we do so for libarrow C++. ### What changes are included in this PR? Add the same logic that we use for libarrow. ### Are these changes tested? I've validated manually that the suffixes are generated. ``` tree | grep libarrow_python │   │   ├── libarrow_python.so -> libarrow_python.so.1900 │   │   ├── libarrow_python.so.1900 -> libarrow_python.so.1900.0.0 │   │   ├── libarrow_python.so.1900.0.0 │   │   ├── libarrow_python.pxd │   ├── libarrow_python.so -> libarrow_python.so.1900 │   ├── libarrow_python.so.1900 -> libarrow_python.so.1900.0.0 │   ├── libarrow_python.so.1900.0.0 ``` ### Are there any user-facing changes? We will generate so libraries with version suffixes. * GitHub Issue: apache#44614 Authored-by: Raúl Cumplido <[email protected]> Signed-off-by: Jacob Wujciak-Jens <[email protected]>
1 parent aab7d81 commit d7641dc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

python/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON)
3131
set(PYARROW_VERSION "19.0.0-SNAPSHOT")
3232
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" PYARROW_BASE_VERSION "${PYARROW_VERSION}")
3333

34+
# Generate SO version and full SO version
35+
project(pyarrow VERSION "${PYARROW_BASE_VERSION}")
36+
set(PYARROW_VERSION_MAJOR "${pyarrow_VERSION_MAJOR}")
37+
set(PYARROW_VERSION_MINOR "${pyarrow_VERSION_MINOR}")
38+
set(PYARROW_VERSION_PATCH "${pyarrow_VERSION_PATCH}")
39+
# pyarrow 1.x.y => SO version is "10x", full SO version is "10x.y.0"
40+
# Example: for 18.0.0 --> PYARROW_SO_VERSION=1800, PYARROW_FULL_SO_VERSION=1800.0.0
41+
math(EXPR PYARROW_SO_VERSION "${PYARROW_VERSION_MAJOR} * 100 + ${PYARROW_VERSION_MINOR}")
42+
set(PYARROW_FULL_SO_VERSION "${PYARROW_SO_VERSION}.${PYARROW_VERSION_PATCH}.0")
43+
3444
# Running from a Python sdist tarball
3545
set(LOCAL_CMAKE_MODULES "${CMAKE_SOURCE_DIR}/cmake_modules")
3646
if(EXISTS "${LOCAL_CMAKE_MODULES}")
@@ -470,6 +480,8 @@ else()
470480
endif()
471481
target_link_libraries(arrow_python PUBLIC Python3::NumPy)
472482
target_compile_definitions(arrow_python PRIVATE ARROW_PYTHON_EXPORTING)
483+
set_target_properties(arrow_python PROPERTIES VERSION "${PYARROW_FULL_SO_VERSION}"
484+
SOVERSION "${PYARROW_SO_VERSION}")
473485
install(TARGETS arrow_python
474486
ARCHIVE DESTINATION .
475487
LIBRARY DESTINATION .
@@ -485,6 +497,9 @@ else()
485497
${PARQUET_LINK_LIBS})
486498
target_compile_definitions(arrow_python_parquet_encryption
487499
PRIVATE ARROW_PYTHON_PARQUET_ENCRYPTION_EXPORTING)
500+
set_target_properties(arrow_python_parquet_encryption
501+
PROPERTIES VERSION "${PYARROW_FULL_SO_VERSION}"
502+
SOVERSION "${PYARROW_SO_VERSION}")
488503
install(TARGETS arrow_python_parquet_encryption
489504
ARCHIVE DESTINATION .
490505
LIBRARY DESTINATION .
@@ -515,6 +530,9 @@ if(PYARROW_BUILD_FLIGHT)
515530
target_link_libraries(arrow_python_flight PUBLIC arrow_python
516531
ArrowFlight::arrow_flight_shared)
517532
target_compile_definitions(arrow_python_flight PRIVATE ARROW_PYFLIGHT_EXPORTING)
533+
set_target_properties(arrow_python_flight
534+
PROPERTIES VERSION "${PYARROW_FULL_SO_VERSION}"
535+
SOVERSION "${PYARROW_SO_VERSION}")
518536
install(TARGETS arrow_python_flight
519537
ARCHIVE DESTINATION .
520538
LIBRARY DESTINATION .

0 commit comments

Comments
 (0)