|
1 | 1 | """ |
2 | | -Teide — Low-level ctypes wrapper for libteide. |
| 2 | +Teide — Fast columnar dataframe library for Python. |
3 | 3 |
|
4 | 4 | Usage: |
5 | | - from teide import TeideLib |
6 | | - lib = TeideLib() # loads libteide.so |
7 | | - lib.sym_init() |
8 | | - # ... use the C API ... |
9 | | - lib.sym_destroy() |
10 | | - lib.arena_destroy_all() |
| 5 | + from teide import Context, col, lit |
| 6 | +
|
| 7 | + with Context() as ctx: |
| 8 | + df = ctx.read_csv("data.csv") |
| 9 | + result = df.group_by("id1").agg(col("v1").sum()).collect() |
| 10 | + print(result) |
11 | 11 | """ |
12 | 12 |
|
| 13 | +__version__ = "0.1.0" |
| 14 | + |
13 | 15 | import ctypes |
14 | 16 | import os |
15 | 17 | import sys |
|
21 | 23 |
|
22 | 24 |
|
23 | 25 | def _find_lib(): |
24 | | - """Find libteide.so, checking TEIDE_LIB env var first.""" |
| 26 | + """Find libteide shared library. |
| 27 | +
|
| 28 | + Search order: |
| 29 | + 1. Same directory as this __init__.py (wheel-bundled layout) |
| 30 | + 2. TEIDE_LIB environment variable |
| 31 | + 3. Common build directories relative to source tree |
| 32 | + """ |
| 33 | + _pkg_dir = os.path.dirname(__file__) |
| 34 | + _lib_names = ["libteide.so", "libteide.dylib"] |
| 35 | + |
| 36 | + # 1. Wheel-bundled: libteide.so sits next to __init__.py |
| 37 | + for name in _lib_names: |
| 38 | + path = os.path.join(_pkg_dir, name) |
| 39 | + if os.path.exists(path): |
| 40 | + return os.path.abspath(path) |
| 41 | + |
| 42 | + # 2. Explicit env var |
25 | 43 | env_path = os.environ.get("TEIDE_LIB") |
26 | 44 | if env_path and os.path.exists(env_path): |
27 | 45 | return env_path |
28 | 46 |
|
29 | | - # Search common locations |
| 47 | + # 3. Source-tree build directories |
30 | 48 | search_dirs = [ |
31 | | - os.path.join(os.path.dirname(__file__), "..", "..", "..", "build_release"), |
32 | | - os.path.join(os.path.dirname(__file__), "..", "..", "..", "build"), |
| 49 | + os.path.join(_pkg_dir, "..", "..", "..", "build_release"), |
| 50 | + os.path.join(_pkg_dir, "..", "..", "..", "build"), |
33 | 51 | ".", |
34 | 52 | ] |
35 | 53 | for d in search_dirs: |
36 | | - for name in ["libteide.so", "libteide.dylib"]: |
| 54 | + for name in _lib_names: |
37 | 55 | path = os.path.join(d, name) |
38 | 56 | if os.path.exists(path): |
39 | 57 | return os.path.abspath(path) |
40 | 58 |
|
41 | | - raise OSError("Cannot find libteide.so. Set TEIDE_LIB environment variable.") |
| 59 | + raise OSError( |
| 60 | + "Cannot find libteide.so. Install via 'pip install teide' or set TEIDE_LIB." |
| 61 | + ) |
42 | 62 |
|
43 | 63 |
|
44 | 64 | class TeideLib: |
@@ -422,3 +442,6 @@ def part_load(self, db_root, table_name): |
422 | 442 | OP_AVG = 55 |
423 | 443 | OP_FIRST = 56 |
424 | 444 | OP_LAST = 57 |
| 445 | + |
| 446 | +# Re-export high-level API so users can do: from teide import Context, col, lit |
| 447 | +from teide.api import Context, col, lit, Expr, Table, Series, Query # noqa: E402,F401 |
0 commit comments