diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 106530f84223a..d15c924d2dad2 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -45,6 +45,7 @@ jobs: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0'))) runs-on: ubuntu-24.04 env: + IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} outputs: sdist_file: ${{ steps.save-path.outputs.sdist_name }} @@ -117,6 +118,7 @@ jobs: python: ["cp313t", "3.13"] env: + IS_PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} steps: - name: Checkout pandas @@ -164,7 +166,6 @@ jobs: uses: pypa/cibuildwheel@v3.2.1 with: package-dir: ./dist/${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }} - output-dir: ./dist env: CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} CIBW_BUILD_FRONTEND: ${{ matrix.cibw_build_frontend || 'pip' }} @@ -195,19 +196,26 @@ jobs: - name: Validate wheel RECORD shell: bash -el {0} - run: for whl in $(ls ./dist/*.whl); do wheel unpack $whl -d /tmp; done + run: for whl in $(ls wheelhouse); do wheel unpack wheelhouse/$whl -d /tmp; done - uses: actions/upload-artifact@v6 with: name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} - path: ./dist/*.whl + path: ./wheelhouse/*.whl - name: Upload wheels & sdist - if: ${{ success() && env.IS_SCHEDULE_DISPATCH == 'true' }} - uses: scientific-python/upload-nightly-action@0.6.2 - with: - artifacts_path: ./dist - anaconda_nightly_upload_token: ${{secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN}} + if: ${{ success() && (env.IS_SCHEDULE_DISPATCH == 'true' || env.IS_PUSH == 'true') }} + shell: bash -el {0} + env: + PANDAS_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.PANDAS_NIGHTLY_UPLOAD_TOKEN }} + # trigger an upload to + # https://anaconda.org/scientific-python-nightly-wheels/pandas + # for cron jobs or "Run workflow" (restricted to main branch). + # The tokens were originally generated at anaconda.org + run: | + source ci/upload_wheels.sh + set_upload_vars + upload_wheels publish: if: > diff --git a/.gitignore b/.gitignore index 5177a195f99f9..a4a21293ab1ee 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,7 @@ pandas/py.typed .ropeproject # wheel files *.whl +**/wheelhouse/* pip-wheel-metadata # coverage .coverage diff --git a/ci/upload_wheels.sh b/ci/upload_wheels.sh new file mode 100644 index 0000000000000..92959e8716a80 --- /dev/null +++ b/ci/upload_wheels.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Modified from numpy's https://github.com/numpy/numpy/blob/main/tools/wheels/upload_wheels.sh + +set_upload_vars() { + echo "IS_SCHEDULE_DISPATCH is $IS_SCHEDULE_DISPATCH" + if [[ "$IS_SCHEDULE_DISPATCH" == "true" ]]; then + echo scheduled or dispatched event + export ANACONDA_ORG="scientific-python-nightly-wheels" + export TOKEN="$PANDAS_NIGHTLY_UPLOAD_TOKEN" + export ANACONDA_UPLOAD="true" + else + echo non-dispatch event + export ANACONDA_UPLOAD="false" + fi +} +upload_wheels() { + echo "${PWD}" + if [[ ${ANACONDA_UPLOAD} == true ]]; then + if [ -z "${TOKEN}" ]; then + echo no token set, not uploading + else + # sdists are located under dist folder when built through setup.py + if compgen -G "./dist/*.gz"; then + echo "Found sdist" + anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./dist/*.gz + echo "Uploaded sdist" + fi + if compgen -G "./wheelhouse/*.whl"; then + echo "Found wheel" + anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./wheelhouse/*.whl + echo "Uploaded wheel" + fi + echo "PyPI-style index: https://pypi.anaconda.org/$ANACONDA_ORG/simple" + fi + fi +}