Skip to content

Commit 9cb682c

Browse files
authored
Add commands and tests + fix tests that were using asyncio (#3793)
* added sync commands and tests Signed-off-by: Lior Sventitzky <[email protected]> * fixes to tests that were using asyncio Signed-off-by: Lior Sventitzky <[email protected]> * lint fix Signed-off-by: Lior Sventitzky <[email protected]> * fixed client name and version Signed-off-by: Lior Sventitzky <[email protected]> * addressed comments Signed-off-by: Lior Sventitzky <[email protected]> * addressed final comments Signed-off-by: Lior Sventitzky <[email protected]> --------- Signed-off-by: Lior Sventitzky <[email protected]>
1 parent f433222 commit 9cb682c

File tree

7 files changed

+18403
-52
lines changed

7 files changed

+18403
-52
lines changed

ffi/.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[env]
2-
GLIDE_NAME = { value = "GlideFFI", force = true }
2+
GLIDE_NAME = "GlideFFI"
33
GLIDE_VERSION = "0.1.0"
44
# Suppress error
55
# > ... was built for newer 'macOS' version (14.5) than being linked (14.0)

python/dev.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def find_project_root() -> Path:
2626
VENV_BIN_DIR = VENV_DIR / "bin"
2727
PYTHON_EXE = VENV_BIN_DIR / "python"
2828
FFI_DIR = GLIDE_ROOT / "ffi"
29+
GLIDE_SYNC_NAME = "GlidePySync"
30+
GLIDE_ASYNC_NAME = "GlidePy"
2931

3032

3133
def check_dependencies() -> None:
@@ -129,26 +131,48 @@ def generate_protobuf_files() -> None:
129131
print(f"[OK] Protobuf files (.py + .pyi) generated at: {proto_dst}")
130132

131133

132-
def build_async_client(release: bool, no_cache: bool = False) -> None:
134+
def build_async_client(
135+
glide_version: str, release: bool, no_cache: bool = False
136+
) -> None:
133137
print(
134-
f"[INFO] Building async client in {'release' if release else 'debug'} mode..."
138+
f"[INFO] Building async client with version={glide_version} in {'release' if release else 'debug'} mode..."
135139
)
136140
env = activate_venv(no_cache)
141+
env.update(
142+
{ # Update it with your GLIDE variables
143+
"GLIDE_NAME": GLIDE_ASYNC_NAME,
144+
"GLIDE_VERSION": glide_version,
145+
}
146+
)
137147
generate_protobuf_files()
138148

139149
cmd = [str(PYTHON_EXE), "-m", "maturin", "develop"]
140150
if release:
141151
cmd += ["--release", "--strip"]
142152

143-
run_command(cmd, cwd=PYTHON_DIR, env=env, label="maturin develop")
153+
run_command(
154+
cmd,
155+
cwd=PYTHON_DIR,
156+
env=env,
157+
label="maturin develop",
158+
)
144159
print("[OK] Async client build completed")
145160

146161

147-
def build_sync_client() -> None:
148-
print("[INFO] Building sync client...")
162+
def build_sync_client(glide_version: str) -> None:
163+
print(f"[INFO] Building sync client with version={glide_version}...")
149164
generate_protobuf_files()
150165

151-
run_command(["cargo", "build"], cwd=FFI_DIR, label="cargo build ffi")
166+
run_command(
167+
["cargo", "build"],
168+
cwd=FFI_DIR,
169+
label="cargo build ffi",
170+
env={
171+
"GLIDE_NAME": GLIDE_SYNC_NAME,
172+
"GLIDE_VERSION": glide_version,
173+
**os.environ,
174+
},
175+
)
152176

153177
print("[OK] Sync client build completed")
154178

@@ -255,6 +279,12 @@ def main() -> None:
255279
action="store_true",
256280
help="Install Python dependencies without cache",
257281
)
282+
build_parser.add_argument(
283+
"--glide-version",
284+
type=str,
285+
default="unknown",
286+
help="Specify the client version that will be used for server identification and displayed in CLIENT INFO output",
287+
)
258288

259289
subparsers.add_parser(
260290
"protobuf", help="Generate Python protobuf files including .pyi stubs"
@@ -295,10 +325,10 @@ def main() -> None:
295325
no_cache = args.no_cache
296326
if args.client in ["async", "all"]:
297327
print(f"🛠 Building async client ({args.mode} mode)...")
298-
build_async_client(release, no_cache)
328+
build_async_client(args.glide_version, release, no_cache)
299329
if args.client in ["sync", "all"]:
300330
print("🛠 Building sync client...")
301-
build_sync_client()
331+
build_sync_client(glide_version=args.glide_version)
302332

303333
print("[✅ DONE] Task completed successfully.")
304334

0 commit comments

Comments
 (0)