nedb-engine 2.2.26__tar.gz → 2.2.28__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/PKG-INFO +1 -1
  2. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/pyproject.toml +1 -1
  3. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/__init__.py +28 -2
  4. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/_native.abi3.so +0 -0
  5. nedb_engine-2.2.28/python/nedb/nedbd-v2 +0 -0
  6. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/nedbd-v2-darwin-arm64 +0 -0
  7. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/nedbd-v2-darwin-x64 +0 -0
  8. nedb_engine-2.2.28/python/nedb/nedbd-v2.exe +0 -0
  9. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/server.py +207 -6
  10. nedb_engine-2.2.26/python/nedb/nedbd-v2 +0 -0
  11. nedb_engine-2.2.26/python/nedb/nedbd-v2.exe +0 -0
  12. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/.gitignore +0 -0
  13. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/LICENSE +0 -0
  14. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/README.md +0 -0
  15. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/client/node/README.md +0 -0
  16. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/client/python/README.md +0 -0
  17. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/autoindex.py +0 -0
  18. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/backends/__init__.py +0 -0
  19. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/backends/redis_backend.py +0 -0
  20. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/cascade.py +0 -0
  21. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/concurrent.py +0 -0
  22. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/crypto.py +0 -0
  23. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/engine.py +0 -0
  24. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/index.py +0 -0
  25. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/log.py +0 -0
  26. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/merkle.py +0 -0
  27. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/mongo.py +0 -0
  28. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/query.py +0 -0
  29. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/redis_compat.py +0 -0
  30. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/relations.py +0 -0
  31. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/resp2.py +0 -0
  32. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/snapshot.py +0 -0
  33. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/sql.py +0 -0
  34. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/store.py +0 -0
  35. {nedb_engine-2.2.26 → nedb_engine-2.2.28}/python/nedb/wrap_redis.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nedb-engine
3
- Version: 2.2.26
3
+ Version: 2.2.28
4
4
  Summary: NEDB — a versioned, self-compressing, time-traveling embedded database (replay-protected, idempotent, relational, searchable) with durable AOF persistence and a server daemon (nedbd).
5
5
  Project-URL: Homepage, https://github.com/aiassistsecure/nedb
6
6
  Project-URL: Repository, https://github.com/aiassistsecure/nedb
@@ -10,7 +10,7 @@ build-backend = "hatchling.build"
10
10
 
11
11
  [project]
12
12
  name = "nedb-engine"
13
- version = "2.2.26"
13
+ version = "2.2.28"
14
14
  description = "NEDB — a versioned, self-compressing, time-traveling embedded database (replay-protected, idempotent, relational, searchable) with durable AOF persistence and a server daemon (nedbd)."
15
15
  readme = "README.md"
16
16
  requires-python = ">=3.8"
@@ -34,8 +34,34 @@ try: # compiled Rust core, present in platform wheels (PyO3 via maturin)
34
34
  from . import _native # type: ignore
35
35
  __has_native__ = True
36
36
  except ImportError: # pure-Python install (sdist / unsupported platform)
37
- _native = None # type: ignore
37
+ # Provide a stub module so `from nedb._native import NedbCore` raises an
38
+ # informative error instead of a bare ImportError with no guidance.
39
+ import types as _types, sys as _sys
40
+
41
+ class _NativeStub(_types.ModuleType):
42
+ _MSG = (
43
+ "\n\n"
44
+ " nedb._native is not available on this platform.\n\n"
45
+ " The compiled Rust core ships with platform wheels (Linux x86_64,\n"
46
+ " macOS arm64/x86_64, Windows x64 CPython). It is NOT included in\n"
47
+ " the universal wheel installed on MSYS2/MinGW Python.\n\n"
48
+ " Options:\n"
49
+ " 1. Use the HTTP server instead (works on any platform):\n"
50
+ " nedbd --dag ./data # start DAG server\n"
51
+ " NEDB_URL=http://localhost:7070 python3 script.py\n\n"
52
+ " 2. Re-install on a platform that has a native wheel:\n"
53
+ " pip install --force-reinstall --no-cache-dir nedb-engine\n\n"
54
+ " 3. Run 'nedbd --doctor' for a full diagnosis.\n"
55
+ )
56
+ def __getattr__(self, name: str):
57
+ raise ImportError(f"nedb._native.{name} is not available.{self._MSG}")
58
+
59
+ _native_stub = _NativeStub("nedb._native")
60
+ _native_stub.__package__ = "nedb"
61
+ _sys.modules["nedb._native"] = _native_stub # type: ignore
62
+ _native = _native_stub # type: ignore
38
63
  __has_native__ = False
