Skip to content

Commit

Permalink
BUG: Fix binary comparison in upload_wheels.sh
Browse files Browse the repository at this point in the history
On MacOS, the wheel builder ran on a very old version of bash that
doesn't support `-v`.  Thanks to @eli-schwartz for pointing out that
`/usr/bin/env bash` yields a more modern shell.

The patch also make variable quoting consistent
  • Loading branch information
stefanv committed Nov 30, 2022
1 parent fe31f6b commit 1b47584
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions tools/wheels/upload_wheels.sh
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

set_travis_vars() {
# Set env vars
echo "TRAVIS_EVENT_TYPE is $TRAVIS_EVENT_TYPE"
Expand All @@ -6,16 +8,16 @@ set_travis_vars() {
echo "CIRRUS_TAG is $CIRRUS_TAG"
echo "CIRRUS_API_CREATED is $CIRRUS_API_CREATED"
echo "CIRRUS_PR is $CIRRUS_PR"
if [[ "$TRAVIS_EVENT_TYPE" == "push" && "$TRAVIS_TAG" == v* ]]; then
if [[ $TRAVIS_EVENT_TYPE == "push" && $TRAVIS_TAG == v* ]]; then
IS_PUSH="true"
elif [[ "$CIRRUS_PR" == "" && "$CIRRUS_TAG" == v* ]]; then
elif [[ $CIRRUS_PR == "" && $CIRRUS_TAG == v* ]]; then
IS_PUSH="true"
else
IS_PUSH="false"
fi
if [[ "$TRAVIS_EVENT_TYPE" == "cron" || -v CIRRUS_CRON ]]; then
if [[ $TRAVIS_EVENT_TYPE == cron || -v CIRRUS_CRON ]]; then
IS_SCHEDULE_DISPATCH="true"
elif [[ "$TRAVIS_EVENT_TYPE" == "api" || "$CIRRUS_API_CREATED" == "true" ]]; then
elif [[ $TRAVIS_EVENT_TYPE == api || $CIRRUS_API_CREATED == true ]]; then
# Manual CI run, so upload
IS_SCHEDULE_DISPATCH="true"
else
Expand All @@ -25,12 +27,12 @@ set_travis_vars() {
set_upload_vars() {
echo "IS_PUSH is $IS_PUSH"
echo "IS_SCHEDULE_DISPATCH is $IS_SCHEDULE_DISPATCH"
if [[ "$IS_PUSH" == "true" ]]; then
if [[ $IS_PUSH == true ]]; then
echo push and tag event
export ANACONDA_ORG="multibuild-wheels-staging"
export TOKEN="$NUMPY_STAGING_UPLOAD_TOKEN"
export ANACONDA_UPLOAD="true"
elif [[ "$IS_SCHEDULE_DISPATCH" == "true" ]]; then
elif [[ $IS_SCHEDULE_DISPATCH == true ]]; then
echo scheduled or dispatched event
export ANACONDA_ORG="scipy-wheels-nightly"
export TOKEN="$NUMPY_NIGHTLY_UPLOAD_TOKEN"
Expand All @@ -41,20 +43,20 @@ set_upload_vars() {
fi
}
upload_wheels() {
echo ${PWD}
if [[ ${ANACONDA_UPLOAD} == true ]]; then
if [ -z ${TOKEN} ]; then
echo "${PWD}"
if [[ $ANACONDA_UPLOAD == true ]]; then
if [[ -z $TOKEN ]]; then
echo no token set, not uploading
else
python -m pip install \
git+https://github.com/Anaconda-Platform/anaconda-client.git@be1e14936a8e947da94d026c990715f0596d7043
# 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
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./dist/*.gz
elif compgen -G "./wheelhouse/*.whl"; then
echo "Found wheel"
anaconda -q -t ${TOKEN} upload --skip -u ${ANACONDA_ORG} ./wheelhouse/*.whl
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./wheelhouse/*.whl
else
echo "Files do not exist"
return 1
Expand Down

0 comments on commit 1b47584

Please sign in to comment.