Skip to content

Commit 617144d

Browse files
author
Test User
committed
docs: add WASM web demo shield and release
1 parent 5aa0da6 commit 617144d

3 files changed

Lines changed: 31 additions & 10 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cdd-python-all
22
==============
33
[![License](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4+
[![interactive WASM web demo](https://img.shields.io/badge/interactive-WASM_web_demo-blue.svg)](https://offscale.io/wasm_web_demo)
45
[![CI](https://github.com/offscale/cdd-python-all/actions/workflows/ci.yml/badge.svg)](https://github.com/offscale/cdd-python-all/actions)
56
[![Test Coverage](https://img.shields.io/badge/test_coverage-99%25-brightgreen.svg)](#)
67
[![Doc Coverage](https://img.shields.io/badge/doc_coverage-100%25-brightgreen.svg)](#)

‎scripts/build_wasm.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import os
22
import subprocess
33

4+
45
def main():
56
os.makedirs("bin", exist_ok=True)
67
wasm_out = os.path.join("bin", "cdd-python-all.wasm")
7-
8+
89
try:
910
print("Building WASI...")
10-
subprocess.run(["uv", "run", "py2wasm", "src/openapi_client/cli.py", "-o", wasm_out], check=True)
11+
subprocess.run(
12+
["uv", "run", "py2wasm", "src/openapi_client/cli.py", "-o", wasm_out],
13+
check=True,
14+
)
1115
except subprocess.CalledProcessError:
1216
print("WASI build failed. Falling back to Pyodide zip bundle.")
1317
if os.path.exists(wasm_out):
1418
os.remove(wasm_out)
15-
19+
1620
# Cross-platform zip
1721
import zipfile
18-
with zipfile.ZipFile(wasm_out, 'w', zipfile.ZIP_DEFLATED) as zipf:
22+
23+
with zipfile.ZipFile(wasm_out, "w", zipfile.ZIP_DEFLATED) as zipf:
1924
for root, dirs, files in os.walk("src"):
2025
for file in files:
2126
if "__pycache__" not in root and file.endswith(".py"):
@@ -24,5 +29,6 @@ def main():
2429
if os.path.exists("pyproject.toml"):
2530
zipf.write("pyproject.toml", "pyproject.toml")
2631

32+
2733
if __name__ == "__main__":
2834
main()

‎scripts/run_petstore_test.py‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,43 @@
33
import shutil
44
import subprocess
55

6+
67
def main():
7-
test_harness_dir = os.environ.get("TEST_HARNESS_DIR", os.path.expanduser("~/repos/cdd-openapi-test-harness"))
8-
8+
test_harness_dir = os.environ.get(
9+
"TEST_HARNESS_DIR", os.path.expanduser("~/repos/cdd-openapi-test-harness")
10+
)
11+
912
if len(sys.argv) < 3:
1013
print("Usage: run_petstore_test.py <json_file> <tmp_dir>")
1114
sys.exit(1)
12-
15+
1316
json_file = sys.argv[1]
1417
tmp_dir = sys.argv[2]
15-
18+
1619
input_path = os.path.join(test_harness_dir, json_file)
1720
if not os.path.exists(input_path):
1821
print(f"Skipping test, missing {input_path}")
1922
sys.exit(0)
2023

21-
cmd = ["uv", "run", "cdd-python", "from_openapi", "to_sdk_cli", "-i", input_path, "-o", tmp_dir]
22-
24+
cmd = [
25+
"uv",
26+
"run",
27+
"cdd-python",
28+
"from_openapi",
29+
"to_sdk_cli",
30+
"-i",
31+
input_path,
32+
"-o",
33+
tmp_dir,
34+
]
35+
2336
try:
2437
print(f"Running petstore test against {input_path} -> {tmp_dir}")
2538
subprocess.run(cmd, check=True)
2639
finally:
2740
if os.path.exists(tmp_dir):
2841
shutil.rmtree(tmp_dir)
2942

43+
3044
if __name__ == "__main__":
3145
main()

0 commit comments

Comments
 (0)