Skip to content

Commit 82b917c

Browse files
abrookinsdotlambda
andauthored
Include redis_om package for Poetry 2.0+ compatibility (#740)
* include redis_om package * Add redis_om placeholder for Poetry 2.0+ compatibility - Add redis_om/README.md placeholder so package directory exists - Update .gitignore to track README.md but ignore generated files - Update make_sync.py to preserve README.md when regenerating * Add placeholder __init__.py so Poetry recognizes redis_om as a package * Fix wheel packaging to include redis_om and exclude docs/images - Add redis_om to packages AND include with format=[sdist, wheel] to override .gitignore exclusion - Remove docs/* and images/* from include (shouldn't be in wheels) Fixes all issues from #713: 1. redis_om/ missing from wheel 2. docs/ and images/ incorrectly in wheel 3. python-ulid already updated in prior commit Closes #713 Closes #731 --------- Co-authored-by: dotlambda <[email protected]>
1 parent cfa363b commit 82b917c

File tree

5 files changed

+63
-6
lines changed

5 files changed

+63
-6
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ dmypy.json
134134
.install.stamp
135135

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

140146
# Apple Files

make_sync.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import os
22
import re
3+
import shutil
34
from pathlib import Path
45

56
import unasync
67

8+
# Files to preserve in redis_om/ directory (not overwritten by sync)
9+
PRESERVED_FILES = {"README.md"}
10+
711
ADDITIONAL_REPLACEMENTS = {
812
"aredis_om": "redis_om",
913
"async_redis": "sync_redis",
@@ -14,7 +18,28 @@
1418
}
1519

1620

21+
def clean_generated_dir(dirpath: Path, preserved: set):
22+
"""Remove generated files from a directory while preserving specified files."""
23+
if not dirpath.exists():
24+
return
25+
for item in dirpath.iterdir():
26+
if item.name in preserved:
27+
continue
28+
if item.is_dir():
29+
shutil.rmtree(item)
30+
else:
31+
item.unlink()
32+
33+
1734
def main():
35+
base_dir = Path(__file__).absolute().parent
36+
37+
# Clean generated directories before regenerating (preserve README.md)
38+
redis_om_dir = base_dir / "redis_om"
39+
tests_sync_dir = base_dir / "tests_sync"
40+
clean_generated_dir(redis_om_dir, PRESERVED_FILES)
41+
clean_generated_dir(tests_sync_dir, set())
42+
1843
rules = [
1944
unasync.Rule(
2045
fromdir="/aredis_om/",
@@ -28,7 +53,7 @@ def main():
2853
),
2954
]
3055
filepaths = []
31-
for root, _, filenames in os.walk(Path(__file__).absolute().parent):
56+
for root, _, filenames in os.walk(base_dir):
3257
for filename in filenames:
3358
if filename.rpartition(".")[-1] in (
3459
"py",

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ readme = "README.md"
99
repository = "https://github.com/redis/redis-om-python"
1010
packages = [
1111
{ "include" = "aredis_om" },
12+
{ "include" = "redis_om" },
1213
]
1314
classifiers = [
1415
"Development Status :: 3 - Alpha",
@@ -25,10 +26,10 @@ classifiers = [
2526
'Programming Language :: Python :: 3.13',
2627
'Programming Language :: Python',
2728
]
28-
include=[
29-
"docs/*",
30-
"images/*",
31-
"redis_om/**/*",
29+
# Include redis_om (generated by make sync) in wheel builds.
30+
# This overrides .gitignore which excludes these files from version control.
31+
include = [
32+
{ path = "redis_om/**/*", format = ["sdist", "wheel"] },
3233
]
3334

3435
[tool.poetry.urls]

redis_om/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# redis_om - Sync Version (Auto-Generated)
2+
3+
This directory contains the **synchronous version** of redis-om-python.
4+
5+
## Important Notes
6+
7+
1. **Do not edit files in this directory directly** - they are auto-generated from `aredis_om/` using [unasync](https://github.com/python-trio/unasync).
8+
9+
2. **To regenerate**: Run `make sync` from the project root.
10+
11+
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.
12+
13+
4. **All other files are gitignored**: Only this README is tracked in git. The actual Python files are generated and ignored.
14+
15+
## Development Workflow
16+
17+
1. Make changes in `aredis_om/` (the async version)
18+
2. Run `make sync` to generate the sync version
19+
3. Run tests for both versions
20+

redis_om/__init__.py

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

0 commit comments

Comments
 (0)