diff --git a/.github/workflows/release-jupyter.yml b/.github/workflows/release-jupyter.yml new file mode 100644 index 00000000..d1815594 --- /dev/null +++ b/.github/workflows/release-jupyter.yml @@ -0,0 +1,218 @@ +name: Jupyter Kernel Release + +on: + push: + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: read + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install tree-sitter-cli + run: npm install -g tree-sitter-cli + + - name: Generate parser + working-directory: tree-sitter-ggsql + run: tree-sitter generate + + - uses: actions/upload-artifact@v4 + with: + name: tree-sitter-generated + path: tree-sitter-ggsql/src/ + + linux: + needs: generate + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64, aarch64] + env: + GGSQL_SKIP_GENERATE: "1" + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: tree-sitter-generated + path: tree-sitter-ggsql/src/ + + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + working-directory: ggsql-jupyter + manylinux: 2_28 + docker-options: -e GGSQL_SKIP_GENERATE=1 + + - uses: actions/upload-artifact@v4 + with: + name: jupyter-wheels-linux-${{ matrix.target }} + path: ggsql-jupyter/dist + + macos: + needs: generate + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - target: x86_64 + runner: macos-latest + - target: aarch64 + runner: macos-latest + env: + GGSQL_SKIP_GENERATE: "1" + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: tree-sitter-generated + path: tree-sitter-ggsql/src/ + + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist + working-directory: ggsql-jupyter + + - uses: actions/upload-artifact@v4 + with: + name: jupyter-wheels-macos-${{ matrix.target }} + path: ggsql-jupyter/dist + + windows: + needs: generate + runs-on: windows-latest + env: + GGSQL_SKIP_GENERATE: "1" + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: tree-sitter-generated + path: tree-sitter-ggsql/src/ + + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: x64 + args: --release --out dist + working-directory: ggsql-jupyter + + - uses: actions/upload-artifact@v4 + with: + name: jupyter-wheels-windows-x64 + path: ggsql-jupyter/dist + + sdist: + needs: generate + runs-on: ubuntu-latest + env: + GGSQL_SKIP_GENERATE: "1" + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: tree-sitter-generated + path: tree-sitter-ggsql/src/ + + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + working-directory: ggsql-jupyter + + - uses: actions/upload-artifact@v4 + with: + name: jupyter-wheels-sdist + path: ggsql-jupyter/dist + + publish: + needs: [linux, macos, windows, sdist] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + environment: pypi-jupyter + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + pattern: jupyter-wheels-* + merge-multiple: true + path: dist + + - name: List wheels + run: ls -lh dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + needs: [linux, macos, windows] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + steps: + - uses: actions/download-artifact@v4 + with: + pattern: jupyter-wheels-* + path: artifacts + + - name: Extract binaries from wheels + run: | + mkdir -p binaries + + # Linux x86_64 + unzip -j artifacts/jupyter-wheels-linux-x86_64/*manylinux*x86_64*.whl \ + "*.data/scripts/ggsql-jupyter" -d /tmp/extract + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-linux-x64 + rm -rf /tmp/extract + + # Linux aarch64 + unzip -j artifacts/jupyter-wheels-linux-aarch64/*manylinux*aarch64*.whl \ + "*.data/scripts/ggsql-jupyter" -d /tmp/extract + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-linux-arm64 + rm -rf /tmp/extract + + # macOS x86_64 + unzip -j artifacts/jupyter-wheels-macos-x86_64/*macosx*x86_64*.whl \ + "*.data/scripts/ggsql-jupyter" -d /tmp/extract + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-macos-x64 + rm -rf /tmp/extract + + # macOS aarch64 + unzip -j artifacts/jupyter-wheels-macos-aarch64/*macosx*arm64*.whl \ + "*.data/scripts/ggsql-jupyter" -d /tmp/extract + mv /tmp/extract/ggsql-jupyter binaries/ggsql-jupyter-macos-arm64 + rm -rf /tmp/extract + + # Windows x64 + unzip -j artifacts/jupyter-wheels-windows-x64/*win_amd64*.whl \ + "*.data/scripts/ggsql-jupyter.exe" -d /tmp/extract + mv /tmp/extract/ggsql-jupyter.exe binaries/ggsql-jupyter-windows-x64.exe + rm -rf /tmp/extract + + chmod +x binaries/ggsql-jupyter-* + ls -lh binaries/ + + - name: Upload to GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: binaries/* diff --git a/.github/workflows/python-release.yml b/.github/workflows/release-python.yml similarity index 100% rename from .github/workflows/python-release.yml rename to .github/workflows/release-python.yml diff --git a/.github/workflows/vscode.yaml b/.github/workflows/release-vscode.yaml similarity index 100% rename from .github/workflows/vscode.yaml rename to .github/workflows/release-vscode.yaml diff --git a/ggsql-jupyter/README.md b/ggsql-jupyter/README.md index 28b563af..9e4eede4 100644 --- a/ggsql-jupyter/README.md +++ b/ggsql-jupyter/README.md @@ -19,63 +19,55 @@ The ggsql Jupyter kernel enables you to run ggsql queries directly in Jupyter no ### Prerequisites - Jupyter Lab or Notebook installed -- Python 3.8+ (for Jupyter) -### Option 1: Install from crates.io (Recommended) +### Option 1: Install from PyPI (Recommended) -If you have Rust installed: +The easiest way to install the ggsql kernel is from PyPI. This provides pre-built binaries for Linux, macOS, and Windows. + +Using pip: ```bash -cargo install ggsql-jupyter +pip install ggsql-jupyter ggsql-jupyter --install ``` -This will: - -1. Download and compile the kernel -2. Install it into your current environment (respects virtualenvs, conda, uv) - -### Option 2: Download Pre-built Binary from GitHub Releases +Using [uv](https://docs.astral.sh/uv/): -For users without Rust: - -1. **Download the binary** for your platform from [GitHub Releases](https://github.com/georgestagg/ggsql/releases) - - - Linux: `ggsql-jupyter-linux-x64` - - macOS (Intel): `ggsql-jupyter-macos-x64` - - macOS (Apple Silicon): `ggsql-jupyter-macos-arm64` - - Windows: `ggsql-jupyter-windows-x64.exe` +```bash +uv tool install ggsql-jupyter +ggsql-jupyter --install +``` -2. **Rename and make executable** (Linux/macOS): +The `--install` flag registers the kernel with Jupyter. It automatically detects and respects your current environment (virtualenv, conda, uv, etc.). - ```bash - mv ggsql-jupyter-linux-x64 ggsql-jupyter - chmod +x ggsql-jupyter - ``` +### Option 2: Download Pre-built Binary -3. **Install the kernel**: +Pre-built binaries are available from [GitHub Releases](https://github.com/georgestagg/ggsql/releases): - ```bash - ./ggsql-jupyter --install - ``` +| Platform | Binary | +| -------------------- | ---------------------------------- | +| Linux (x86_64) | `ggsql-jupyter-linux-x64` | +| Linux (ARM64) | `ggsql-jupyter-linux-arm64` | +| macOS (Intel) | `ggsql-jupyter-macos-x64` | +| macOS (Apple Silicon) | `ggsql-jupyter-macos-arm64` | +| Windows (x64) | `ggsql-jupyter-windows-x64.exe` | - On Windows (PowerShell): +After downloading, make it executable and install: - ```powershell - .\ggsql-jupyter-windows-x64.exe --install - ``` +```bash +chmod +x ggsql-jupyter-* +./ggsql-jupyter-linux-x64 --install +``` -The `--install` flag automatically: +On Windows (PowerShell): -- Creates a temporary directory with the kernel spec -- Copies the binary to the appropriate location -- Runs `jupyter kernelspec install` with the correct flags -- Respects your current environment (virtualenv, conda, etc.) -- Cleans up temporary files +```powershell +.\ggsql-jupyter-windows-x64.exe --install +``` ### Option 3: Build from Source -From the workspace root: +Requires a [Rust toolchain](https://rustup.rs/). From the workspace root: ```bash cargo build --release --package ggsql-jupyter diff --git a/ggsql-jupyter/pyproject.toml b/ggsql-jupyter/pyproject.toml new file mode 100644 index 00000000..cbc1f735 --- /dev/null +++ b/ggsql-jupyter/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["maturin>=1.4"] +build-backend = "maturin" + +[project] +name = "ggsql-jupyter" +version = "0.1.0" +description = "Jupyter kernel for ggsql - SQL extension for declarative data visualization" +readme = "README.md" +license = { text = "MIT" } +keywords = ["jupyter", "kernel", "sql", "visualization", "ggsql"] +classifiers = [ + "Programming Language :: Rust", + "Framework :: Jupyter", +] + +[tool.maturin] +bindings = "bin"