Skip to content

Commit 1bc9d34

Browse files
authored
Merge pull request #3 from Lithe-IDEA/codex/2122-python-toolchain-provider
feat(python): 启用包内后端和动态解释器发现
2 parents 32d134f + 16231e1 commit 1bc9d34

32 files changed

Lines changed: 2361 additions & 1692 deletions

‎.cargo/config.toml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# The package-local backend must start without a separately installed CRT.
2+
[target.x86_64-pc-windows-msvc]
3+
rustflags = ["-C", "target-feature=+crt-static"]
4+
5+
[target.aarch64-pc-windows-msvc]
6+
rustflags = ["-C", "target-feature=+crt-static"]
7+
8+
# The bundled musl targets use Rust's linker, including for local cross-builds.
9+
[target.x86_64-unknown-linux-musl]
10+
linker = "rust-lld"
11+
12+
[target.aarch64-unknown-linux-musl]
13+
linker = "rust-lld"

‎.github/workflows/ci.yml‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@ permissions:
1010

1111
jobs:
1212
package:
13+
uses: ./.github/workflows/package.yml
14+
15+
verify-store:
16+
needs: package
1317
runs-on: ubuntu-latest
1418
timeout-minutes: 15
1519
steps:
1620
- uses: actions/checkout@v4
1721
- uses: actions/setup-node@v4
1822
with:
1923
node-version: 22
20-
- name: Build all 6 platform archives
21-
run: node scripts/package.mjs
22-
- name: Verify release archives
24+
- uses: actions/download-artifact@v4
25+
with:
26+
pattern: python-support-archive-*
27+
merge-multiple: true
28+
path: dist
29+
- name: Verify six release archives
30+
env:
31+
LITHE_EXPECT_ALL_ARCHIVES: "1"
2332
run: node --test --test-timeout=60000 scripts/package/*.test.mjs
2433
- name: Validate against Lithe Store rules
2534
run: |
@@ -37,12 +46,6 @@ jobs:
3746
}
3847
process.exit(failed ? 1 : 0);
3948
"
40-
- name: Upload built platform archives
41-
uses: actions/upload-artifact@v4
42-
with:
43-
name: python-support-archives
44-
path: dist/python-support-*.zip
45-
if-no-files-found: error
4649
4750
commands:
4851
needs: package
@@ -72,7 +75,7 @@ jobs:
7275
run: python -m pip install --disable-pip-version-check pytest
7376
- uses: actions/download-artifact@v4
7477
with:
75-
name: python-support-archives
78+
name: python-support-archive-${{ matrix.platform }}
7679
path: dist
7780
- name: Unpack Windows archive under a path with spaces
7881
if: runner.os == 'Windows'

‎.github/workflows/package.yml‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Package Python Support
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
type: string
8+
required: false
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
package:
15+
runs-on: ${{ matrix.os }}
16+
timeout-minutes: 20
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- os: macos-latest
22+
platform: darwin-arm64
23+
target: aarch64-apple-darwin
24+
- os: macos-15-intel
25+
platform: darwin-x64
26+
target: x86_64-apple-darwin
27+
- os: ubuntu-latest
28+
platform: linux-x64
29+
target: x86_64-unknown-linux-musl
30+
- os: ubuntu-24.04-arm
31+
platform: linux-arm64
32+
target: aarch64-unknown-linux-musl
33+
- os: windows-latest
34+
platform: windows-x64
35+
target: x86_64-pc-windows-msvc
36+
- os: windows-11-arm
37+
platform: windows-arm64
38+
target: aarch64-pc-windows-msvc
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: 22
44+
- name: Configure Rust
45+
shell: bash
46+
env:
47+
TARGET: ${{ matrix.target }}
48+
run: |
49+
rustup toolchain install 1.87 --profile minimal --target "$TARGET"
50+
rustup override set 1.87
51+
- name: Test backend
52+
run: cargo test --locked --manifest-path backend/Cargo.toml
53+
- name: Assemble plugin archive
54+
shell: bash
55+
env:
56+
PLATFORM: ${{ matrix.platform }}
57+
TAG: ${{ inputs.tag }}
58+
run: |
59+
args=(--platform "$PLATFORM")
60+
if [[ -n "$TAG" ]]; then
61+
args+=(--expect-tag "$TAG")
62+
fi
63+
node scripts/package.mjs "${args[@]}"
64+
- name: Verify archive
65+
run: node --test --test-timeout=60000 scripts/package/archives.test.mjs
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: python-support-archive-${{ matrix.platform }}
69+
path: dist/python-support-*-${{ matrix.platform }}.zip
70+
if-no-files-found: error

‎.github/workflows/release.yml‎

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,86 @@
11
name: Release
22

33
# Push a tag v<version> matching plugin.json to publish a GitHub Release.
4-
# Lithe Store's tracker picks up stable releases and opens index pull requests.
5-
# Tags listed in PRERELEASE_TAGS below are published as pre-releases, which the
6-
# tracker skips until a compatible Lithe desktop release is out.
4+
# Lithe Store automatically tracks stable releases of eligible plugins.
75
on:
86
push:
97
tags: ["v*"]
108

119
permissions:
12-
contents: write
10+
contents: read
1311

1412
jobs:
15-
release:
13+
check:
1614
runs-on: ubuntu-latest
17-
timeout-minutes: 15
15+
timeout-minutes: 5
16+
outputs:
17+
exists: ${{ steps.release.outputs.exists }}
1818
steps:
19-
- name: Check whether release already exists
20-
id: check
19+
- name: Check whether the release already exists
20+
id: release
2121
env:
2222
GH_TOKEN: ${{ github.token }}
2323
run: |
2424
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
25-
echo "Release $GITHUB_REF_NAME already exists; skipping workflow build."
2625
echo "exists=true" >> "$GITHUB_OUTPUT"
2726
else
2827
echo "exists=false" >> "$GITHUB_OUTPUT"
2928
fi
29+
30+
package:
31+
needs: check
32+
if: needs.check.outputs.exists == 'false'
33+
uses: ./.github/workflows/package.yml
34+
with:
35+
tag: ${{ github.ref_name }}
36+
37+
release:
38+
needs: [check, package]
39+
if: needs.check.outputs.exists == 'false'
40+
runs-on: ubuntu-latest
41+
timeout-minutes: 5
42+
permissions:
43+
contents: write
44+
steps:
3045
- uses: actions/checkout@v4
31-
if: steps.check.outputs.exists != 'true'
3246
- uses: actions/setup-node@v4
33-
if: steps.check.outputs.exists != 'true'
3447
with:
3548
node-version: 22
36-
- name: Build 6 platform archives
37-
if: steps.check.outputs.exists != 'true'
38-
run: |
39-
set -o pipefail
40-
node scripts/package.mjs --expect-tag "$GITHUB_REF_NAME" | tee "$RUNNER_TEMP/checksums.txt"
41-
- name: Verify release archives
42-
if: steps.check.outputs.exists != 'true'
49+
- uses: actions/download-artifact@v4
50+
with:
51+
pattern: python-support-archive-*
52+
merge-multiple: true
53+
path: dist
54+
- name: Verify the six release archives
55+
env:
56+
LITHE_EXPECT_ALL_ARCHIVES: "1"
4357
run: node --test --test-timeout=60000 scripts/package/*.test.mjs
4458
- name: Publish GitHub Release
45-
if: steps.check.outputs.exists != 'true'
4659
env:
4760
GH_TOKEN: ${{ github.token }}
48-
PRERELEASE_TAGS: v0.1.0 v0.1.1
61+
# v1.0.0 requires a host that advertises toolchainProviders 0 and buildSystems 1.
62+
PRERELEASE_TAGS: v0.1.0 v0.1.1 v1.0.0
4963
run: |
50-
prerelease=false
64+
release_flags=()
65+
installation='Lithe Store 会在收录后提供此版本。打开 设置 → 插件 → 插件市场,搜索 Python Support。'
5166
for tag in $PRERELEASE_TAGS; do
52-
if [[ "$tag" == "$GITHUB_REF_NAME" ]]; then prerelease=true; fi
67+
if [[ "$tag" == "$GITHUB_REF_NAME" ]]; then
68+
release_flags+=(--prerelease)
69+
installation='下载对应平台的 ZIP。打开 设置 → 插件 → 从文件安装…,核对 SHA-256 后确认。'
70+
break
71+
fi
5372
done
73+
notes="docs/releases/$GITHUB_REF_NAME.md"
74+
test -s "$notes"
5475
{
55-
echo "兼容性:按插件契约 v0(schemaVersion 0、pluginAPIVersion 0)构建,需要支持声明式插件契约 v0 与项目内工具环境(.venv)信任解析的新版 Lithe 桌面端(desktop-v* 预发布)。"
76+
cat "$notes"
5677
echo
57-
if [[ -s "docs/releases/$GITHUB_REF_NAME.md" ]]; then
58-
cat "docs/releases/$GITHUB_REF_NAME.md"
59-
echo
60-
fi
61-
if [[ "$prerelease" == true ]]; then
62-
echo "安装:预发布版本,Lithe Store 自动追踪会跳过。下载对应平台的 ZIP,在 设置 → 插件 中点击 从文件安装…,选中 ZIP 后核对 SHA-256 并确认。"
63-
else
64-
echo "安装:Lithe Store(https://github.com/Lithe-IDEA/Lithe-store)收录后,可在 设置 → 插件 → 插件市场 中搜索 Python Support 并安装。"
65-
fi
78+
echo "$installation"
79+
echo
80+
echo 'SHA-256'
6681
echo
67-
echo "SHA-256:"
6882
echo '```'
69-
sed 's#^dist/##' "$RUNNER_TEMP/checksums.txt"
83+
(cd dist && sha256sum ./*.zip)
7084
echo '```'
7185
} > "$RUNNER_TEMP/notes.md"
72-
release_flags=()
73-
if [[ "$prerelease" == true ]]; then
74-
release_flags+=(--prerelease)
75-
fi
7686
gh release create "$GITHUB_REF_NAME" dist/*.zip --title "Python Support $GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/notes.md" "${release_flags[@]}"

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
dist/
55
**/__pycache__/
66
*.py[cod]
7+
8+
/backend/target/

0 commit comments

Comments
 (0)