64
+ del _types, _sys, _NativeStub, _native_stub
39
65
 
40
66
  __all__ = [
41
67
  "NEDB", "OpLog", "Op", "ReplayError", "Query", "parse_nql",
@@ -47,4 +73,4 @@ __all__ = [
47
73
  "wrap_redis", "WrappedRedis",
48
74
  "_native", "__has_native__",
49
75
  ]
50
- __version__ = "2.2.26"
76
+ __version__ = "2.2.28"
Binary file
@@ -544,6 +544,189 @@ def make_handler(manager: Manager, token: Optional[str]):
544
544
  return Handler
545
545
 
546
546
 
547
+ def _run_doctor() -> None: # noqa: C901
548
+ """Interactive environment diagnostic with exact copy-paste commands."""
549
+ import platform as _platform, shutil as _shutil, sys as _sys, subprocess as _sub
550
+
551
+ from . import __version__
552
+
553
+ # ── terminal colours (disabled on Windows without ANSI support) ──────────
554
+ _ansi = _sys.stdout.isatty() and _sys.platform != "win32" or os.environ.get("TERM")
555
+ def _c(code, text): return f"\033[{code}m{text}\033[0m" if _ansi else text
556
+ OK = _c("32", "✓")
557
+ ERR = _c("31", "✗")
558
+ WARN = _c("33", "!")
559
+ BOLD = lambda t: _c("1", t)
560
+ DIM = lambda t: _c("2", t)
561
+ CMD = lambda t: _c("36", t) # cyan for copy-paste commands
562
+
563
+ def _hr(char="─", width=60): print(f" {char * width}")
564
+ def _h(title): _hr(); print(f" {BOLD(title)}"); _hr()
565
+ def _ok(msg): print(f" {OK} {msg}")
566
+ def _err(msg): print(f" {ERR} {msg}")
567
+ def _warn(msg): print(f" {WARN} {msg}")
568
+ def _cmd(label, cmd, comment=""):
569
+ parts = [f" {CMD(cmd)}"]
570
+ if comment:
571
+ parts.append(f" {DIM('# ' + comment)}")
572
+ elif label:
573
+ parts.append(f" {DIM('# ' + label)}")
574
+ print("".join(parts))
575
+
576
+ print(f"\n {BOLD('NEDB Doctor')} · v{__version__}\n")
577
+
578
+ # ── 1. Python environment ─────────────────────────────────────────────────
579
+ _h("Python environment")
580
+ py_exe = _sys.executable
581
+ py_ver = _platform.python_version()
582
+ py_impl = _platform.python_implementation()
583
+ machine = _platform.machine()
584
+ sys_pl = _sys.platform
585
+
586
+ # Detect MSYS2 / MinGW
587
+ msystem = os.environ.get("MSYSTEM", "")
588
+ is_msys2 = bool(msystem) or "mingw" in py_exe.lower()
589
+ env_tag = f"MSYS2 {msystem}" if is_msys2 else sys_pl
590
+
591
+ _ok(f"Python {py_ver} ({py_impl}, {env_tag}, {machine})")
592
+ _ok(f"Executable {py_exe}")
593
+
594
+ # pip executable
595
+ _pip = _shutil.which("pip3") or _shutil.which("pip") or f"{py_exe} -m pip"
596
+ _ok(f"pip {_pip}")
597
+
598
+ # site-packages
599
+ import site as _site
600
+ _sp = (_site.getsitepackages() or [None])[0]
601
+ _ok(f"site-packages {_sp}")
602
+
603
+ # ── 2. nedb._native ───────────────────────────────────────────────────────
604
+ _h("nedb._native (embedded Rust DAG core)")
605
+ from nedb import __has_native__
606
+ has_native = __has_native__
607
+ if has_native:
608
+ _ok("nedb._native loaded — NedbCore / embedded DAG API ready")
609
+ else:
610
+ _err("nedb._native not available")
611
+ if is_msys2:
612
+ _warn("MSYS2/MinGW Python cannot load MSVC-compiled extensions.")
613
+ _warn("This is a known limitation — use HTTP mode (see Fix plan below).")
614
+ else:
615
+ print(f"\n {BOLD('Fix:')} reinstall to pull the platform wheel:\n")
616
+ _cmd("", f"{_pip} install --force-reinstall --no-cache-dir nedb-engine",
617
+ "downloads the wheel with _native bundled")
618
+
619
+ # ── 3. nedbd-v2 binary ────────────────────────────────────────────────────
620
+ _h("nedbd-v2 (DAG HTTP server binary)")
621
+ _pkg_dir = os.path.dirname(os.path.abspath(__file__))
622
+ _cwd = os.getcwd()
623
+ _cargo_bin = os.path.join(os.path.expanduser("~"), ".cargo", "bin")
624
+ _bin_names = ["nedbd-v2", "nedbd_v2", "nedbd-v2.exe", "nedbd_v2.exe"]
625
+ _cargo_names = ["nedbd", "nedbd.exe"]
626
+ _search = (
627
+ [os.path.join(_pkg_dir, n) for n in _bin_names]
628
+ + [_shutil.which(n) or "" for n in _bin_names]
629
+ + [os.path.join(_cargo_bin, n) for n in _bin_names + _cargo_names]
630
+ + [os.path.join(_cwd, "rust", "nedb-v2", "target", "release", n)
631
+ for n in _bin_names + _cargo_names]
632
+ )
633
+ _bin = next((p for p in _search if p and os.path.isfile(p)), None)
634
+
635
+ if _bin:
636
+ _ok(f"Found: {_bin}")
637
+ _ok("nedbd --dag is ready")
638
+ else:
639
+ _err("nedbd-v2 binary not found")
640
+ _warn(f"Searched: {_pkg_dir} | PATH | {_cargo_bin}")
641
+
642
+ # ── 4. cargo (Rust toolchain) ─────────────────────────────────────────────
643
+ _h("Rust toolchain")
644
+ _cargo_exe = _shutil.which("cargo")
645
+ if _cargo_exe:
646
+ try:
647
+ _cv = _sub.check_output([_cargo_exe, "--version"], stderr=_sub.DEVNULL,
648
+ timeout=5).decode().strip()
649
+ except Exception:
650
+ _cv = "(version unknown)"
651
+ _ok(f"cargo {_cv} → {_cargo_exe}")
652
+ has_cargo = True
653
+ else:
654
+ _err("cargo not found on PATH")
655
+ _warn("Install Rust: https://rustup.rs")
656
+ has_cargo = False
657
+
658
+ # ── 5. Fix plan ───────────────────────────────────────────────────────────
659
+ print()
660
+ _h("Fix plan")
661
+
662
+ step = 1
663
+ all_good = has_native and _bin
664
+
665
+ if all_good:
666
+ _ok("Everything is working. Commands to use:\n")
667
+ _cmd("start DAG server", f"nedbd --dag ./nedb-data")
668
+ _cmd("start AOF server", f"nedbd ./nedb-data")
669
+ _cmd("run a test (embedded)",f"python3 tests/test_the_will.py")
670
+ print()
671
+ return
672
+
673
+ # Binary missing
674
+ if not _bin:
675
+ print(f" {BOLD(f'Step {step}: Install the nedbd-v2 DAG server binary')}\n")
676
+ step += 1
677
+ if has_cargo:
678
+ _cmd("install from crates.io (recommended)",
679
+ "cargo install nedb-core-v2",
680
+ f"binary → {os.path.join(_cargo_bin, 'nedbd')}")
681
+ print()
682
+ _cmd("OR reinstall pip wheel (also bundles the binary)",
683
+ f"{_pip} install --force-reinstall --no-cache-dir nedb-engine")
684
+ else:
685
+ _cmd("reinstall pip wheel (bundles the binary)",
686
+ f"{_pip} install --force-reinstall --no-cache-dir nedb-engine")
687
+ print()
688
+ _warn("Or install Rust first (to build from source):")
689
+ if sys_pl == "win32" or is_msys2:
690
+ _cmd("", "winget install Rustlang.Rust.MSVC", "or visit https://rustup.rs")
691
+ else:
692
+ _cmd("", "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh")
693
+ print()
694
+
695
+ # _native missing
696
+ if not has_native:
697
+ print(f" {BOLD(f'Step {step}: Use the embedded Rust core (nedb._native)')}\n")
698
+ step += 1
699
+ if is_msys2:
700
+ print(f" {WARN} MSYS2/MinGW cannot load MSVC extensions — use HTTP mode:\n")
701
+ _data_dir = os.path.join(os.path.expanduser("~"), "nedb-data")
702
+ _dag_cmd = (_bin or "nedbd") + f" --dag {_data_dir}"
703
+ _cmd("terminal 1 — start the DAG server", _dag_cmd)
704
+ print()
705
+ _cmd("terminal 2 — run Python scripts with HTTP mode",
706
+ f"NEDB_URL=http://localhost:7070 python3 your_script.py")
707
+ print()
708
+ _cmd("test the will (HTTP mode)",
709
+ f"NEDB_URL=http://localhost:7070 python3 tests/test_the_will.py",
710
+ "18/18 checks — no _native needed")
711
+ else:
712
+ _cmd("reinstall to pull platform wheel with _native",
713
+ f"{_pip} install --force-reinstall --no-cache-dir nedb-engine")
714
+ print()
715
+
716
+ # Shell PATH tip
717
+ if _bin and _cargo_bin not in os.environ.get("PATH", ""):
718
+ print(f" {BOLD('Note:')} {_cargo_bin} may not be on your PATH yet.\n")
719
+ if sys_pl == "win32" or is_msys2:
720
+ _cmd("add to PATH permanently (Git Bash / MSYS2)",
721
+ f'echo \'export PATH="$PATH:{_cargo_bin}"\' >> ~/.bashrc && source ~/.bashrc')
722
+ else:
723
+ _cmd("add to PATH permanently",
724
+ f'echo \'export PATH="$PATH:{_cargo_bin}"\' >> ~/.profile && source ~/.profile')
725
+ print()
726
+
727
+ print(f" Run {CMD('nedbd --doctor')} again after installing to confirm everything is green.\n")
728
+
729
+
547
730
  def main() -> None:
548
731
  import argparse as _ap, signal, threading
549
732
  from .resp2 import make_resp2_server
@@ -568,8 +751,18 @@ def main() -> None:
568
751
  help="Run the v2 content-addressed DAG engine (Rust binary) instead of the v1 AOF engine. "
569
752
  "No AOF, no global lock, instant cold start. Env var NEDBD_DAG=1 also enables this.",
570
753
  )
