abetlen / abetlen/llama-cpp-python

Set GGML_BUILD_NUMBER to the correct version when building from pypi tarball

未關閉
#1,979 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
10.6k
分支
1.4k
PR 合併指標
PR 指標待擷取

描述

# 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](https://github.com/abetlen/llama-cpp-python/blob/main/README.md).
- [X] I [searched using keywords relevant to my issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/filtering-and-searching-issues-and-pull-requests) to make sure that I am creating a new issue that is not already open (or closed).
- [X] I reviewed the [Discussions](https://github.com/abetlen/llama-cpp-python/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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。