Skip to content

Commit

Permalink
GH-44614: [Python][C++] Add version suffix to libarrow_python* librar…
Browse files Browse the repository at this point in the history
…ies (#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: #44614

Authored-by: Raúl Cumplido <[email protected]>
Signed-off-by: Jacob Wujciak-Jens <[email protected]>
  • Loading branch information
raulcd authored Nov 13, 2024
1 parent aab7d81 commit d7641dc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON)
set(PYARROW_VERSION "19.0.0-SNAPSHOT")
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" PYARROW_BASE_VERSION "${PYARROW_VERSION}")

# Generate SO version and full SO version
project(pyarrow VERSION "${PYARROW_BASE_VERSION}")
set(PYARROW_VERSION_MAJOR "${pyarrow_VERSION_MAJOR}")
set(PYARROW_VERSION_MINOR "${pyarrow_VERSION_MINOR}")
set(PYARROW_VERSION_PATCH "${pyarrow_VERSION_PATCH}")
# pyarrow 1.x.y => SO version is "10x", full SO version is "10x.y.0"
# Example: for 18.0.0 --> PYARROW_SO_VERSION=1800, PYARROW_FULL_SO_VERSION=1800.0.0
math(EXPR PYARROW_SO_VERSION "${PYARROW_VERSION_MAJOR} * 100 + ${PYARROW_VERSION_MINOR}")
set(PYARROW_FULL_SO_VERSION "${PYARROW_SO_VERSION}.${PYARROW_VERSION_PATCH}.0")

# Running from a Python sdist tarball
set(LOCAL_CMAKE_MODULES "${CMAKE_SOURCE_DIR}/cmake_modules")
if(EXISTS "${LOCAL_CMAKE_MODULES}")
Expand Down Expand Up @@ -470,6 +480,8 @@ else()
endif()
target_link_libraries(arrow_python PUBLIC Python3::NumPy)
target_compile_definitions(arrow_python PRIVATE ARROW_PYTHON_EXPORTING)
set_target_properties(arrow_python PROPERTIES VERSION "${PYARROW_FULL_SO_VERSION}"
SOVERSION "${PYARROW_SO_VERSION}")
install(TARGETS arrow_python
ARCHIVE DESTINATION .
LIBRARY DESTINATION .
Expand All @@ -485,6 +497,9 @@ else()
${PARQUET_LINK_LIBS})
target_compile_definitions(arrow_python_parquet_encryption
PRIVATE ARROW_PYTHON_PARQUET_ENCRYPTION_EXPORTING)
set_target_properties(arrow_python_parquet_encryption
PROPERTIES VERSION "${PYARROW_FULL_SO_VERSION}"
SOVERSION "${PYARROW_SO_VERSION}")
install(TARGETS arrow_python_parquet_encryption
ARCHIVE DESTINATION .
LIBRARY DESTINATION .
Expand Down Expand Up @@ -515,6 +530,9 @@ if(PYARROW_BUILD_FLIGHT)
target_link_libraries(arrow_python_flight PUBLIC arrow_python
ArrowFlight::arrow_flight_shared)
target_compile_definitions(arrow_python_flight PRIVATE ARROW_PYFLIGHT_EXPORTING)
set_target_properties(arrow_python_flight
PROPERTIES VERSION "${PYARROW_FULL_SO_VERSION}"
SOVERSION "${PYARROW_SO_VERSION}")
install(TARGETS arrow_python_flight
ARCHIVE DESTINATION .
LIBRARY DESTINATION .
Expand Down

0 comments on commit d7641dc

Please sign in to comment.