754
+ parser.add_argument(
755
+ "--doctor", action="store_true",
756
+ help="Diagnose the NEDB environment — checks for native extension, DAG binary, "
757
+ "and prints platform-specific install instructions for anything missing.",
758
+ )
571
759
  args = parser.parse_args()
572
760
 
761
+ # ── Doctor mode ───────────────────────────────────────────────────────────
762
+ if args.doctor:
763
+ _run_doctor()
764
+ return
765
+
573
766
  # ── DAG mode: exec into the Rust v2 binary, replacing this process entirely ──
574
767
  if args.dag:
575
768
  import shutil as _shutil, subprocess as _sub, sys as _sys
@@ -605,12 +798,20 @@ def main() -> None:
605
798
  )
606
799
  _bin = next((c for c in _candidates if c and os.path.isfile(c)), None)
607
800
  if _bin is None:
608
- print("nedbd --dag: v2 Rust binary not found.", file=_sys.stderr)
609
- print(" Expected 'nedbd-v2' (or 'nedbd-v2.exe' on Windows) alongside the", file=_sys.stderr)
610
- print(" package or on PATH. Options:", file=_sys.stderr)
611
- print(" pip install --upgrade nedb-engine (platform wheel bundles the binary)", file=_sys.stderr)
612
- print(" cd rust/nedb-v2 && cargo build --release", file=_sys.stderr)
613
- print(" # then copy: nedbd-v2[.exe] to PATH or the nedb package dir", file=_sys.stderr)
801
+ print("", file=_sys.stderr)
802
+ print(" nedbd --dag: DAG engine binary not found.", file=_sys.stderr)
803
+ print("", file=_sys.stderr)
804
+ print(" The v2 content-addressed DAG engine (nedbd-v2) is a Rust binary that ships", file=_sys.stderr)
805
+ print(" alongside the Python package on supported platforms.", file=_sys.stderr)
806
+ print("", file=_sys.stderr)
807
+ print(" Run 'nedbd --doctor' for a full diagnosis and platform-specific fix:", file=_sys.stderr)
808
+ print("", file=_sys.stderr)
809
+ print(" nedbd --doctor", file=_sys.stderr)
810
+ print("", file=_sys.stderr)
811
+ print(" Quick fixes:", file=_sys.stderr)
812
+ print(" pip install --force-reinstall --no-cache-dir nedb-engine # re-install with binary", file=_sys.stderr)
813
+ print(" cargo install nedb-core-v2 # build from source (any platform)", file=_sys.stderr)
814
+ print("", file=_sys.stderr)
614
815
  _sys.exit(1)
615
816
  # Rust binary: nedbd-v2 [data_dir]
616
817
  # Port/token/TMK are passed via environment variables (not CLI flags).
Binary file
Binary file
File without changes
File without changes
File without changes