Skip to content
Merged
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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ dmypy.json
.install.stamp

# Sync version of the library, via Unasync
redis_om/
# Note: redis_om/ contains placeholder files that ARE tracked:
# - README.md (documentation)
# - __init__.py (so Poetry recognizes it as a package)
# All other files in redis_om/ are generated by `make sync` and ignored.
redis_om/*
!redis_om/README.md
!redis_om/__init__.py
tests_sync/

# Apple Files
Expand Down
27 changes: 26 additions & 1 deletion make_sync.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import os
import re
import shutil
from pathlib import Path

import unasync

# Files to preserve in redis_om/ directory (not overwritten by sync)
PRESERVED_FILES = {"README.md"}

ADDITIONAL_REPLACEMENTS = {
"aredis_om": "redis_om",
"async_redis": "sync_redis",
Expand All @@ -14,7 +18,28 @@
}


def clean_generated_dir(dirpath: Path, preserved: set):
"""Remove generated files from a directory while preserving specified files."""
if not dirpath.exists():
return
for item in dirpath.iterdir():
if item.name in preserved:
continue
if item.is_dir():
shutil.rmtree(item)
else:
item.unlink()


def main():
base_dir = Path(__file__).absolute().parent

# Clean generated directories before regenerating (preserve README.md)
redis_om_dir = base_dir / "redis_om"
tests_sync_dir = base_dir / "tests_sync"
clean_generated_dir(redis_om_dir, PRESERVED_FILES)
clean_generated_dir(tests_sync_dir, set())

rules = [
unasync.Rule(
fromdir="/aredis_om/",
Expand All @@ -28,7 +53,7 @@ def main():
),
]
filepaths = []
for root, _, filenames in os.walk(Path(__file__).absolute().parent):
for root, _, filenames in os.walk(base_dir):
for filename in filenames:
if filename.rpartition(".")[-1] in (
"py",
Expand Down
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ readme = "README.md"
repository = "https://github.com/redis/redis-om-python"
packages = [
{ "include" = "aredis_om" },
{ "include" = "redis_om" },
]
classifiers = [
"Development Status :: 3 - Alpha",
Expand All @@ -25,10 +26,10 @@ classifiers = [
'Programming Language :: Python :: 3.13',
'Programming Language :: Python',
]
include=[
"docs/*",
"images/*",
"redis_om/**/*",
# Include redis_om (generated by make sync) in wheel builds.
# This overrides .gitignore which excludes these files from version control.
include = [
{ path = "redis_om/**/*", format = ["sdist", "wheel"] },
]

[tool.poetry.urls]
Expand Down
20 changes: 20 additions & 0 deletions redis_om/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# redis_om - Sync Version (Auto-Generated)

This directory contains the **synchronous version** of redis-om-python.

## Important Notes

1. **Do not edit files in this directory directly** - they are auto-generated from `aredis_om/` using [unasync](https://github.com/python-trio/unasync).

2. **To regenerate**: Run `make sync` from the project root.

3. **Why this README exists**: This placeholder file allows the `redis_om` package to be declared in `pyproject.toml` for Poetry 2.0+ compatibility, which requires package directories to exist at install time.

4. **All other files are gitignored**: Only this README is tracked in git. The actual Python files are generated and ignored.

## Development Workflow

1. Make changes in `aredis_om/` (the async version)
2. Run `make sync` to generate the sync version
3. Run tests for both versions

5 changes: 5 additions & 0 deletions redis_om/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Placeholder __init__.py for Poetry package recognition.
# This file is overwritten by `make sync` - see redis_om/README.md for details.
#
# The actual exports are generated from aredis_om/__init__.py.
# Run `make sync` to generate the full sync version of the library.
Loading