diff --git a/build-library/action.yml b/build-library/action.yml index d32c2c59f..aaabf0d76 100644 --- a/build-library/action.yml +++ b/build-library/action.yml @@ -121,6 +121,19 @@ inputs: required: false type: boolean + use-uv-lockfile: + description: | + Whether to use a uv lockfile when installing dependencies. + + .. note:: + + This option is only applicable when ``use-uv`` is set to ``true``. If + ``use-uv`` is set to ``false``, this option will be ignored. + + default: false + required: false + type: boolean + skip-python-setup: description: | Whether to skip the Python setup step performed by @@ -164,6 +177,16 @@ runs: message: > Skipping Python setup to use system Python. + - name: "Install dependencies from lockfile" + if: ${{ inputs.use-uv == 'true' && inputs.use-uv-lockfile == 'true' }} + shell: bash + env: + WORKING_DIRECTORY: ${{ inputs.working-directory }} + run: | + cd ${WORKING_DIRECTORY} + uv export --frozen --no-emit-project --no-hashes -o /tmp/requirements-locked.txt + uv pip install --no-managed-python --system -r /tmp/requirements-locked.txt + - name: "Install library" shell: bash env: diff --git a/build-wheelhouse/action.yml b/build-wheelhouse/action.yml index e56525feb..3c0643872 100644 --- a/build-wheelhouse/action.yml +++ b/build-wheelhouse/action.yml @@ -149,6 +149,19 @@ inputs: required: false type: boolean + use-uv-lockfile: + description: | + Whether to use a uv lockfile when installing dependencies. + + .. note:: + + This option is only applicable when ``use-uv`` is set to ``true``. If + ``use-uv`` is set to ``false``, this option will be ignored. + + default: false + required: false + type: boolean + skip-python-setup: description: | Whether to skip the Python setup step performed by @@ -429,12 +442,17 @@ runs: INSTALL_TARGET: ${{ steps.specific-target-requested.outputs.install_target }} WORKING_DIRECTORY: ${{ inputs.working-directory }} GITHUB_WORKSPACE: ${{ github.workspace }} + USE_UV: ${{ inputs.use-uv }} + USE_UV_LOCKFILE: ${{ inputs.use-uv-lockfile }} run: | ${ACTIVATE_VENV} cd ${WORKING_DIRECTORY} if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then poetry export --without-hashes --format=requirements.txt --output=wheel_reqs.txt pip wheel -w ${GITHUB_WORKSPACE}/wheelhouse -r wheel_reqs.txt + elif [[ "${USE_UV}" == 'true' && "${USE_UV_LOCKFILE}" == 'true' ]]; then + uv export --frozen --no-emit-project --no-hashes -o wheel_reqs.txt + pip wheel -w ${GITHUB_WORKSPACE}/wheelhouse -r wheel_reqs.txt else python -m pip wheel "${INSTALL_TARGET}" -w ${GITHUB_WORKSPACE}/wheelhouse fi diff --git a/check-vulnerabilities/action.yml b/check-vulnerabilities/action.yml index 2156d2d42..274aa064a 100644 --- a/check-vulnerabilities/action.yml +++ b/check-vulnerabilities/action.yml @@ -219,6 +219,19 @@ inputs: required: false type: boolean + use-uv-lockfile: + description: | + Whether to use a uv lockfile when installing dependencies. + + .. note:: + + This option is only applicable when ``use-uv`` is set to ``true``. If + ``use-uv`` is set to ``false``, this option will be ignored. + + default: false + required: false + type: boolean + runs: using: "composite" steps: @@ -243,7 +256,7 @@ runs: fi - name: "Install Git and clone project" - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 if: ${{ inputs.checkout == 'true' }} with: repository: ${{ inputs.repo-full-name == '' && github.repository || inputs.repo-full-name }} @@ -376,29 +389,38 @@ runs: BUILD_BACKEND: ${{ steps.github-environment-variables.outputs.BUILD_BACKEND }} ACTIVATE_VENV: ${{ steps.virtual-environment-activation-command.outputs.ACTIVATE_VENV }} EXTRA_TARGETS: ${{ inputs.extra-targets }} + USE_UV_LOCKFILE: ${{ inputs.use-uv-lockfile }} # Note: we need to use an array to store the extra targets, otherwise # the shell expansion messes with the quotes in the poetry case. run: | ${ACTIVATE_VENV} - if [[ "${EXTRA_TARGETS}" != '' ]]; then - if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then - echo "Installing extra targets with poetry: ${EXTRA_TARGETS}" - extra_targets=${EXTRA_TARGETS} + if [[ "${USE_UV_LOCKFILE}" == 'true' && "${BUILD_BACKEND}" == 'uv' ]]; then + if [[ "${EXTRA_TARGETS}" != '' ]]; then + uv sync --frozen --extra "${EXTRA_TARGETS}" --no-dev else - echo "Installing extra targets with pip: ${EXTRA_TARGETS}" - extra_targets=[${EXTRA_TARGETS}] + uv sync --frozen --no-dev fi else - echo "No extra targets to install" - extra_targets="" - fi + if [[ "${EXTRA_TARGETS}" != '' ]]; then + if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then + echo "Installing extra targets with poetry: ${EXTRA_TARGETS}" + extra_targets=${EXTRA_TARGETS} + else + echo "Installing extra targets with pip: ${EXTRA_TARGETS}" + extra_targets=[${EXTRA_TARGETS}] + fi + else + echo "No extra targets to install" + extra_targets="" + fi - if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then - poetry install --extras "${extra_targets}" - elif [[ "${BUILD_BACKEND}" == 'uv' ]]; then - uv pip install ."${extra_targets}" - else - python -m pip install ."${extra_targets}" + if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then + poetry install --extras "${extra_targets}" + elif [[ "${BUILD_BACKEND}" == 'uv' ]]; then + uv pip install ."${extra_targets}" + else + python -m pip install ."${extra_targets}" + fi fi - name: "Check if requirements.txt file exists" diff --git a/doc/source/changelog/1364.added.md b/doc/source/changelog/1364.added.md new file mode 100644 index 000000000..fcef7b7d6 --- /dev/null +++ b/doc/source/changelog/1364.added.md @@ -0,0 +1 @@ +Allow us uv lock file