Skip to content

Commit

Permalink
dont include rocksdb lib in the package
Browse files Browse the repository at this point in the history
  • Loading branch information
hadim committed Jan 4, 2023
1 parent 05f0f15 commit 08fb6d9
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions recipes/aimrocks/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ set -ex
# NOTE(hadim): to locate rocksdb
export AIM_DEP_DIR=$PREFIX

# Do not embed rocksdb in the package
export EMBED_ROCKSDB=0

python -m pip install . -vv
3 changes: 3 additions & 0 deletions recipes/aimrocks/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ source:
url: https://github.com/aimhubio/aimrocks/archive/refs/tags/v{{ version }}.tar.gz
sha256: c30ff542ba95cd615616cec07061f33e8385ebd131801fc2cdaf83010241a469

patches:
- setup_rocksdb.patch

build:
number: 0
skip: true # [win]
Expand Down
64 changes: 64 additions & 0 deletions recipes/aimrocks/setup_rocksdb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/setup.py b/setup.py
index a6ba6e3..7fadf92 100644
--- a/setup.py
+++ b/setup.py
@@ -40,9 +40,6 @@ third_party_install_dir = os.environ.get('AIM_DEP_DIR', '/usr/local')
third_party_deps = ['rocksdb']

third_party_lib_dir = os.path.join(third_party_install_dir, 'lib')
-third_party_libs = glob(os.path.join(third_party_lib_dir, 'librocksdb.*'))
-
-third_party_headers = [os.path.join(third_party_install_dir, 'include/rocksdb')]

# We define a local include directory to store all the required public headers.
# The third party headers are copied into this directory to enable binding with
@@ -54,17 +51,25 @@ local_lib_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'src/aimrocks')
)

-print('third party libs detected:', third_party_libs)
-for source in third_party_libs:
- print('copying third party lib', source, local_lib_dir)
- copy_file(source, local_lib_dir)
+if os.environ.get("EMBED_ROCKSDB", "1") == "1":
+
+ third_party_libs = glob(os.path.join(third_party_lib_dir, 'librocksdb.*'))

-for source in third_party_headers:
- basename = os.path.basename(source)
- destination = os.path.join(local_include_dir, basename)
- copy_tree(source, destination,
- preserve_symlinks=False, update=True)
+ print('third party libs detected:', third_party_libs)
+ for source in third_party_libs:
+ print('copying third party lib', source, local_lib_dir)
+ copy_file(source, local_lib_dir)

+ third_party_headers = [os.path.join(third_party_install_dir, 'include/rocksdb')]
+ for source in third_party_headers:
+ basename = os.path.basename(source)
+ destination = os.path.join(local_include_dir, basename)
+ copy_tree(source, destination,
+ preserve_symlinks=False, update=True)
+
+# `include_dirs` is used to specify the include directories for the extension.
+# It contains the aimrocks local headers and the rocksdb ones.
+include_dirs = [os.path.join(third_party_install_dir, 'include/'), local_include_dir]

exts = [
Extension(
@@ -73,13 +78,12 @@ exts = [
extra_compile_args=aimrocks_extra_compile_args,
extra_link_args=aimrocks_extra_link_args,
language='c++',
- include_dirs=[local_include_dir],
+ include_dirs=include_dirs,
library_dirs=[third_party_lib_dir],
libraries=['rocksdb'],
)
]

-
setup(
name="aimrocks",
version='0.2.1',

0 comments on commit 08fb6d9

Please sign in to comment.