diff --git a/.gitignore b/.gitignore index f61a629..28d9139 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ dist *.eggs src/aimrocks/lib_rocksdb.cpp *.so +*.lib *.dylib lib*.so.* __pycache__ diff --git a/MANIFEST.in b/MANIFEST.in index 27cd7f8..eb7254d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ include requirements.txt -recursive-include src *.hpp *.pxd *.pyx *.h *.hxx *.pyi *.so* *.dylib* +recursive-include src *.hpp *.pxd *.pyx *.h *.hxx *.pyi *.lib *.so* *.dylib* diff --git a/setup.py b/setup.py index a6ba6e3..4e29bfc 100644 --- a/setup.py +++ b/setup.py @@ -33,14 +33,28 @@ if platform.system() == 'Darwin': aimrocks_extra_compile_args += ['-mmacosx-version-min=10.7', '-stdlib=libc++'] aimrocks_extra_link_args += ["-Wl,-rpath,@loader_path"] +elif platform.system() == 'Windows': + aimrocks_extra_compile_args = ['/std:c++latest', '/permissive-', '/W3', '/O2', '/EHsc', '/GL'] + aimrocks_extra_link_args = ['/LTCG'] else: aimrocks_extra_link_args += ["-Wl,-rpath,$ORIGIN"] -third_party_install_dir = os.environ.get('AIM_DEP_DIR', '/usr/local') -third_party_deps = ['rocksdb'] +if platform.system() == 'Windows': + third_party_install_dir = os.environ.get('AIM_DEP_DIR', '../vcpkg/installed/x64-windows-static-md') + third_party_deps = ['rocksdb', 'bz2', 'lz4', 'snappy', 'zlib', 'zstd'] +else: + 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.*')) +if platform.system() == 'Windows': + third_party_libs = [ + os.path.join(third_party_lib_dir, lib + '.lib') + for lib in third_party_deps + ] + third_party_deps += ['rpcrt4', 'shlwapi'] # Windows system libs used by rocksdb +else: + third_party_libs = glob(os.path.join(third_party_lib_dir, 'librocksdb.*')) third_party_headers = [os.path.join(third_party_install_dir, 'include/rocksdb')] @@ -75,7 +89,7 @@ language='c++', include_dirs=[local_include_dir], library_dirs=[third_party_lib_dir], - libraries=['rocksdb'], + libraries=third_party_deps, ) ] diff --git a/src/aimrocks/lib_utils.py b/src/aimrocks/lib_utils.py index 40e2dc7..c9f53aa 100644 --- a/src/aimrocks/lib_utils.py +++ b/src/aimrocks/lib_utils.py @@ -17,9 +17,20 @@ def get_lib_dir(): return path def get_libs(): - return [ + libs = [ 'rocksdb', ] + if platform.system() == 'Windows': + libs += [ + 'bz2', + 'lz4', + 'snappy', + 'zlib', + 'zstd', + 'rpcrt4', + 'shlwapi', + ] + return libs def get_lib_filename(name, lib_dir): if platform.system() == 'Darwin': diff --git a/tests/test_memtable.py b/tests/test_memtable.py index 103c773..531c85f 100644 --- a/tests/test_memtable.py +++ b/tests/test_memtable.py @@ -13,6 +13,7 @@ def test_open_skiplist_memtable_factory(): loc = tempfile.mkdtemp() try: test_db = aimrocks.DB(os.path.join(loc, "test"), opts) + del test_db finally: shutil.rmtree(loc) @@ -25,5 +26,6 @@ def test_open_vector_memtable_factory(): loc = tempfile.mkdtemp() try: test_db = aimrocks.DB(os.path.join(loc, "test"), opts) + del test_db finally: shutil.rmtree(loc)