diff --git a/.github/workflows/build-wheel.yml b/.github/workflows/build-wheel.yml index ff7dd3fe5..cdd666c23 100644 --- a/.github/workflows/build-wheel.yml +++ b/.github/workflows/build-wheel.yml @@ -80,16 +80,13 @@ jobs: with: platforms: ${{ matrix.arch }} - - name: Install build tools - run: uv pip install -r requirements-dev.txt - - name: Bump new dev version if: github.event_name != 'release' run: | git config user.name "Marcelo Duarte" git config user.email marcelotduarte@users.noreply.github.com SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) - VERSION=$(bump-my-version show current_version 2>/dev/null) + VERSION=$(uvx bump-my-version show current_version 2>/dev/null) VERSION_BASE=$(python -c "print('$VERSION'.rsplit('-',1)[0])") if [ "${{ github.event_name }}" == "pull_request" ]; then OPTIONAL=".${{ github.event.number }}" @@ -97,7 +94,7 @@ jobs: OPTIONAL="" fi VERSION_NEW=$VERSION_BASE$OPTIONAL-dev.$SOURCE_DATE_EPOCH - bump-my-version bump --no-tag build --new-version=$VERSION_NEW 2>/dev/null + uvx bump-my-version bump --no-tag build --new-version=$VERSION_NEW 2>/dev/null git log -1 - name: Build sdist and wheels diff --git a/ci/build-wheel.sh b/ci/build-wheel.sh index e10b0b7cb..fbc57b47a 100755 --- a/ci/build-wheel.sh +++ b/ci/build-wheel.sh @@ -19,6 +19,7 @@ else PLATFORM_TAG_MASK=$(echo $PLATFORM_TAG | sed 's/_/*/') fi +# Usage if ! [ -z "$1" ] && [ "$1" == "--help" ]; then echo "Usage:" echo "$0 [--all|TAG] [--archs=ARCHS]" @@ -46,11 +47,34 @@ while ! [ -z "$1" ]; do shift done +# Functions and commands +_verlte() { + echo -e $(echo -e "$1\n$2" | sort -V | head -n1) +} + +_vergte() { + echo -e $(echo -e "$1\n$2" | sort -V -r | head -n1) +} + +_bump_my_version () { + local args=$* + # Use python <= 3.12 (python 3.13t is not supported) + local py_version=$(_verlte $PY_VERSION 3.12) + echo $(uvx -p $py_version bump-my-version $args 2>/dev/null | tr -d '\r\n') +} + +_cibuildwheel () { + local args=$* + # Use python >= 3.11 + local py_version=$(_vergte $PY_VERSION 3.11) + # Do not export UV_* to avoid conflict with uv in cibuildwheel macOS/Windows + unset UV_SYSTEM_PYTHON + uvx -p $py_version cibuildwheel $args +} + echo "::group::Install dependencies and build tools" -# Do not export UV_PYTHON to avoid conflict with uv in cibuildwheel macOS -UV_RESOLUTION=highest \ - uv pip install -r requirements.txt -r requirements-dev.txt -VERSION=$(bump-my-version show current_version 2>/dev/null | tr -d '\r\n') +UV_RESOLUTION=highest uv pip install -r requirements.txt +VERSION=$(_bump_my_version show current_version) if [[ $VERSION == *-* ]]; then VERSION_OK=$($PYTHON -c "print(''.join('$VERSION'.replace('-','.').rsplit('.',1)), end='')") else @@ -65,24 +89,21 @@ if [[ $PY_PLATFORM == linux* ]]; then echo "::endgroup::" fi echo "::group::Build wheel(s)" -# Do not export UV_* to avoid conflict with uv in cibuildwheel macOS/Windows -unset UV_PYTHON -unset UV_SYSTEM_PYTHON if [ "$BUILD_TAG" == "--only" ]; then - DIRTY=$(bump-my-version show scm_info.dirty 2>/dev/null | tr -d '\r\n') + DIRTY=$(_bump_my_version show scm_info.dirty) FILEMASK=cx_Freeze-$VERSION_OK-$PYTHON_TAG-$PYTHON_TAG-$PLATFORM_TAG_MASK FILEEXISTS=$(ls wheelhouse/$FILEMASK.whl 2>/dev/null || echo '') if [ "$DIRTY" != "False" ] || [ -z "$FILEEXISTS" ]; then if [[ $PY_PLATFORM == win* ]]; then uv build --no-build-isolation --wheel -o wheelhouse else - cibuildwheel --only $PYTHON_TAG-$PLATFORM_TAG --prerelease-pythons + _cibuildwheel --only $PYTHON_TAG-$PLATFORM_TAG fi fi elif ! [ -z "$BUILD_TAG" ]; then - CIBW_BUILD="$BUILD_TAG" cibuildwheel $ARCHS + CIBW_BUILD="$BUILD_TAG" _cibuildwheel $ARCHS else - cibuildwheel $ARCHS + _cibuildwheel $ARCHS fi echo "::endgroup::"