File tree Expand file tree Collapse file tree 4 files changed +33
-5
lines changed
examples/python_bindings/clip_cpp Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,8 @@ if (MSVC)
248248 add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
249249endif ()
250250
251+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
252+
251253add_subdirectory (ggml)
252254
253255add_library (clip
@@ -264,6 +266,9 @@ if (BUILD_SHARED_LIBS)
264266 set_target_properties (ggml PROPERTIES POSITION_INDEPENDENT_CODE ON )
265267 set_target_properties (clip PROPERTIES POSITION_INDEPENDENT_CODE ON )
266268 target_compile_definitions (clip PRIVATE CLIP_SHARED CLIP_BUILD)
269+ set (CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR} )
270+ install (TARGETS ggml clip
271+ LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR} /examples/python_bindings/clip_cpp)
267272endif ()
268273
269274add_subdirectory (models)
Original file line number Diff line number Diff line change 11import ctypes
2+ from ctypes .util import find_library
23import os
34from typing import List , Dict , Any
45
89this_dir = os .path .abspath (os .path .dirname (__file__ ))
910
1011# Load the shared library
11- path_to_dll = os .environ .get ("CLIP_DLL" , this_dir )
12- os .chdir (path_to_dll )
13- ggml_lib = ctypes .CDLL ("./libggml.so" )
14- clip_lib = ctypes .CDLL ("./libclip.so" )
15- os .chdir (cur_dir )
12+ ggml_lib_path , clip_lib_path = find_library ("ggml" ), find_library ("clip" )
13+ if ggml_lib_path is None or clip_lib_path is None :
14+ raise RuntimeError (f"Could not find shared libraries. Please copy to the current working directory or supply the "
15+ f"correct LD_LIBRARY_PATH/DYLD_LIBRARY_PATH." )
16+
17+ ggml_lib = ctypes .CDLL (ggml_lib_path )
18+ clip_lib = ctypes .CDLL (clip_lib_path )
1619
1720
1821# Define the ctypes structures
Original file line number Diff line number Diff line change 1+ # /bin/bash
2+
3+ # Change to the project directory
4+ cd " $( dirname " $0 " ) " /..
5+
6+ rm -rf ./build
7+
8+ mkdir build
9+
10+ cd build
11+
12+ cmake -DBUILD_SHARED_LIBS=ON -DCLIP_NATIVE=OFF ..
13+
14+ make
15+
16+ make install
Original file line number Diff line number Diff line change 11# /bin/bash
2+
3+ # Change to the project directory
4+ cd " $( dirname " $0 " ) " /..
5+
26find . -type f \( -name ' *.cpp' -o -name ' *.hpp' -o -name ' *.c' -o -name ' *.h' \) ! -path " ./ggml/*" ! -path " ./build/*" -exec clang-format -i {} +
You can’t perform that action at this time.
0 commit comments