Skip to content

Commit 265d38c

Browse files
authored
fix: packging issues for v0.3.5 (#66)
* fix: align cmake flags (#63) * fix: resolve error in release pypi pkg (#64) * fix: align cmake flags * require macos15 * fix: pypi packaging issues (#65) * fix: align cmake flags * require macos15 * fix xgb version for compatibaility
1 parent 5b191dd commit 265d38c

7 files changed

Lines changed: 76 additions & 28 deletions

File tree

‎.github/workflows/pypi-release.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
matrix:
19-
os: [ubuntu-latest, macos-latest]
19+
os: [ubuntu-latest, macos-15]
2020

2121
steps:
2222
- uses: actions/checkout@v4

‎CMakeLists.txt‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,23 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2929
set(BASE_C_FLAGS "-fPIC -fno-strict-overflow -fno-strict-aliasing")
3030
set(BASE_CXX_FLAGS "-fPIC -fno-strict-overflow -fno-strict-aliasing")
3131

32-
# Compiler-specific flags
32+
# Compiler-specific flags.
3333
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
34-
set(COMPILER_SPECIFIC_FLAGS "-Wno-cast-user-defined -Wno-array-bounds -Wno-type-limits")
35-
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
36-
set(COMPILER_SPECIFIC_FLAGS "-Wno-array-bounds")
34+
set(COMPILER_SPECIFIC_C_FLAGS "-Wno-array-bounds -Wno-type-limits")
35+
set(COMPILER_SPECIFIC_CXX_FLAGS "-Wno-cast-user-defined ${COMPILER_SPECIFIC_C_FLAGS}")
36+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
37+
# GLCache/segment.c stores INT64_MAX into a double field; AppleClang 21 flags the
38+
# value change as -Wimplicit-const-int-float-conversion and -Werror makes it fatal.
39+
set(COMPILER_SPECIFIC_C_FLAGS "-Wno-array-bounds -Wno-implicit-const-int-float-conversion")
40+
set(COMPILER_SPECIFIC_CXX_FLAGS "${COMPILER_SPECIFIC_C_FLAGS}")
3741
else()
38-
set(COMPILER_SPECIFIC_FLAGS "")
42+
set(COMPILER_SPECIFIC_C_FLAGS "")
43+
set(COMPILER_SPECIFIC_CXX_FLAGS "")
3944
endif()
4045

4146
# Apply flags
42-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BASE_C_FLAGS}")
43-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}")
47+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BASE_C_FLAGS} ${COMPILER_SPECIFIC_C_FLAGS}")
48+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}")
4449

4550
# =============================================================================
4651
# Git Submodule Management
@@ -80,13 +85,16 @@ endif()
8085
function(build_libcachesim)
8186
message(STATUS "Building libCacheSim...")
8287

83-
# Prepare CMake arguments for subproject
88+
# Prepare CMake arguments for subproject.
89+
# The C flags carry the compiler-specific suppressions too: libCacheSim is mostly
90+
# C, and passing them only to the C++ compiler left its C sources exposed to
91+
# upstream's -Werror.
8492
set(CMAKE_ARGS
85-
"-DCMAKE_C_FLAGS=${BASE_C_FLAGS}"
86-
"-DCMAKE_CXX_FLAGS=${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
87-
"-DCMAKE_CXX_FLAGS_DEBUG=-g ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
88-
"-DCMAKE_CXX_FLAGS_RELEASE=-O3 ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
89-
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_FLAGS}"
93+
"-DCMAKE_C_FLAGS=${BASE_C_FLAGS} ${COMPILER_SPECIFIC_C_FLAGS}"
94+
"-DCMAKE_CXX_FLAGS=${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
95+
"-DCMAKE_CXX_FLAGS_DEBUG=-g ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
96+
"-DCMAKE_CXX_FLAGS_RELEASE=-O3 ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
97+
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG ${BASE_CXX_FLAGS} ${COMPILER_SPECIFIC_CXX_FLAGS}"
9098
)
9199

92100
# Configure libCacheSim

‎docs/src/en/getting_started/installation.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
Windows is not supported.
1212

