From 941da59bbc18a734521ccdac24124f7906af443c Mon Sep 17 00:00:00 2001 From: Xiaoze Fan Date: Mon, 16 Nov 2026 22:25:08 +0000 Subject: [PATCH 1/4] ci: build and publish release wheels on v* tags --- .github/workflows/release.yml | 113 ++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..26f9b4c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,113 @@ +name: Release wheels + +# Release wheels: built by scripts/build-wheels.sh --release, published to PyPI, then attached to +# a draft GitHub release. A manual run only builds and import-checks development wheels. +on: + push: + tags: ["v*"] + workflow_dispatch: + +# Never cancelled: a release must not stop half-way through an upload. +concurrency: + group: release-wheels-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: read + +jobs: + build: + name: Build + if: github.repository == 'FlashML-org/FreeToken-metal' + runs-on: macos-15 + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 + with: + version: "0.13.7" + # The action's own checksum table stops before this version. + checksum: "81b811b57e4624df7ed3aac148e0359100d9962f3d9dce00aec533dc2e086731" + # A cache another ref's run saved must not reach a release. + enable-cache: false + # The event picks the mode, not the ref: a manual run started on a tag stays a rehearsal. + - run: | + # Nothing uploaded to PyPI after the commit can reach the wheels or the checks. + UV_EXCLUDE_NEWER="$(git log -1 --format=%cI)" + export UV_EXCLUDE_NEWER + if [ "$GITHUB_EVENT_NAME" = push ]; then + version="$(sed -nE 's/^__version__ = "([^"]+)"$/\1/p' python/ftmetal/version.py)" + if [ "$GITHUB_REF_NAME" != "v$version" ]; then + echo "::error::tag $GITHUB_REF_NAME does not name version $version" + exit 1 + fi + scripts/build-wheels.sh --release --out-dir dist + else + scripts/build-wheels.sh --out-dir dist + fi + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: release-wheels + path: dist/*.whl + if-no-files-found: error + # Long enough to rerun the publish jobs days later. + retention-days: 30 + + publish-pypi: + name: Publish to PyPI + needs: build + if: github.event_name == 'push' && github.ref_type == 'tag' + runs-on: ubuntu-latest + timeout-minutes: 10 + environment: pypi + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: release-wheels + path: dist + - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 + with: + version: "0.13.7" + checksum: "c5221ff41b7892bfc223543883600125f6a47fe845093e0f5bdff4f359196d83" + enable-cache: false + # PyPI accepts an identical file again but refuses other bytes under a name it holds. + - env: + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + run: uv publish --trusted-publishing never dist/*.whl + + github-release: + name: Draft GitHub release + # After PyPI, so the release carries the wheels PyPI holds. + needs: publish-pypi + if: github.event_name == 'push' && github.ref_type == 'tag' + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: write + steps: + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: release-wheels + path: dist + # gh release create adds a second draft for a tag, so an earlier attempt's draft is replaced. + - env: + GH_TOKEN: ${{ github.token }} + run: | + releases="$(gh api "repos/$GITHUB_REPOSITORY/releases" --paginate \ + --jq '.[] | select(.tag_name == env.GITHUB_REF_NAME) | "\(.id) \(.draft)"')" + case "$releases" in + "") ;; + *$'\n'*) + echo "::error::more than one release is tagged $GITHUB_REF_NAME" + exit 1 + ;; + *" true") gh api --method DELETE "repos/$GITHUB_REPOSITORY/releases/${releases% true}" ;; + *) + echo "::error::release $GITHUB_REF_NAME is already published; its assets stay as they are" + exit 1 + ;; + esac + gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft --verify-tag \ + --title "$GITHUB_REF_NAME" --notes "Draft: write the notes, then publish." dist/*.whl From ea24c2c81f4e0ab47fda92159126fc4d15c0cdfb Mon Sep 17 00:00:00 2001 From: Xiaoze Fan Date: Mon, 16 Nov 2026 22:25:08 +0000 Subject: [PATCH 2/4] docs: install from PyPI in the README and the install guide --- README.md | 28 ++++++++++++++++++---------- docs/install.md | 18 ++++++++++++++++-- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2e2c664..d83103f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@
- - - FreeToken-metal + + + FreeToken-metal
@@ -28,17 +28,25 @@ Runs on Apple Silicon Macs with macOS 15 or later. ## Getting Started +Install FreeToken-metal with [uv](https://docs.astral.sh/uv/) (recommended) or pip: + +```bash +uv tool install --python 3.13 freetoken-metal +ftm serve --model /path/to/Qwen3.6-35B-A3B-MLX +``` + +Or build it from source: + ```bash git clone https://github.com/FlashML-org/FreeToken-metal.git && cd FreeToken-metal ./install.sh -ftm serve --model /path/to/Qwen3.6-35B-A3B-MLX ``` -- [Install](docs/install.md) -- [Quick start](docs/quickstart.md) -- [Supported models](docs/models.md) -- [CLI reference](docs/cli.md) -- [Contributing](CONTRIBUTING.md) +- [Install](https://github.com/FlashML-org/FreeToken-metal/blob/main/docs/install.md) +- [Quick start](https://github.com/FlashML-org/FreeToken-metal/blob/main/docs/quickstart.md) +- [Supported models](https://github.com/FlashML-org/FreeToken-metal/blob/main/docs/models.md) +- [CLI reference](https://github.com/FlashML-org/FreeToken-metal/blob/main/docs/cli.md) +- [Contributing](https://github.com/FlashML-org/FreeToken-metal/blob/main/CONTRIBUTING.md) ## Citation @@ -61,4 +69,4 @@ and is built on [MLX](https://github.com/ml-explore/mlx). ## License -[Apache License 2.0](LICENSE). +[Apache License 2.0](https://github.com/FlashML-org/FreeToken-metal/blob/main/LICENSE). diff --git a/docs/install.md b/docs/install.md index 4f628ab..e436db5 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,7 +1,21 @@ # Install -Requires an Apple Silicon Mac with macOS 15 or later and the Xcode Command Line Tools -(`xcode-select --install`). +Requires an Apple Silicon Mac with macOS 15 or later. Building from source also needs the Xcode +Command Line Tools (`xcode-select --install`). + +## From PyPI + +With [uv](https://docs.astral.sh/uv/): + +```bash +uv tool install --python 3.13 freetoken-metal +ftm --version +``` + +It installs into an environment of its own and links `ftm` into `~/.local/bin`; run +`uv tool update-shell` if that directory is not on your `PATH`, and +`uv tool upgrade freetoken-metal` to update. With pip, install into a virtual environment of +Python 3.11 to 3.13: `pip install freetoken-metal`. ## Install script From 9f774a3a36d581047c27522d5b9aa842c527f678 Mon Sep 17 00:00:00 2001 From: Xiaoze Fan Date: Mon, 16 Nov 2026 22:25:08 +0000 Subject: [PATCH 3/4] build: remove the egg-info the wheel build leaves --- scripts/build-wheels.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-wheels.sh b/scripts/build-wheels.sh index 701a27d..fbe2b7d 100755 --- a/scripts/build-wheels.sh +++ b/scripts/build-wheels.sh @@ -96,7 +96,7 @@ cleanup() { if [ "$STAMPED" = 1 ]; then cp "$SCRATCH/version.py" "$ROOT/$VERSION_FILE" fi - rm -rf "$SCRATCH" "$ROOT/build" "$ROOT/python/ftmetal.egg-info" + rm -rf "$SCRATCH" "$ROOT/build" "$ROOT/python/freetoken_metal.egg-info" } trap cleanup EXIT From ba40a009281d4142733e0b8a6fa7f915b2810076 Mon Sep 17 00:00:00 2001 From: Xiaoze Fan Date: Mon, 16 Nov 2026 22:25:08 +0000 Subject: [PATCH 4/4] build: add the PyPI classifiers --- pyproject.toml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 5ab3134..5f5c4dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,19 @@ license = "Apache-2.0" license-files = ["LICENSE"] authors = [{ name = "FlashML Team" }] requires-python = ">=3.11,<3.14" +# No License:: classifier: setuptools>=77 rejects mixing one with the SPDX string above. +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Operating System :: MacOS", + "Environment :: GPU", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Scientific/Engineering :: Artificial Intelligence", +] dependencies = [ "mlx==0.32.3", "numpy>=2.0,<3",