Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
47051c2
feat: use uv lock file
SMoraisAnsys Jul 25, 2026
4cef1c2
chore: adding changelog file 1427.added.md [dependabot-skip]
pyansys-ci-bot Jul 25, 2026
5ec64d2
wip: test PR
SMoraisAnsys Jul 25, 2026
f3cee24
wip: add missing input
SMoraisAnsys Jul 25, 2026
83e60ca
refactor: add failing step when non uv lock file exists
SMoraisAnsys Jul 27, 2026
53ed4db
ci: force code style with install
SMoraisAnsys Jul 27, 2026
5fe8fc6
fix: missing working directory when checking
SMoraisAnsys Jul 27, 2026
b5c507e
ci: update to trigger jobs
SMoraisAnsys Jul 27, 2026
48bc226
ci: update to trigger jobs
SMoraisAnsys Jul 27, 2026
0ba1a55
ci: add missed input to trigger uv lock install
SMoraisAnsys Jul 27, 2026
10ddec7
refactor: do not use add group to not break hooks
SMoraisAnsys Jul 27, 2026
41f5114
refactor: fix previous refactoring
SMoraisAnsys Jul 27, 2026
32cd596
fix: add missing step in build wheelhouse
SMoraisAnsys Jul 28, 2026
940bac6
refactor: keep uv logic to install only
SMoraisAnsys Jul 28, 2026
8e525b6
refactor: fix wrong logic
SMoraisAnsys Jul 28, 2026
cc9b64f
refactor: cleanup
SMoraisAnsys Jul 28, 2026
6932c1a
fix: distribution folder handling when using uv without pip
SMoraisAnsys Jul 28, 2026
1b687e1
ci: update to only test with geometry
SMoraisAnsys Jul 28, 2026
759836d
refactor: update to fix type hint
SMoraisAnsys Jul 28, 2026
c55b759
ci: do not use lockfile on fake package
SMoraisAnsys Jul 29, 2026
e0f044e
ci: update following review
SMoraisAnsys Jul 29, 2026
33d926e
revert: change related to target to use
SMoraisAnsys Jul 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci_cd_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ jobs:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
use-python-cache: false
checkout: false
skip-install: false

@SMoraisAnsys SMoraisAnsys Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a comment to remind the need to revert some CI changes before any merge


