Skip to content

Commit

Permalink
Feat/pip wheel version script (#28)
Browse files Browse the repository at this point in the history
* Add pip wheel version script

* add debugging to pip version script

* Rewrite rapids-twine in bash

* Address shellcheck suggestions

* Print debug statements to stderr

* Simplify rapids-pip-wheel-version

* Pass epoch timestamp into pip-version script

* Use set -u instead of rapids-require-env-var
  • Loading branch information
sevagh authored Nov 16, 2022
1 parent b11d45c commit 4664eb1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 80 deletions.
34 changes: 34 additions & 0 deletions tools/rapids-pip-wheel-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# A utility script that generates a pip wheel version
# Positional Arguments:
# 1) epoch timestamp
set -exo pipefail
export RAPIDS_SCRIPT_NAME="rapids-pip-wheel-version"

if [ -z "$1" ]; then
rapids-echo-stderr "Must specify input arguments: EPOCH_TIMESTAMP"
exit 1
fi
epoch_timestamp="$1"

function distutilsNormalizeVersion {
echo -n "$(python3 -c "from setuptools.extern import packaging; print(packaging.version.Version('$1'))")"
}

rapids-echo-stderr "pwd is $(pwd)"

latest_git_tag="$(git describe --tag --abbrev=0)"

# drop letters ('v', 'a', etc.) from tag
# v22.12.00a -> 22.12.00
# v22.12.00 -> 22.12.00

latest_git_tag="${latest_git_tag//[a-z]/}"

# normalize with distutils logic
latest_git_tag="$(distutilsNormalizeVersion "${latest_git_tag}")"

# add epoch timestamp so more recent wheels are installed first
versioneer_override="$latest_git_tag.$epoch_timestamp"

echo -n "${versioneer_override}"
34 changes: 34 additions & 0 deletions tools/rapids-twine
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# A utility script that wraps twine to support build tags (PEP427)
#
# Positional Arguments:
# 1) wheel dir
set -exou pipefail
export RAPIDS_SCRIPT_NAME="rapids-twine"

if [ -z "$1" ]; then
rapids-echo-stderr "Must specify input arguments: WHEEL_DIR"
exit 1
fi
wheeldir="$1"

build_tag="${RAPIDS_PY_WHEEL_BUILD_TAG:-""}"

if [ "${build_tag}" != "" ]; then
echo "Checking if build tag ${build_tag} is legal..."
if [[ "${build_tag}" =~ [^[:digit:]] ]]; then
rapids-echo-stderr "Build tag can only be digits"
exit 1
fi

echo "Need to apply build tag ${build_tag}..."
for wheelfile in "${wheeldir}"/*.whl; do
wheel_version=$(echo "$wheelfile" | cut -d'-' -f2)
replacement_wheel_version="${wheel_version}-${build_tag}"
wheelnewfile="${wheelfile/$wheel_version/$replacement_wheel_version}"

mv "${wheelfile}" "${wheelnewfile}"
done
fi

twine upload --disable-progress-bar --non-interactive "${wheeldir}"/*.whl
80 changes: 0 additions & 80 deletions tools/rapids-twine.py

This file was deleted.

0 comments on commit 4664eb1

Please sign in to comment.