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)
248
248
add_compile_definitions (_CRT_SECURE_NO_WARNINGS )
249
249
endif ()
250
250
251
+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} )
252
+
251
253
add_subdirectory (ggml )
252
254
253
255
add_library (clip
@@ -264,6 +266,9 @@ if (BUILD_SHARED_LIBS)
264
266
set_target_properties (ggml PROPERTIES POSITION_INDEPENDENT_CODE ON )
265
267
set_target_properties (clip PROPERTIES POSITION_INDEPENDENT_CODE ON )
266
268
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 )
267
272
endif ()
268
273
269
274
add_subdirectory (models )
Original file line number Diff line number Diff line change 1
1
import ctypes
2
+ from ctypes .util import find_library
2
3
import os
3
4
from typing import List , Dict , Any
4
5
8
9
this_dir = os .path .abspath (os .path .dirname (__file__ ))
9
10
10
11
# 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 )
16
19
17
20
18
21
# 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 1
1
# /bin/bash
2
+
3
+ # Change to the project directory
4
+ cd " $( dirname " $0 " ) " /..
5
+
2
6
find . -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