mirror of
https://github.com/abetlen/llama-cpp-python.git
synced 2023-09-07 17:34:22 +03:00
Updated package to build with skbuild
This commit is contained in:
37
setup.py
37
setup.py
@@ -1,42 +1,11 @@
|
||||
import os
|
||||
import subprocess
|
||||
from setuptools import setup, Extension
|
||||
|
||||
from distutils.command.build_ext import build_ext
|
||||
|
||||
|
||||
class build_ext_custom(build_ext):
|
||||
def run(self):
|
||||
build_dir = os.path.join(os.getcwd(), "build")
|
||||
src_dir = os.path.join(os.getcwd(), "vendor", "llama.cpp")
|
||||
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
|
||||
cmake_flags = [
|
||||
"-DLLAMA_STATIC=Off",
|
||||
"-DBUILD_SHARED_LIBS=On",
|
||||
"-DCMAKE_CXX_FLAGS=-fPIC",
|
||||
"-DCMAKE_C_FLAGS=-fPIC",
|
||||
]
|
||||
subprocess.check_call(["cmake", src_dir, *cmake_flags], cwd=build_dir)
|
||||
subprocess.check_call(["cmake", "--build", "."], cwd=build_dir)
|
||||
|
||||
# Move the shared library to the root directory
|
||||
lib_path = os.path.join(build_dir, "libllama.so")
|
||||
target_path = os.path.join(os.getcwd(), "libllama.so")
|
||||
os.rename(lib_path, target_path)
|
||||
|
||||
from skbuild import setup
|
||||
|
||||
setup(
|
||||
name="llama_cpp",
|
||||
description="A Python wrapper for llama.cpp",
|
||||
version="0.0.1",
|
||||
version="0.1.1",
|
||||
author="Andrei Betlen",
|
||||
author_email="abetlen@gmail.com",
|
||||
license="MIT",
|
||||
py_modules=["llama_cpp"],
|
||||
ext_modules=[
|
||||
Extension("libllama", ["vendor/llama.cpp"]),
|
||||
],
|
||||
cmdclass={"build_ext": build_ext_custom},
|
||||
packages=['llama_cpp'],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user