Lightweight coding agent that runs in your terminal
Rust
Publish Python runtime wheels on release (#21784)
Ahmed Ibrahim9183503b972c
diff --git a/.github/workflows/rust-release-windows.yml b/.github/workflows/rust-release-windows.ymlindex 2eb7ef2a47..24cdebe454 100644--- a/.github/workflows/rust-release-windows.yml+++ b/.github/workflows/rust-release-windows.yml@@ -220,6 +220,47 @@ jobs:"$dest/${binary}-${{ matrix.target }}.exe"done+ - name: Build Python runtime wheel+ shell: bash+ run: |+ set -euo pipefail++ case "${{ matrix.target }}" in+ aarch64-pc-windows-msvc)+ platform_tag="win_arm64"+ ;;+ x86_64-pc-windows-msvc)+ platform_tag="win_amd64"+ ;;+ *)+ echo "No Python runtime wheel platform tag for ${{ matrix.target }}"+ exit 1+ ;;+ esac++ python -m pip install build++ stage_dir="${RUNNER_TEMP}/openai-codex-cli-bin-${{ matrix.target }}"+ wheel_dir="${GITHUB_WORKSPACE}/python-runtime-dist/${{ matrix.target }}"+ # Keep the helpers next to codex.exe in the runtime wheel so Windows+ # sandbox/elevation lookup matches the standalone release zip.+ python "${GITHUB_WORKSPACE}/sdk/python/scripts/update_sdk_artifacts.py" \+ stage-runtime \+ "$stage_dir" \+ "${GITHUB_WORKSPACE}/codex-rs/target/${{ matrix.target }}/release/codex.exe" \+ --codex-version "${GITHUB_REF_NAME}" \+ --platform-tag "$platform_tag" \+ --resource-binary "${GITHUB_WORKSPACE}/codex-rs/target/${{ matrix.target }}/release/codex-command-runner.exe" \+ --resource-binary "${GITHUB_WORKSPACE}/codex-rs/target/${{ matrix.target }}/release/codex-windows-sandbox-setup.exe"+ python -m build --wheel --outdir "$wheel_dir" "$stage_dir"++ - name: Upload Python runtime wheel+ uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0+ with:+ name: python-runtime-wheel-${{ matrix.target }}+ path: python-runtime-dist/${{ matrix.target }}/*.whl+ if-no-files-found: error+- name: Install DotSlashuses: facebook/install-dotslash@1e4e7b3e07eaca387acb98f1d4720e0bee8dbb6a # v2diff --git a/.github/workflows/rust-release.yml b/.github/workflows/rust-release.ymlindex d05340a020..f958153f9c 100644--- a/.github/workflows/rust-release.yml+++ b/.github/workflows/rust-release.yml@@ -399,6 +399,61 @@ jobs:cp target/${{ matrix.target }}/release/codex-${{ matrix.target }}.dmg "$dest/codex-${{ matrix.target }}.dmg"fi+ - name: Build Python runtime wheel+ if: ${{ matrix.bundle == 'primary' }}+ shell: bash+ run: |+ set -euo pipefail++ case "${{ matrix.target }}" in+ aarch64-apple-darwin)+ platform_tag="macosx_11_0_arm64"+ ;;+ x86_64-apple-darwin)+ platform_tag="macosx_10_9_x86_64"+ ;;+ aarch64-unknown-linux-musl)+ platform_tag="musllinux_1_1_aarch64"+ ;;+ x86_64-unknown-linux-musl)+ platform_tag="musllinux_1_1_x86_64"+ ;;+ *)+ echo "No Python runtime wheel platform tag for ${{ matrix.target }}"+ exit 1+ ;;+ esac++ python3 -m pip install build++ stage_dir="${RUNNER_TEMP}/openai-codex-cli-bin-${{ matrix.target }}"+ wheel_dir="${GITHUB_WORKSPACE}/python-runtime-dist/${{ matrix.target }}"+ resource_args=()+ if [[ "${{ matrix.target }}" == *linux* ]]; then+ # Keep bwrap in the runtime wheel so Linux sandbox fallback behavior+ # matches the standalone release bundle on hosts without system bwrap.+ resource_args+=(+ --resource-binary+ "${GITHUB_WORKSPACE}/codex-rs/target/${{ matrix.target }}/release/bwrap"+ )+ fi+ python3 "${GITHUB_WORKSPACE}/sdk/python/scripts/update_sdk_artifacts.py" \+ stage-runtime \+ "$stage_dir" \+ "${GITHUB_WORKSPACE}/codex-rs/target/${{ matrix.target }}/release/codex" \+ --codex-version "${GITHUB_REF_NAME}" \+ --platform-tag "$platform_tag" \+ "${resource_args[@]}"+ python3 -m build --wheel --outdir "$wheel_dir" "$stage_dir"++ - name: Upload Python runtime wheel+ if: ${{ matrix.bundle == 'primary' }}+ uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0+ with:+ name: python-runtime-wheel-${{ matrix.target }}+ path: python-runtime-dist/${{ matrix.target }}/*.whl+ if-no-files-found: error+- name: Compress artifactsshell: bashrun: |@@ -478,6 +533,7 @@ jobs:tag: ${{ github.ref_name }}should_publish_npm: ${{ steps.npm_publish_settings.outputs.should_publish }}npm_tag: ${{ steps.npm_publish_settings.outputs.npm_tag }}+ should_publish_python_runtime: ${{ steps.python_runtime_publish_settings.outputs.should_publish }}steps:- name: Checkout repository@@ -554,6 +610,22 @@ jobs:echo "npm_tag=" >> "$GITHUB_OUTPUT"fi+ - name: Determine Python runtime publish settings+ id: python_runtime_publish_settings+ env:+ VERSION: ${{ steps.release_name.outputs.name }}+ run: |+ set -euo pipefail+ version="${VERSION}"++ if [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ echo "should_publish=true" >> "$GITHUB_OUTPUT"+ elif [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+$ ]]; then+ echo "should_publish=true" >> "$GITHUB_OUTPUT"+ else+ echo "should_publish=false" >> "$GITHUB_OUTPUT"+ fi+- name: Setup pnpmuses: pnpm/action-setup@a8198c4bff370c8506180b035930dea56dbd5288 # v5with:@@ -787,6 +859,48 @@ jobs:exit "${publish_status}"done+ # Publish the platform-specific Python runtime wheels using PyPI trusted publishing.+ # PyPI project configuration must trust this workflow and job. Keep this+ # non-blocking while the Python runtime publishing path is new; failures still+ # need release follow-up, but should not invalidate the Rust release itself.+ publish-python-runtime:+ # Publish to PyPI for stable releases and alpha pre-releases with numeric suffixes.+ if: ${{ needs.release.outputs.should_publish_python_runtime == 'true' }}+ name: publish-python-runtime+ needs: release+ runs-on: ubuntu-latest+ continue-on-error: true+ environment: pypi+ permissions:+ id-token: write # Required for PyPI trusted publishing.+ contents: read++ steps:+ - name: Download Python runtime wheels from release+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ RELEASE_TAG: ${{ needs.release.outputs.tag }}+ RELEASE_VERSION: ${{ needs.release.outputs.version }}+ run: |+ set -euo pipefail+ python_version="$RELEASE_VERSION"+ python_version="${python_version/-alpha./a}"+ python_version="${python_version/-beta./b}"+ python_version="${python_version/-rc./rc}"++ mkdir -p dist/python-runtime+ gh release download "$RELEASE_TAG" \+ --repo "${GITHUB_REPOSITORY}" \+ --pattern "openai_codex_cli_bin-${python_version}-*.whl" \+ --dir dist/python-runtime+ ls -lh dist/python-runtime++ - name: Publish Python runtime wheels to PyPI+ uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0+ with:+ packages-dir: dist/python-runtime+ skip-existing: true+winget:name: wingetneeds: releasediff --git a/sdk/python/README.md b/sdk/python/README.mdindex 149420ad95..031471b811 100644--- a/sdk/python/README.md+++ b/sdk/python/README.md@@ -91,7 +91,7 @@ This supports the CI release flow:- run `generate-types` before packaging- stage `openai-codex-app-server-sdk` once with an exact `openai-codex-cli-bin==...` dependency- stage `openai-codex-cli-bin` on each supported platform runner with the same pinned runtime version-- build and publish `openai-codex-cli-bin` as platform wheels only; do not publish an sdist+- build and publish `openai-codex-cli-bin` as platform wheels only through PyPI trusted publishing; do not publish an sdist## Compatibility and versioning