add automatic build and publishing scripts

This commit is contained in:
Florian Förster 2026-03-12 12:26:45 +01:00
parent aa288bab65
commit 99a94a3046
6 changed files with 81 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
# own
llama_cpp_python_src/
prototypes/
data/
reports/

View File

@ -0,0 +1,66 @@
@echo off
SETLOCAL EnableDelayedExpansion
:: path to VS Build Tools (example for VS 2022 Community) (otherwise not found in default terminal)
set "VS_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
if exist "%VS_PATH%" (
call "%VS_PATH%"
) else (
echo [X] Setup script for Visual Studio env variables could not be found!
pause
exit /b
)
:: --- Configuration ---
set "REPO_URL=https://github.com/abetlen/llama-cpp-python.git"
set "SOURCE_DIR=llama_cpp_python_src"
set "WHEEL_DIR=.\dist"
:: Optional: specify CUDA architecture (e.g. "89" für RTX 1000 Ada Laptop GPU)
:: "native" architecture only possible if device is identified properly
:: see https://developer.nvidia.com/cuda/gpus for compute compatibility
:: set "CMAKE_ARGS=-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=native"
set "CMAKE_ARGS=-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES='89'"
set "FORCE_CMAKE=1"
set "CMAKE_BUILD_PARALLEL_LEVEL=4"
set "MAX_JOBS=4"
echo [*] Check source directory...
if exist "%SOURCE_DIR%" (
echo [*] Directory exists. Update repository...
cd "%SOURCE_DIR%"
git fetch --all
git reset --hard origin/main
git pull origin main
:: update submodules (contains the actual llama.cpp)
git submodule update --init --recursive
) else (
echo [*] Clone repository...
git clone --recurse-submodules %REPO_URL% %SOURCE_DIR%
cd "%SOURCE_DIR%"
)
echo [*] Start compilation und wheel generation...
:: build wheel from current directory (.)
@REM pdm run -p ..\ python --version
@REM pdm run -p ..\ python -m pip --version
@REM pause
@REM exit /b
pdm run -p ..\ python -m pip wheel . --wheel-dir="..\%WHEEL_DIR%" --no-cache-dir --no-deps -vv
if %ERRORLEVEL% EQU 0 (
echo.
echo [!] SUCCESS: Wheel with CUDA support placed in: %WHEEL_DIR%
dir "..\%WHEEL_DIR%\llama_cpp_python*.whl"
) else (
echo.
echo [X] ERROR: Build process failed.
)
cd ..
pause
ENDLOCAL

13
pdm.lock generated
View File

@ -5,7 +5,7 @@
groups = ["default", "dev", "lint"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
content_hash = "sha256:b23e8c0ac043347792e09d8cc5ed2b185120ad3cec1a2a179842a690a9618d33"
content_hash = "sha256:281a45dbbe9fe4927e83d52f27e165b12498964c56e3d2600e5a5562ba627a23"
[[metadata.targets]]
requires_python = ">=3.11"
@ -423,6 +423,17 @@ files = [
{file = "pdoc3-0.11.6.tar.gz", hash = "sha256:1ea5e84b87a754d191fb64bf5e517ca6c50d0d84a614c1efecf6b46d290ae387"},
]
[[package]]
name = "pip"
version = "26.0.1"
requires_python = ">=3.9"
summary = "The PyPA recommended tool for installing Python packages."
groups = ["default"]
files = [
{file = "pip-26.0.1-py3-none-any.whl", hash = "sha256:bdb1b08f4274833d62c1aa29e20907365a2ceb950410df15fc9521bad440122b"},
{file = "pip-26.0.1.tar.gz", hash = "sha256:c4037d8a277c89b320abe636d59f91e6d0922d08a05b60e85e53b296613346d8"},
]
[[package]]
name = "platformdirs"
version = "4.9.4"

View File

@ -5,7 +5,7 @@ description = "project to build CUDA-enabled builds of Python bindings for 'llam
authors = [
{name = "Florian Förster", email = "f.foerster@d-opt.com"},
]
dependencies = []
dependencies = ["pip>=26.0.1"]
requires-python = ">=3.11"
readme = "README.md"
license = {text = "LicenseRef-Proprietary"}

View File

@ -1 +1 @@
pdm publish -r local --skip-existing
pdm publish -r local -d .\dist --skip-existing --no-build