-
Notifications
You must be signed in to change notification settings - Fork 1
Introduce fastly-compute-py build tool #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6585961
Introduce fastly-compute-py build tool
posborne 6f923e6
Remove a few wasm binaries, remove stray debug changes from bottle-app
posborne 9ef0c17
Remove build-wheels action for now
posborne fec4f2c
Update rust verison used by CI
posborne b02977f
Bump viceroy to v0.16.3
posborne 4be77f8
Move python dependencies install to later in CI setup
posborne 5cb2227
Add nightly rust toolchain
posborne 4f28b51
Attempt to fix CI, add better caching for cpython builds
posborne 23ec1ea
Run CI workflow on all pushes and allow manual trigger
posborne b49f1bb
Add rustfmt and clippy back via new toolchain install method
posborne dc2f529
Fix ci failures, mostly allow-listing pyrefly
posborne a254abb
Separate out maturin build in CI, use DEV_MODE=0 for test
posborne 390f8ef
Remove py03 dependency from standalone binary package
posborne 760ee2d
Add --version to build tool
posborne f00b95d
Update examples uv.lock
posborne 43ab5ca
Optimize caching to include componentize-py git checkouts
posborne fd4ee49
Fix Makefile default EXAMPLE name for bottle-app
posborne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,3 +7,9 @@ __pycache__ | |
|
|
||
| # Build artifacts | ||
| /build/ | ||
| bin/ | ||
|
|
||
| # Rust | ||
| target/ | ||
| *.so | ||
| target/ | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| [submodule "vendor/wasiless"] | ||
| path = vendor/wasiless | ||
| [submodule "crates/wasiless"] | ||
| path = crates/wasiless | ||
| url = git@github.com:fastly/wasiless.git |
This file contains hidden or 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,143 @@ | ||
| # Contributing to Fastly Compute Python SDK | ||
|
|
||
| Thank you for your interest in contributing! This guide will help you get set up for development. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Required Tools | ||
|
|
||
| The build process requires several tools to be installed: | ||
|
|
||
| 1. **Python 3.12+** | ||
| ```bash | ||
| python --version # Should be 3.12 or higher | ||
| ``` | ||
|
|
||
| 2. **uv** - Python package manager | ||
| 3. **Rust toolchain** (stable) | ||
| 4. **wasm32-unknown-unknown target** (required by build.rs) | ||
| ```bash | ||
| rustup target add wasm32-unknown-unknown | ||
| ``` | ||
|
|
||
| 5. **wasm-tools** (required by build.rs for WIT merging and componentization) | ||
| 6. **Viceroy** - Fastly's local testing server | ||
|
|
||
| ## Getting Started | ||
|
|
||
| 1. **Clone the repository** | ||
| ```bash | ||
| git clone <repo-url> | ||
| cd compute-sdk-python/build-tool-impl | ||
| ``` | ||
|
|
||
| 2. **Initialize submodules** (if applicable) | ||
| ```bash | ||
| git submodule update --init --recursive | ||
| ``` | ||
|
|
||
| 3. **Install Python dependencies** | ||
| ```bash | ||
| uv sync --extra dev --extra test | ||
| ``` | ||
|
|
||
| 4. **Verify setup** | ||
| ```bash | ||
| make help # Should show available commands | ||
| ``` | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| ### Building Examples | ||
|
|
||
| The default development workflow uses `cargo run` which automatically picks up Rust changes: | ||
|
|
||
| ```bash | ||
| # Build an example | ||
| make build/bottle-app.composed.wasm | ||
|
|
||
| # Build all examples | ||
| make | ||
|
|
||
| # Serve an example for testing | ||
| make serve EXAMPLE=bottle-app | ||
| ``` | ||
|
|
||
| ### Making Changes to the Build Tool | ||
|
|
||
| The build tool is in `crates/fastly-compute-py/`. When you make changes: | ||
|
|
||
| ```bash | ||
| # The build system automatically rebuilds via `cargo run` | ||
| make build/bottle-app.composed.wasm | ||
|
|
||
| # Or test the installed entry point | ||
| make DEV_MODE=0 build/bottle-app.composed.wasm | ||
| ``` | ||
|
|
||
| ### Code Quality | ||
|
|
||
| ```bash | ||
| # Format code (Python + Rust) | ||
| make format | ||
|
|
||
| # Check formatting | ||
| make format-check | ||
|
|
||
| # Run linters (Python + Rust) | ||
| make lint | ||
|
|
||
| # Auto-fix linting issues | ||
| make lint-fix | ||
| ``` | ||
|
|
||
| ### Testing | ||
|
|
||
| ```bash | ||
| # Run all tests | ||
| make test | ||
|
|
||
| # Update snapshot tests | ||
| make test-update-snapshots | ||
| ``` | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| . | ||
| ├── crates/ | ||
| │ ├── fastly-compute-py/ # Rust build tool | ||
| │ │ ├── build.rs # Build script (requires wasm-tools) | ||
| │ │ └── src/ | ||
| │ └── wasiless/ # WASM component for WASI removal | ||
| ├── examples/ # Example applications | ||
| │ ├── bottle-app/ | ||
| │ ├── flask-app/ | ||
| │ └── ... | ||
| ├── fastly_compute/ # Python SDK | ||
| ├── wit/ # WIT (WebAssembly Interface Type) definitions | ||
| └── tests/ # Integration tests | ||
| ``` | ||
|
|
||
| ## Build Process | ||
|
|
||
| Understanding the build process helps when debugging issues: | ||
|
|
||
| 1. **build.rs runs** (during Rust compilation): | ||
| - Calls `wasm-tools component wit` to merge WIT files | ||
| - Builds `wasiless` crate for wasm32-unknown-unknown | ||
| - Calls `wasm-tools component new` to componentize wasiless | ||
|
|
||
| 2. **fastly-compute-py runs**: | ||
| - Resolves Python dependencies from virtualenv | ||
| - Calls `componentize-py` to build Python WASM component | ||
| - Composes with wasiless using WAC | ||
|
|
||
| ## Continuous Integration | ||
|
|
||
| Our CI builds wheels for multiple platforms: | ||
| - Linux: x86_64, aarch64 | ||
| - macOS: x86_64 (Intel), aarch64 (Apple Silicon) | ||
| - Windows: x86_64 | ||
|
|
||
| The CI workflow (`.github/workflows/build-wheels.yml`) ensures all required tools are installed automatically. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is planned but I have now removed it from this PR, at least until I can get it working separate from this changeset. I have built packages locally just fine.