Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ config = PGliteConfig(
timeout=60, # Extended timeout for CI/CD
log_level="INFO", # Balanced logging
cleanup_on_exit=True, # Automatic cleanup
work_dir=Path("./test-data") # Custom directory
work_dir=Path("./test-data"), # Custom directory
node_modules_dir=Path("/tmp/py-pglite-npm") # One npm install shared by all workers
)

with SQLAlchemyPGliteManager(config) as manager:
Expand Down
9 changes: 9 additions & 0 deletions src/py_pglite/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class PGliteConfig:
work_dir: Working directory for PGlite files (default: None, uses temp)
node_modules_check: Whether to verify node_modules exists (default: True)
auto_install_deps: Whether to auto-install npm dependencies (default: True)
node_modules_dir: Directory to install npm dependencies into once and
share across work directories (for example across pytest-xdist
workers). When set, npm installs run in this directory, guarded
by a file lock, and each work directory gets a ``node_modules``
link to it. Default: None (install into each work directory).
extensions: List of PGlite extensions to enable (e.g., ["pgvector"])
node_options: Custom NODE_OPTIONS for the Node.js process
use_tcp: Use TCP socket instead of Unix domain socket (default: False)
Expand All @@ -49,6 +54,7 @@ class PGliteConfig:
work_dir: Path | None = None
node_modules_check: bool = True
auto_install_deps: bool = True
node_modules_dir: Path | None = None
extensions: list[str] | None = None
node_options: str | None = None
use_tcp: bool = False
Expand All @@ -74,6 +80,9 @@ def __post_init__(self) -> None:
if self.work_dir is not None:
self.work_dir = Path(self.work_dir).resolve()

if self.node_modules_dir is not None:
self.node_modules_dir = Path(self.node_modules_dir).resolve()

# Validate TCP configuration
if self.use_tcp:
if not (1 <= self.tcp_port <= 65535):
Expand Down
5 changes: 4 additions & 1 deletion src/py_pglite/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"""

SUPPORTED_EXTENSIONS: dict[str, dict[str, str]] = {
"pgvector": {"module": "@electric-sql/pglite/vector", "name": "vector"},
"pgvector": {
"module": "@electric-sql/pglite-pgvector",
"name": "vector",
},
"pg_trgm": {"module": "@electric-sql/pglite/contrib/pg_trgm", "name": "pg_trgm"},
"btree_gin": {
"module": "@electric-sql/pglite/contrib/btree_gin",
Expand Down
Loading