Skip to content

Commit

Permalink
add python api
Browse files Browse the repository at this point in the history
Change-Id: Id098c63b08752493358052185c440fbec99533c5
  • Loading branch information
hzzhaojianming committed May 7, 2019
1 parent f415dd6 commit 7a4600c
Show file tree
Hide file tree
Showing 8 changed files with 6,538 additions and 0 deletions.
80 changes: 80 additions & 0 deletions curvefs_python/BUILD_bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library

COPTS = [
"-DGFLAGS=gflags",
"-DOS_LINUX",
"-DSNAPPY",
"-DHAVE_SSE42",
"-DNDEBUG",
"-fno-omit-frame-pointer",
"-momit-leaf-frame-pointer",
"-msse4.2",
"-pthread",
"-Wsign-compare",
"-Wno-unused-parameter",
"-Wno-unused-variable",
"-Woverloaded-virtual",
"-Wnon-virtual-dtor",
"-Wno-missing-field-initializers",
"-std=c++14",
]

cc_library(
name = "curvefs",
srcs = glob(["*.cxx"]),
hdrs = glob(["*h"]),
deps = [
"//external:gflags",
"//external:glog",
"//external:leveldb",
"//external:brpc",
"//external:braft",
"//external:protobuf",
"//src/common:curve_common",
"//src/common:curve_auth",
"//include/client:include_client",
"//include:include-common",
"//proto:nameserver2_cc_proto",
"//proto:topology_cc_proto",
"//proto:chunkserver-cc-protos",
"//src/client:curve_client"
],
copts = COPTS,
linkopts = [
"-lbraft",
"-lcbd",
"-lcurve_client",
"-lbrpc",
"-lbthread",
"-lbvar",
"-ljson2pb",
"-lmcpack2pb",
"-lbutil",
"-lprotoc_lib",
"-lcc_brpc_internal_proto",
"-lcc_brpc_idl_options_proto",
"-lleveldb",
"-lcc_braft_internal_proto",
"-lcurve_common",
"-lcurve_auth",
"-lcurve_concurrent",
"-lglog",
"-lgflags",
"-lnameserver2_proto",
"-ltopology_proto",
"-lchunkserver-protos",
"-lprotobuf",
"-lprotobuf_lite",
"-lssl",
"-lrt",
"-lssl",
"-lcrypto",
"-ldl",
"-lz",
"-lpthread",
"-lunwind",
"-lstdc++",
"-lm",
],
visibility = ["//visibility:public"],
)
18 changes: 18 additions & 0 deletions curvefs_python/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
1.编译整个工程
2.在curve目录下执行 ./curvefs_python/config.sh
3.编译curvefs库
4.拷贝生成libcurvefs动态库到动态库可以搜索的路径
5.接口封装在curvefs.py中,可以通过import curvefs使用

eg:

编译整个工程:
bazel build ... --copt -DHAVE_ZLIB=1 --compilation_mode=dbg -s --define=with_glog=true --define=libunwind=true

在curve目录下执行配置脚本
sh ./curvefs_python/config.sh

编译curvefs库(需要增加一个linkopt选项,指定curvefs_python/tmplib路径):
bazel build curvefs_python:curvefs --copt -DHAVE_ZLIB=1 --compilation_mode=dbg -s --define=with_glog=true --define=libunwind=true --linkopt -L/home/hzzhaojianming/curve/curvefs_python/tmplib

编译成功,拷贝libcurvefs.so并重命名为_curvefs.so
33 changes: 33 additions & 0 deletions curvefs_python/client.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# metaserver config
#
metaserver_addr=127.0.0.1:6666

#
# metacache config
#
getLeaderRetry=3
retryIntervalUs=500

#
# request scheduler config
#
queueCapacity=4096
threadpoolSize=2

#
# failure retry policy
#
opRetryIntervalUs=200000
opMaxRetry=3

#
# io option
#
enableAppliedIndexRead=1
ioSplitMaxSize=64

#
# log info
#
loglevel=0
26 changes: 26 additions & 0 deletions curvefs_python/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
echo "********************************************************************"
echo "***********Prepare for curvefs python API build env.****************"
echo "********************************************************************"
echo "First of all, you must build curve all. Then you can run this script."

curve_path=$PWD

echo "curve workspace path is $curve_path"

cd $curve_path/curvefs_python/

echo "Prepare bazel build file"
cp BUILD_bak BUILD -f

echo "copy libs to tmplib directory"

mkdir tmplib
for i in `find $curve_path/bazel-bin/|grep -w so|grep -v solib|grep -v params`
do
echo $i
cp -f $i ./tmplib/
done

echo "Prepare env done, you can build curvefs now."
echo "Plesae add --linkopt -L/path/to/tmplib to bazel build command line."
8 changes: 8 additions & 0 deletions curvefs_python/curvefs.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%module curvefs
%{
#include <stdint.h>
#include "libcurvefs.h"
%}

%include <stdint.i>
%include "libcurvefs.h"
Loading

0 comments on commit 7a4600c

Please sign in to comment.