Skip to content

Fix: expand ~ in CCACHE_CONFIGPATH to actual home directory#741

Open
b95702041 wants to merge 26 commits intoCytnx-dev:release_to_pypifrom
b95702041:release_to_pypi
Open

Fix: expand ~ in CCACHE_CONFIGPATH to actual home directory#741
b95702041 wants to merge 26 commits intoCytnx-dev:release_to_pypifrom
b95702041:release_to_pypi

Conversation

@b95702041
Copy link
Copy Markdown

  • Use os.path.expanduser() to properly expand ~ in ccache config path
  • Fixes FileNotFoundError on macOS builds in cibuildwheel
  • Resolves CI failure in PR Release to PyPI #711

- Use os.path.expanduser() to properly expand ~ in ccache config path
- Fixes FileNotFoundError on macOS builds in cibuildwheel
- Resolves CI failure in PR Cytnx-dev#711
@b95702041
Copy link
Copy Markdown
Author

b95702041 commented Jan 31, 2026

New error, failed on Building wheel steps but passed the Running before_build step.

https://github.com/b95702041/Cytnx/actions/runs/21540314619

working on fix it now.

- Create symlink from /usr/include/openblas/cblas.h to /usr/include/cblas.h
- Fixes compilation error: 'cblas.h: No such file or directory'
- Similar to existing lapacke.h, lapack.h symlinks
- cblas.h requires openblas_config.h
- Create symlink from /usr/include/openblas/openblas_config.h
- Add CPATH to environment to include /usr/include/openblas
- Create symlinks for all OpenBLAS headers
- Fixes openblas_config-x86_64.h not found error
- Install gcc-c++, glibc-devel, kernel-headers
- Fixes math.h not found error with gcc-toolset-14
- Add CFLAGS and CXXFLAGS with -I/usr/include for Linux builds
- Helps gcc-toolset-14 find standard headers like math.h
- macOS configuration unchanged
- Install gcc-c++, glibc-devel, kernel-headers
- Add cblas.h and openblas_config.h symlinks
- Use ln -sf to force overwrite
- Add verification steps
@b95702041
Copy link
Copy Markdown
Author

b95702041 commented Feb 2, 2026

Fix Linux wheel builds for PyPI release
Remove CFLAGS/CXXFLAGS from pyproject.toml that broke GCC 14 header search.
Use find_package(Boost REQUIRED) instead of CONFIG mode in CMakeLists.txt.
Update cibuildwheel_before_all.sh to install ccache and dependencies for manylinux/musllinux.
Add conditional compilation for execinfo.h in cytnx_error.hpp to support musl libc.

It is successfully built now.

https://github.com/b95702041/Cytnx/actions/runs/21587555177

Copy link
Copy Markdown
Collaborator

@IvanaGyro IvanaGyro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I have some questions.