13+
!!! note "macOS wheels"
14+
The published macOS wheels are Apple Silicon (arm64) only and require **macOS 15 or
15+
newer**. They bundle Homebrew libraries, which are built for the macOS version of the
16+
release runner and set that floor. On an Intel Mac or an older macOS, `pip` falls back
17+
to [building from source](#install-from-source).
18+
1319
## Install from PyPI
1420

1521
Pre-built wheels are published to [PyPI](https://pypi.org/project/libcachesim/), so in most

‎docs/src/zh/getting_started/installation.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
不支持 Windows。
1212

13+
!!! note "关于 macOS wheel"
14+
发布的 macOS wheel 仅面向 Apple Silicon(arm64),且要求 **macOS 15 及以上**。这些 wheel
15+
捆绑了 Homebrew 的动态库,而 Homebrew 只为发布机所用的 macOS 版本构建这些库,因此下限由此
16+
决定。在 Intel Mac 或更旧的 macOS 上,`pip` 会回退到“从源码安装”。
17+
1318
## 从 PyPI 安装
1419

1520
我们已将预编译的 wheel 发布到 [PyPI](https://pypi.org/project/libcachesim/),因此大多数情况下无需编译器:

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ build-dir = "build"
6565
[tool.scikit-build.cmake]
6666
build-type = "Release"
6767
args = ["-G", "Ninja"]
68-
define = { CMAKE_OSX_DEPLOYMENT_TARGET = "11.0" }
68+
define = { CMAKE_OSX_DEPLOYMENT_TARGET = "15.0" }
6969
version = ">=3.15"
7070
source-dir = "."
7171

@@ -83,7 +83,7 @@ skip = ["*-win32", "*-manylinux_i686", "*-musllinux*", "pp*"]
8383
# Set the environment variable for the wheel build step.
8484
# NOTE(haocheng): we enable all the optional features for the wheel build.
8585
# And MACOSX_DEPLOYMENT_TARGET should be kept in sync with [tool.scikit-build.cmake].define.CMAKE_OSX_DEPLOYMENT_TARGET
86-
environment = { LCS_BUILD_DIR = "{project}/src/libCacheSim/build", MACOSX_DEPLOYMENT_TARGET = "11.0", CMAKE_ARGS = "-DENABLE_3L_CACHE=ON -DENABLE_GLCACHE=ON -DENABLE_LRB=ON" }
86+
environment = { LCS_BUILD_DIR = "{project}/src/libCacheSim/build", MACOSX_DEPLOYMENT_TARGET = "15.0", CMAKE_ARGS = "-DENABLE_3L_CACHE=ON -DENABLE_GLCACHE=ON -DENABLE_LRB=ON" }
8787

8888
# Test that the wheel can be imported
8989
test-command = "python -c 'import libcachesim; print(\"Import successful\")'; cp -r {project}/tests .; python -m pytest tests/ -v -m 'not optional'; python -m pytest tests/ -v -m 'optional'"

‎scripts/install_deps.sh‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,21 @@ install_zstd() {
121121
# Install XGBoost from source
122122
install_xgboost() {
123123
log_info "Installing XGBoost from source..."
124+
# Pinned, not tracking master: XGBoost removed the deprecated XGBoosterPredict
125+
# after v3.3.0, and libCacheSim's GLCache/inference.c still calls it, so a clone
126+
# of master fails to compile with "implicit declaration of function". v3.3.0 is
127+
# also what Homebrew installs, so the Linux and macOS wheels build against the
128+
# same API. The directory carries the version so a checkout left in /tmp by an
129+
# older run of this script is not silently reused.
130+
local xgboost_version="v3.3.0"
131+
local xgboost_dir="xgboost-${xgboost_version}"
132+
124133
pushd /tmp/ >/dev/null
125-
if [[ ! -d "xgboost" ]]; then
126-
git clone --recursive https://github.com/dmlc/xgboost
134+
if [[ ! -d "${xgboost_dir}" ]]; then
135+
git clone --recursive --depth 1 --branch "${xgboost_version}" \
136+
https://github.com/dmlc/xgboost "${xgboost_dir}"
127137
fi
128-
pushd xgboost >/dev/null
138+
pushd "${xgboost_dir}" >/dev/null
129139
mkdir -p build
130140
pushd build >/dev/null
131141
cmake -G Ninja ..
@@ -139,11 +149,18 @@ install_xgboost() {
139149
# Install LightGBM from source
140150
install_lightgbm() {
141151
log_info "Installing LightGBM from source..."
152+
# Pinned for the same reason as XGBoost above -- an unpinned clone means the
153+
# build depends on whatever master happens to be that day. v4.7.0 matches the
154+
# version Homebrew installs for the macOS wheels.
155+
local lightgbm_version="v4.7.0"
156+
local lightgbm_dir="LightGBM-${lightgbm_version}"
157+
142158
pushd /tmp/ >/dev/null
143-
if [[ ! -d "LightGBM" ]]; then
144-
git clone --recursive https://github.com/microsoft/LightGBM
159+
if [[ ! -d "${lightgbm_dir}" ]]; then
160+
git clone --recursive --depth 1 --branch "${lightgbm_version}" \
161+
https://github.com/microsoft/LightGBM "${lightgbm_dir}"
145162
fi
146-
pushd LightGBM >/dev/null
163+
pushd "${lightgbm_dir}" >/dev/null
147164
mkdir -p build
148165
pushd build >/dev/null
149166
cmake -G Ninja ..

‎scripts/install_deps_user.sh‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,22 @@ EOF
236236
install_xgboost() {
237237
log_step "Installing XGBoost..."
238238

239+
# Pinned rather than tracking master: XGBoost removed the deprecated
240+
# XGBoosterPredict after v3.3.0, which libCacheSim's GLCache/inference.c still
241+
# calls, so master no longer compiles. See install_deps.sh for the full note.
242+
local xgboost_version="v3.3.0"
243+
239244
pushd "${HOME}/src" >/dev/null
240-
245+
241246
if [[ ! -d "xgboost" ]]; then
242247
git clone --recursive https://github.com/dmlc/xgboost.git
243248
fi
244-
249+
245250
pushd xgboost >/dev/null
246-
git pull origin master
251+
# Fetch and check out the tag instead of pulling master -- this also repoints a
252+
# checkout that an older version of this script left on master.
253+
git fetch --tags origin
254+
git checkout --quiet "${xgboost_version}"
247255
git submodule update --init --recursive
248256

249257
mkdir -p build
@@ -262,14 +270,18 @@ install_xgboost() {
262270
install_lightgbm() {
263271
log_step "Installing LightGBM..."
264272

273+
# Pinned for the same reason as XGBoost above; v4.7.0 matches Homebrew's version.
274+
local lightgbm_version="v4.7.0"
275+
265276
pushd "${HOME}/src" >/dev/null
266-
277+
267278
if [[ ! -d "LightGBM" ]]; then
268279
git clone --recursive https://github.com/microsoft/LightGBM.git
269280
fi
270-
281+
271282
pushd LightGBM >/dev/null
272-
git pull origin master
283+
git fetch --tags origin
284+
git checkout --quiet "${lightgbm_version}"
273285
git submodule update --init --recursive
274286

275287
mkdir -p build

0 commit comments

Comments
 (0)