llama-cpp-python
llama-cpp-python copied to clipboard
Set GGML_BUILD_NUMBER to the correct version when building from pypi tarball
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [X] I am running the latest code. Development is very rapid so there are no tagged versions as of now.
- [X] I carefully followed the README.md.
- [X] I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
- [X] I reviewed the Discussions, and have a new bug or useful enhancement to share.
Expected Behavior
When I build the package from the source tarball uploaded to PyPI, I expect PACKAGE_VERSION in ggml-version.cmake file set to the same version as extracted from git when building directly from the git repo.
Current Behavior
$ grep PACKAGE_VERSION result/lib/python3.12/site-packages/lib/cmake/ggml/ggml-version.cmake | grep '^set'
set(PACKAGE_VERSION "0.0.1"
This is probably because while the published tarball includes .git, the checkout done by actions/checkout in the publish workflow doesn't fetch full depth of the git repo, so the checkout turns out shallow.
This is what is seen during the build:
python3.12-llama-cpp-python> CMake Warning at vendor/llama.cpp/ggml/CMakeLists.txt:298 (message):
python3.12-llama-cpp-python> GGML build version fixed at 1 likely due to a shallow clone.
I think this can be fixed by setting fetch-depth to 0 for the publish workflow. Of course, this may be not very optimal because then the resulting tarball will have to include complete git repo. (The difference in my local tests is around 100Mb.)
Perhaps an alternative fix is to calculate the version during the sdist build, then storing it inside the tarball as a file; finally, read the version from this file during the build, if it's present.