name: Build pandas
description: Rebuilds the C extensions and installs pandas
inputs:
  editable:
    description: Whether to build pandas in editable mode (default true)
    default: true
  werror:
    description: Enable werror flag for build
    default: true
runs:
  using: composite
  steps:

    - name: Environment Detail
      run: |
        micromamba info
        micromamba list
        pip list --pre
      shell: bash -el {0}

    - name: Uninstall existing Pandas installation
      run: |
        if pip show pandas 1>/dev/null; then
          pip uninstall -y pandas
        fi
      shell: bash -el {0}

    - name: Build Pandas
      run: |
        # Ensure meson/pkg-config finds conda's Python headers, not the
        # system Python headers which may be broken (GH#65226).
        export PKG_CONFIG_PATH="$CONDA_PREFIX/lib/pkgconfig"
        if [[ ${{ inputs.editable }} == "true" ]]; then
          pip install -e . --no-build-isolation -v --no-deps \
            ${{ inputs.werror == 'true' && '-Csetup-args="--werror"' || '' }}
        else
          pip install . --no-build-isolation -v --no-deps \
            ${{ inputs.werror == 'true' && '-Csetup-args="--werror"' || '' }}
        fi
      shell: bash -el {0}