@@ -1,5 +1,5 @@
[build-system]
requires = ["scikit-build-core >=0.11", "pybind11 >=3.0"]
requires = ["scikit-build-core >=0.11", "pybind11 >=3.0", "setuptools"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why setuptools is needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distutils was deprecated in Python 3.10 and removed in Python 3.12.
Since the build uses Python 3.12, build 8 failed with:
ModuleNotFoundError: No module named 'distutils'
Adding setuptools resolves this because it provides a distutils compatibility layer.
Reference: https://github.com/b95702041/Cytnx/actions/runs/21543068253

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try to figure out which package provide the outdated FindPythonLibsNew.cmake? pybind11 has fixed the issue about distutils few years ago: pybind/pybind11#3677

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file ./cmake/Modules/FindPythonLibsNew.cmake was copied from pybind11 on January 6, 2020 and has never been updated since.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the git history:

gitlog --follow ./cmake/Modules/FindPythonLibsNew.cmake

commit 4af776705ff03bf6ef32a2de32b6ef58e053a214 Author: kaihsin [kaihsinwu@gmail.com](mailto:kaihsinwu@gmail.com) Date: Mon Jan 6 01:22:33 2020 -0500 update, merge complete, clean container base

This file was manually added by kaihsin in 2020, not installed from the pybind11 package.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine to remove it because we have bound with pybind11 now.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the outdated FindPythonLibsNew.cmake. CI now uses pybind11 3.0.2's version and passes.

https://github.com/b95702041/Cytnx/actions/runs/22293371698

@IvanaGyro
Copy link
Copy Markdown
Collaborator

There is a thing that I have not finished. cibuildwheel builds wheels in containers on Linux, which will make ccache fails to cache across the builds with different python version. We have to mount the system directory used by ccache in the docker containers.

Copy link
Copy Markdown
Collaborator

@pcchen pcchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #741 Review — Fix: expand ~ in CCACHE_CONFIGPATH

Posted by Claude Code on behalf of @pcchen

Critical Issues (1)

1. expanduser called before null check — TypeError if env var is unset
tools/cibuildwheel_before_build.py

ccache_config_path = os.getenv('CCACHE_CONFIGPATH')

# Expand ~ to actual home directory
ccache_config_path = os.path.expanduser(ccache_config_path)  # ← called with None if var unset
if not ccache_config_path:
    raise RuntimeError('The CCACHE_CONFIGPATH environment variable must be set.')

os.getenv() returns None if the variable is not set. os.path.expanduser(None) raises TypeError in Python 3, masking the real error message. The null check must come first:

ccache_config_path = os.getenv('CCACHE_CONFIGPATH')
if not ccache_config_path:
    raise RuntimeError('The CCACHE_CONFIGPATH environment variable must be set.')
ccache_config_path = os.path.expanduser(ccache_config_path)

Important Issues (3)

2. libomp-devel dropped from dnf/yum install
tools/cibuildwheel_before_all.sh

The old script installed libomp-devel (OpenMP). The new dnf and yum branches omit it. If the C++ build uses OpenMP (-fopenmp), this will cause silent link failures. Only the apk branch doesn't need it because Alpine ships OpenMP with GCC. Add libomp-devel back to the dnf/yum branches.

3. .bak file committed to git
cmake/Modules/FindPythonLibsNew.cmake.bak

Renaming FindPythonLibsNew.cmakeFindPythonLibsNew.cmake.bak commits a backup artifact to the repo. Either delete the file if it's no longer needed, or keep the original name. A .bak file in cmake/Modules will confuse future developers.

4. Boost_NO_BOOST_CMAKE=ON only applied to Linux, not macOS
pyproject.toml

CMAKE_ARGS = "-DBoost_NO_BOOST_CMAKE=ON" is set in [tool.cibuildwheel.linux] environment but not [tool.cibuildwheel.macos]. Combined with the CMakeLists.txt change removing CONFIG from find_package(Boost REQUIRED), this may behave inconsistently: Linux forces the find-module path, macOS uses whatever CMake defaults to with Homebrew Boost. If macOS already works, add a comment explaining why the flag is not needed there.


Minor Issues (2)

5. ~ in CCACHE_CONFIGPATH is fragile
pyproject.toml: CCACHE_CONFIGPATH = "~/ccache.conf" — cibuildwheel passes this as a literal string; shell expansion does not apply. The Python fix makes it work, but $HOME/ccache.conf would be more conventional and self-documenting.

6. setuptools added without version pin
pyproject.toml: "setuptools" added to build-system.requires with no version constraint. This may cause non-reproducible builds as setuptools makes breaking changes. Consider "setuptools>=68" or similar.


Strengths

  • The execinfo.h / HAS_EXECINFO guard in cytnx_error.hpp is correct and necessary for non-glibc platforms (macOS, musl/Alpine).
  • Multi-distro apk/dnf/yum dispatch in cibuildwheel_before_all.sh is clean and extensible.
  • ln -sf instead of ln -s prevents errors on re-runs.
  • manylinux_2_28 downgrade is a reasonable compatibility improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants