You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2021/09/08 18:47:13 UTC

[datasketches-cpp] 02/02: pull changes to remove in-tree pybind11, refactor to allow python and c++ to coexist in a single package

This is an automated email from the ASF dual-hosted git repository.

jmalkin pushed a commit to branch count-sketch-python
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git

commit fc2841bebcd215edb3b835389f4dcb1b951a0ed1
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Wed Sep 8 11:46:48 2021 -0700

    pull changes to remove in-tree pybind11, refactor to allow python and c++ to coexist in a single package
---
 python/CMakeLists.txt                          | 2 +-
 python/datasketches/__init__.py                | 7 +++++++
 python/{src => datasketches}/count_sketch.py   | 2 +-
 python/{src => datasketches}/streaming_heap.py | 0
 python/src/__init__.py                         | 2 --
 python/src/datasketches.cpp                    | 2 +-
 python/tests/count_sketch_test.py              | 6 ++----
 setup.py                                       | 2 +-
 8 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index f541b93..f2f2eb5 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -45,7 +45,7 @@ target_link_libraries(python
 
 set_target_properties(python PROPERTIES
   PREFIX ""
-  OUTPUT_NAME datasketches
+  OUTPUT_NAME _datasketches
 )
 
 # ensure we make a .so on Mac rather than .dylib
diff --git a/python/datasketches/__init__.py b/python/datasketches/__init__.py
new file mode 100644
index 0000000..6b87303
--- /dev/null
+++ b/python/datasketches/__init__.py
@@ -0,0 +1,7 @@
+#from .streaming_heap import StreamingHeap
+from .count_sketch import CountSketch
+
+try:
+  from _datasketches import *
+except ImportError:
+  print("Import error!")
diff --git a/python/src/count_sketch.py b/python/datasketches/count_sketch.py
similarity index 99%
rename from python/src/count_sketch.py
rename to python/datasketches/count_sketch.py
index 34ac8f1..47cbf6a 100644
--- a/python/src/count_sketch.py
+++ b/python/datasketches/count_sketch.py
@@ -17,7 +17,7 @@
 
 import numpy as np
 from random import randint, seed
-from streaming_heap import StreamingHeap
+from datasketches.streaming_heap import StreamingHeap
 
 
 class CountSketch:
diff --git a/python/src/streaming_heap.py b/python/datasketches/streaming_heap.py
similarity index 100%
rename from python/src/streaming_heap.py
rename to python/datasketches/streaming_heap.py
diff --git a/python/src/__init__.py b/python/src/__init__.py
index 1e1acc2..e69de29 100644
--- a/python/src/__init__.py
+++ b/python/src/__init__.py
@@ -1,2 +0,0 @@
-name = "datasketches"
- 
\ No newline at end of file
diff --git a/python/src/datasketches.cpp b/python/src/datasketches.cpp
index 4ef491b..a3f5749 100644
--- a/python/src/datasketches.cpp
+++ b/python/src/datasketches.cpp
@@ -30,7 +30,7 @@ void init_vo(py::module& m);
 void init_req(py::module& m);
 void init_vector_of_kll(py::module& m);
 
-PYBIND11_MODULE(datasketches, m) {
+PYBIND11_MODULE(_datasketches, m) {
   init_hll(m);
   init_kll(m);
   init_fi(m);
diff --git a/python/tests/count_sketch_test.py b/python/tests/count_sketch_test.py
index 6bcd49e..925816c 100644
--- a/python/tests/count_sketch_test.py
+++ b/python/tests/count_sketch_test.py
@@ -16,10 +16,8 @@
 # under the License.
 
 import unittest
-import sys
-import os
-sys.path.append(os.path.abspath('../src'))
-from count_sketch import CountSketch  # TODO  -- There is probably a better way to do this??
+
+from datasketches import CountSketch
 import numpy as np
 
 
diff --git a/setup.py b/setup.py
index c3ec1a6..d76f667 100644
--- a/setup.py
+++ b/setup.py
@@ -91,7 +91,7 @@ setup(
     packages=find_packages('python'), # python pacakges only in this dir
     package_dir={'':'python'},
     # may need to add all source paths for sdist packages w/o MANIFEST.in
-    ext_modules=[CMakeExtension('datasketches')],
+    ext_modules=[CMakeExtension('_datasketches')],
     cmdclass={'build_ext': CMakeBuild},
     install_requires=['numpy', 'pybind11 >= 2.6.0'],
     zip_safe=False

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org