-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): Support run typescript in lyric (#3)
- Loading branch information
Showing
26 changed files
with
663 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# python generated files | ||
__pycache__/ | ||
*.py[oc] | ||
build/ | ||
dist/ | ||
wheels/ | ||
*.egg-info | ||
|
||
# venv | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.10.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
SHELL=/bin/bash | ||
VENV = .venv | ||
|
||
# Detect the operating system and set the virtualenv bin directory | ||
ifeq ($(OS),Windows_NT) | ||
VENV_BIN=$(VENV)/Scripts | ||
else | ||
VENV_BIN=$(VENV)/bin | ||
endif | ||
|
||
setup: $(VENV)/bin/activate | ||
|
||
$(VENV)/bin/activate: $(VENV)/.venv-timestamp | ||
|
||
$(VENV)/.venv-timestamp: | ||
# Create new virtual environment if setup.py has changed | ||
python3 -m venv $(VENV) | ||
$(VENV_BIN)/pip install --upgrade pip | ||
touch $(VENV)/.venv-timestamp | ||
|
||
.PYHONY: build-task | ||
build-task: setup | ||
# to src directory and run setup.py | ||
cd ../lyric-task && rye build | ||
$(VENV_BIN)/pip install --force-reinstall ../dist/lyric_task-*.whl | ||
|
||
.PHONY: build-wasm | ||
build-wasm: build-task | ||
# Activate virtual environment and run setup.py | ||
# to src directory and run setup.py | ||
cd ../../../components/rust/component-ts-transpiling && cargo build --release --target wasm32-wasip1 | ||
cp ../../../target/wasm32-wasip1/release/component_ts_transpiling.wasm src/lyric_component_ts_transpiling | ||
|
||
.PHONY: build | ||
build: build-wasm | ||
rye build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# lyric-component-ts-transpiling | ||
|
||
Python wrapper for the [component-ts-transpiling](../../../components/rust/component-ts-transpiling/README.md) | ||
wasi library. |
29 changes: 29 additions & 0 deletions
29
bindings/python/lyric-component-ts-transpiling/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[project] | ||
name = "lyric-component-ts-transpiling" | ||
version = "0.1.0" | ||
description = "Add your description here" | ||
authors = [ | ||
{ name = "Fangyin Cheng", email = "staneyffer@gmail.com" } | ||
] | ||
dependencies = [ | ||
"lyric-task", | ||
] | ||
readme = "README.md" | ||
requires-python = ">= 3.10" | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[tool.rye] | ||
managed = true | ||
dev-dependencies = [] | ||
|
||
[tool.hatch.metadata] | ||
allow-direct-references = true | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["src/lyric_component_ts_transpiling"] | ||
include = [ | ||
"src/lyric_component_ts_transpiling/*.wasm", | ||
] |
16 changes: 16 additions & 0 deletions
16
...ings/python/lyric-component-ts-transpiling/src/lyric_component_ts_transpiling/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Wrapper for the TypeScript transpiling WebAssembly module. | ||
May be we should find a better way to install the wasm file, but for now we just pypi | ||
install the package and the wasm file is included in the package. | ||
""" | ||
|
||
from importlib.resources import files | ||
from lyric_task import WasmTaskSpec, Language | ||
|
||
def get_wasm_path(): | ||
return files('lyric_component_ts_transpiling').joinpath('component_ts_transpiling.wasm') | ||
|
||
|
||
class TypeScriptWasmTaskSpec(WasmTaskSpec): | ||
def __init__(self): | ||
super().__init__(str(get_wasm_path()), Language.WASI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.