Skip to content

Commit 43a7d49

Browse files
authored
Fix packaging bug: include generated sync code in wheel (v1.0.6) (#803)
Fix packaging bug: include generated sync code in wheel - Add artifacts option to pyproject.toml so hatchling includes redis_om/ files that are in .gitignore (generated by make sync) - Fix supports_hash_field_expiration() to check sync Redis class in generated sync code via post-processing in make_sync.py - Bump version to 1.0.6
1 parent 2a27d48 commit 43a7d49

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

make_sync.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"AsyncMock": "Mock",
1818
# RedisVL uses SearchIndex for sync, not SyncSearchIndex
1919
"AsyncSearchIndex": "SearchIndex",
20+
# Fix supports_hash_field_expiration to check sync Redis class
21+
"redis_lib.asyncio.Redis": "redis_lib.Redis",
2022
}
2123

2224

@@ -75,39 +77,39 @@ def main():
7577
"redis_om/model/cli/migrate_data.py",
7678
"redis_om/model/cli/migrate.py"
7779
]
78-
80+
7981
for cli_file in cli_files:
8082
file_path = Path(__file__).absolute().parent / cli_file
8183
if file_path.exists():
8284
with open(file_path, 'r') as f:
8385
content = f.read()
84-
86+
8587
# Remove run_async() call wrappers (not the function definition)
8688
# Only match run_async() calls that are not function definitions
8789
def remove_run_async_call(match):
8890
inner_content = match.group(1)
8991
return inner_content
90-
92+
9193
# Pattern to match run_async() function calls (not definitions)
9294
# Look for = or return statements followed by run_async(...)
9395
lines = content.split('\n')
9496
new_lines = []
95-
97+
9698
for line in lines:
9799
# Skip function definitions
98100
if 'def run_async(' in line:
99101
new_lines.append(line)
100102
continue
101-
103+
102104
# Replace run_async() calls
103105
if 'run_async(' in line and ('=' in line or 'return ' in line or line.strip().startswith('run_async(')):
104106
# Simple pattern for function calls
105107
line = re.sub(r'run_async\(([^)]+(?:\([^)]*\)[^)]*)*)\)', r'\1', line)
106-
108+
107109
new_lines.append(line)
108-
110+
109111
content = '\n'.join(new_lines)
110-
112+
111113
with open(file_path, 'w') as f:
112114
f.write(content)
113115

@@ -117,6 +119,13 @@ def remove_run_async_call(match):
117119
with open(model_file, 'r') as f:
118120
content = f.read()
119121

122+
# Fix supports_hash_field_expiration to check sync Redis class
123+
# The unasync replacement doesn't work for dotted attribute access
124+
content = content.replace(
125+
'redis_lib.asyncio.Redis',
126+
'redis_lib.Redis'
127+
)
128+
120129
# Fix Pipeline import: redis.asyncio.client -> redis.client
121130
content = content.replace(
122131
'from redis.asyncio.client import Pipeline',

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "redis-om"
3-
version = "1.0.5"
3+
version = "1.0.6"
44
description = "Object mappings, and more, for Redis."
55
authors = [{ name = "Redis OSS", email = "oss@redis.com" }]
66
maintainers = [{ name = "Redis OSS", email = "oss@redis.com" }]
@@ -81,12 +81,23 @@ build-backend = "hatchling.build"
8181

8282
[tool.hatch.build.targets.wheel]
8383
packages = ["aredis_om", "redis_om"]
84+
# Include generated sync code (redis_om/) that is in .gitignore
85+
# These files are created by `make sync` before building
86+
artifacts = [
87+
"redis_om/**/*",
88+
"tests_sync/**/*",
89+
]
8490

8591
[tool.hatch.build.targets.sdist]
8692
include = [
8793
"aredis_om/**/*",
8894
"redis_om/**/*",
8995
]
96+
# Include generated sync code (redis_om/) that is in .gitignore
97+
artifacts = [
98+
"redis_om/**/*",
99+
"tests_sync/**/*",
100+
]
90101

91102

92103

0 commit comments

Comments
 (0)