pyc_editor 0.4.8

A Rust library for reading, modifying, and writing Python .pyc files.
Documentation
name: Rust

on:
  push:
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Restore stdlib cache
      uses: actions/cache/restore@v4
      with:
        path: tests/data
        key: python-stdlib-${{ runner.os }}
        restore-keys: |

          python-stdlib-

    - name: Install pyenv and Python versions
      run: |

        versions=("3.10.11" "3.11.4" "3.12.2" "3.13.1")

        missing_versions=()
        for version in "${versions[@]}"; do
            major_minor="${version%.*}"
            if [ ! -d "tests/data/cpython-${major_minor}/Lib" ]; then
            missing_versions+=("$version")
          fi
        done

        if [ ${#missing_versions[@]} -eq 0 ]; then
          echo "All required stdlib folders found in cache. Skipping Python installation."
          exit 0
        fi

        echo "Missing stdlib folders for: ${missing_versions[@]}"
        echo "Installing pyenv and missing Python versions..."

        curl https://pyenv.run | bash

        export PYENV_ROOT="$HOME/.pyenv"
        export PATH="$PYENV_ROOT/bin:$PATH"
        eval "$(pyenv init --path)"
        eval "$(pyenv virtualenv-init -)"

        for version in "${missing_versions[@]}"; do
          pyenv install "$version"
        done

        # Export all paths to GitHub env regardless
        echo "PYTHON_3_10=$HOME/.pyenv/versions/3.10.11/bin/python3.10" >> $GITHUB_ENV
        echo "PYTHON_3_11=$HOME/.pyenv/versions/3.11.4/bin/python3.11" >> $GITHUB_ENV
        echo "PYTHON_3_12=$HOME/.pyenv/versions/3.12.2/bin/python3.12" >> $GITHUB_ENV
        echo "PYTHON_3_13=$HOME/.pyenv/versions/3.13.1/bin/python3.13" >> $GITHUB_ENV

    - name: Build
      run: cargo build --release --all-features --all-targets --verbose

    - name: Run tests
      run: cargo test --release --all-features --verbose -- --show-output

    - name: Cache Python standard libraries
      uses: actions/cache/save@v4
      with:
        path: tests/data
        key: python-stdlib-${{ runner.os }}