type-check:
name: Type check with Ty
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/ci_cd_pr_flit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
test-build-library-flit:
name: "Test build-library action (use-uv: ${{ matrix.use-uv }}) using ansys-actions-flit package"
runs-on: ubuntu-latest
needs: test-build-wheelhouse-flit
# needs: test-build-wheelhouse-flit
strategy:
matrix:
use-uv: ['true', 'false']
Expand Down Expand Up @@ -173,11 +173,12 @@ jobs:
operating-system: ${{ matrix.os }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
attest-provenance: true
use-uv-lockfile: ${{ matrix.repository.name == 'pyansys-geometry' }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest creating a separate workflow (ci_cd_pr_uv ?) for testing projects that have started moving to uv to keep things clean and separated, and to have a natural place for testing more uv projects in the future (quite a number of them now). What do you think?

Although pyansys-geometry is using a hatchling build backend instead of uv_build, we could still test all projects leveraging uv lock files but not using any of flit_core.buildapi/poetry.core.masonry.api build backends in ci_cd_pr_uv.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just a CI config to illustrate that the changes work. Having another test workflow is a good idea but shouldn't we wait for uv_build to be used ?

use-uv: ${{ matrix.repository.name == 'pyansys-geometry' }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use-uv: ${{ matrix.repository.name == 'pyansys-geometry' }}

use-uv is true by default in the actions, which means we were always testing this execution path for every project. This change now means it will be only be tested for pyansys-geometry, which is not what you intended I suppose.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary ci config and planned to be reverted (cf #1427 (comment))


test-build-library-flit-projects:
name: "Test build-library action for ${{ matrix.repository.name }} project"
runs-on: ubuntu-latest
needs: test-build-wheelhouse-flit-projects
strategy:
matrix:
repository:
Expand All @@ -195,7 +196,6 @@ jobs:
contents: read
attestations: write # Needed for provenance attestation
steps:

- name: "Install Git and clone ${{ matrix.repository.name }} repository"
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
Expand All @@ -216,6 +216,8 @@ jobs:
library-name: ${{ matrix.repository.library }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
attest-provenance: true
use-uv-lockfile: ${{ matrix.repository.name == 'pyansys-geometry' }}
Comment thread
SMoraisAnsys marked this conversation as resolved.
use-uv: ${{ matrix.repository.name == 'pyansys-geometry' }}
Comment thread
SMoraisAnsys marked this conversation as resolved.

test-check-licenses-flit-projects:
name: "Test check-licenses action for ${{ matrix.repository.name }} project"
Expand Down Expand Up @@ -291,6 +293,9 @@ jobs:
use-python-cache: false
use-prek: ${{ matrix.use-prek }}
checkout: false
use-uv-lockfile: ${{ matrix.repository.name == 'pyansys-geometry' }}
Comment thread
SMoraisAnsys marked this conversation as resolved.
use-uv: ${{ matrix.repository.name == 'pyansys-geometry' }}
Comment thread
SMoraisAnsys marked this conversation as resolved.
skip-install: false

test-doc-style-flit-projects:
name: "Test doc-style action for ${{ matrix.repository.name }} project"
Expand Down
51 changes: 51 additions & 0 deletions build-library/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ 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 is ignored.
default: false
required: false
type: boolean

skip-python-setup:
description: |
Whether to skip the Python setup step performed by
Expand Down Expand Up @@ -164,7 +176,46 @@ runs:
message: >
Skipping Python setup to use system Python.

# ------------------------------------------------------------------------
# Install package by leveraging uv lockfile if requested and available
# ------------------------------------------------------------------------

- name: "Validate uv lockfile existence"
id: validate-uv-lockfile
if: ${{ inputs.use-uv == 'true' && inputs.use-uv-lockfile == 'true' }}
shell: bash
env:
WORKING_DIRECTORY: ${{ inputs.working-directory }}
run: |
if [[ ! -f "${WORKING_DIRECTORY}/uv.lock" ]]; then
echo "UV_LOCKFILE_MISSING=true" >> ${GITHUB_OUTPUT}
else
echo "UV_LOCKFILE_MISSING=false" >> ${GITHUB_OUTPUT}
fi

- uses: ansys/actions/_logging@main
if: ${{ steps.validate-uv-lockfile.outputs.UV_LOCKFILE_MISSING == 'true' }}
with:
level: "ERROR"
message: >
uv lockfile (uv.lock) not found in ${{ inputs.working-directory }}

- name: "Install dependencies from uv 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
Comment thread
SMoraisAnsys marked this conversation as resolved.
Outdated

# ------------------------------------------------------------------------
# Install package without leveraging uv lockfile
# ------------------------------------------------------------------------

- name: "Install library"
if: ${{ inputs.use-uv != 'true' || inputs.use-uv-lockfile != 'true' }}
shell: bash
env:
INSTALL_COMMAND: ${{ inputs.use-uv == 'true' && 'uv pip install --no-managed-python --system' || 'python -m pip install' }}
Expand Down
43 changes: 43 additions & 0 deletions build-wheelhouse/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ 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 is ignored.
default: false
required: false
type: boolean

skip-python-setup:
description: |
Whether to skip the Python setup step performed by
Expand Down Expand Up @@ -290,10 +302,33 @@ runs:
python -m pip install -U pip
fi

- name: "Validate uv lockfile existence"
id: validate-uv-lockfile
if: ${{ inputs.use-uv == 'true' && inputs.use-uv-lockfile == 'true' }}
shell: bash
env:
WORKING_DIRECTORY: ${{ inputs.working-directory }}
run: |
if [[ ! -f "${WORKING_DIRECTORY}/uv.lock" ]]; then
echo "UV_LOCKFILE_MISSING=true" >> ${GITHUB_OUTPUT}
else
echo "UV_LOCKFILE_MISSING=false" >> ${GITHUB_OUTPUT}
fi

- uses: ansys/actions/_logging@main
if: ${{ steps.validate-uv-lockfile.outputs.UV_LOCKFILE_MISSING == 'true' }}
with:
level: "ERROR"
message: >
uv lockfile (uv.lock) not found in repository root

- name: "Install the library with the desired targets"
env:
INSTALL_COMMAND: ${{ inputs.use-uv == 'true' && 'uv pip install --no-managed-python' || 'python -m pip install' }}
INSTALL_TARGET: ${{ steps.specific-target-requested.outputs.install_target }}
TARGET: ${{ inputs.target }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INSTALL_TARGET can be used directly rather than creating a separate env variable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this is not possible because INSTALL_TARGET would be . or .[my-target] (I just tested the changes :') ) Also, this env var is used when creating the wheel so better keep things as they are.

USE_UV: ${{ inputs.use-uv }}
USE_UV_LOCKFILE: ${{ inputs.use-uv-lockfile }}
ACTIVATE_VENV: ${{ steps.virtual-environment-activation-command.outputs.ACTIVATE_VENV }}
BUILD_BACKEND: ${{ steps.build-system.outputs.BUILD_BACKEND }}
WORKING_DIRECTORY: ${{ inputs.working-directory }}
Expand All @@ -303,6 +338,12 @@ runs:
cd ${WORKING_DIRECTORY}
if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then
poetry install ${INSTALL_TARGET}
elif [[ "${USE_UV}" == 'true' && "${USE_UV_LOCKFILE}" == 'true' ]]; then
if [[ "${TARGET}" != '' ]]; then
uv sync --frozen --extra "${TARGET}" --no-dev
else
uv sync --frozen --no-dev
fi
else
${INSTALL_COMMAND} "${INSTALL_TARGET}"
fi
Expand Down Expand Up @@ -410,6 +451,8 @@ runs:
ACTIVATE_VENV: ${{ steps.virtual-environment-activation-command.outputs.ACTIVATE_VENV }}
BUILD_BACKEND: ${{ steps.build-system.outputs.BUILD_BACKEND }}
INSTALL_COMMAND: ${{ inputs.use-uv == 'true' && 'uv pip install --no-managed-python' || 'python -m pip install' }}
USE_UV: ${{ inputs.use-uv }}
USE_UV_LOCKFILE: ${{ inputs.use-uv-lockfile }}
run: |
${ACTIVATE_VENV}
if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then
Expand Down
2 changes: 1 addition & 1 deletion build-wheelhouse/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def find_module_from_dist(pkg_name: str, attr: str):
if pth_file:
source_code_folder = None
# Read the .pth file to find the source code path
with Path(pth_file).open("r") as file:
with Path(str(dist.locate_file(pth_file))).open("r") as file:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why this change? Did the previous implementation start failing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is described in the PR description. Let me know if that's not clear enoguh

for line in file:
# Check if the path is a valid directory
path = Path(line.strip())
Expand Down
85 changes: 69 additions & 16 deletions check-vulnerabilities/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ 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 is ignored.
default: false
required: false
type: boolean

runs:
using: "composite"
steps:
Expand Down Expand Up @@ -277,6 +289,24 @@ runs:
message: >
Build backend: ${{ steps.github-environment-variables.outputs.BUILD_BACKEND }}

- name: "Validate uv lockfile existence"
id: validate-uv-lockfile
if: ${{ inputs.use-uv == 'true' && inputs.use-uv-lockfile == 'true' && inputs.skip-install == 'false' }}
shell: bash
run: |
if [[ ! -f "uv.lock" ]]; then
echo "UV_LOCKFILE_MISSING=true" >> ${GITHUB_OUTPUT}
else
echo "UV_LOCKFILE_MISSING=false" >> ${GITHUB_OUTPUT}
fi

- uses: ansys/actions/_logging@main
if: ${{ steps.validate-uv-lockfile.outputs.UV_LOCKFILE_MISSING == 'true' }}
with:
level: "ERROR"
message: >
uv lockfile (uv.lock) not found in repository root

# ------------------------------------------------------------------------

- uses: ansys/actions/_logging@main
Expand Down Expand Up @@ -376,29 +406,41 @@ 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}
# Use uv lockfile if requested and the build backend is uv
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
# Use other installation methods if uv lockfile is not requested or the build backend is not uv
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}"
# 1. Define the extra targets to be installed based on the build backend and the provided input
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
# 2. Trigger the installation command based on the build backend
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
Comment thread
SMoraisAnsys marked this conversation as resolved.
Outdated

- name: "Check if requirements.txt file exists"
Expand All @@ -410,6 +452,17 @@ runs:
run: |
echo "EXISTS_REQUIREMENTS=$(if [ -f requirements/requirements_${EXTRA_TARGETS}.txt ]; then echo 'true'; else echo 'false'; fi)" >> $GITHUB_OUTPUT

- uses: ansys/actions/_logging@main
if: ${{ inputs.skip-install == 'true' && inputs.use-uv-lockfile == 'true' && steps.check-exists-requirements-file.outputs.EXISTS_REQUIREMENTS == 'true' }}
with:
level: "ERROR"
message: >
``use-uv-lockfile`` is enabled, but ``skip-install`` is also enabled and
a requirements file exists. Please, either use the lock file or the requirements
file, but not both. If you want to use the lock file, remove the requirements file
from the repository. If you want to use the requirements file, disable
``use-uv-lockfile``.
Comment thread
SMoraisAnsys marked this conversation as resolved.
Outdated

- name: "Install dependencies from the requirements file"
shell: bash
if: ${{ (inputs.skip-install == 'true' ) && (steps.check-exists-requirements-file.outputs.EXISTS_REQUIREMENTS == 'true') }}
Expand Down
37 changes: 36 additions & 1 deletion code-style/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ 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`` and
``skip-install`` is set to ``false``. Otherwise, this option is ignored.
default: false
required: false
type: boolean

checkout:
description: |
Whether to do a checkout step or not. If ``true``, the checkout step is performed.
Expand Down Expand Up @@ -255,6 +267,24 @@ runs:

# ------------------------------------------------------------------------

- name: "Validate uv lockfile existence"
id: validate-uv-lockfile
if: ${{ inputs.use-uv == 'true' && inputs.use-uv-lockfile == 'true' && inputs.skip-install == 'false' }}
shell: bash
run: |
if [[ ! -f "uv.lock" ]]; then
echo "UV_LOCKFILE_MISSING=true" >> ${GITHUB_OUTPUT}
else
echo "UV_LOCKFILE_MISSING=false" >> ${GITHUB_OUTPUT}
fi

- uses: ansys/actions/_logging@main
if: ${{ steps.validate-uv-lockfile.outputs.UV_LOCKFILE_MISSING == 'true' }}
with:
level: "ERROR"
message: >
uv lockfile (uv.lock) not found in repository root

- name: "Update pip"
shell: bash
env:
Expand All @@ -274,12 +304,17 @@ runs:
env:
BUILD_BACKEND: ${{ steps.github-environment-variables.outputs.BUILD_BACKEND }}
ACTIVATE_VENV: ${{ steps.virtual-environment-activation-command.outputs.ACTIVATE_VENV }}
USE_UV_LOCKFILE: ${{ inputs.use-uv-lockfile }}
run: |
${ACTIVATE_VENV}
if [[ "${BUILD_BACKEND}" == 'poetry' ]]; then
poetry install
elif [[ "${BUILD_BACKEND}" == 'uv' ]]; then
uv pip install .
if [[ "${USE_UV_LOCKFILE}" == 'true' ]]; then
uv sync --frozen --no-dev
else
uv pip install .
fi
else
python -m pip install .
fi
Expand Down
1 change: 1 addition & 0 deletions doc/source/changelog/1427.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use uv lock file
Loading