Skip to content

feat: use uv lock file - #1427

Open
SMoraisAnsys wants to merge 22 commits into
mainfrom
feat/use-uv-lock-file
Open

feat: use uv lock file#1427
SMoraisAnsys wants to merge 22 commits into
mainfrom
feat/use-uv-lock-file

Conversation

@SMoraisAnsys

@SMoraisAnsys SMoraisAnsys commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Follow up of #1364 but with a clean branch.

Related to #1088, in particular this comment, and #1088.

Testing in pyaedt was successfull and highlighted that fonttools, a transitive dependency, was associated to a vulnerability in Safety's db. This is not a universal id like CVE/GHSA.

The use of uv add --group ansys-actions -r "${REQUIREMENTS_FILE}" has been removed in 10ddec7 because some hooks might check the pyproject.toml / uv.lock files and lead to CI failure. That is the case with pyansys-geometry which leverages pyproject-fmt.

The smoke_test.py file has been updated in 6932c1a to be compatible with uv's architecture to manage packages. I assume that we we weren't affected previously because uv pip install mimics pip's behavior. But when using uv sync that behavior changes and we can't use CWD to retrieve the dist files. Levering relative location solves this issue and seems to also work with other package managers.

Note

Currently the changes are limited to a subset of actions. We might want to extend it to others. TBD

@SMoraisAnsys
SMoraisAnsys requested a review from a team as a code owner July 25, 2026 06:56
@github-actions github-actions Bot added the enhancement General improvements to existing features label Jul 25, 2026
@SMoraisAnsys
SMoraisAnsys marked this pull request as draft July 25, 2026 16:41
@github-actions github-actions Bot added the ci Pipelines maintenance related label Jul 25, 2026
@SMoraisAnsys
SMoraisAnsys force-pushed the feat/use-uv-lock-file branch from 17f742f to 6932c1a Compare July 28, 2026 16:16
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

@SMoraisAnsys SMoraisAnsys self-assigned this Jul 29, 2026
@SMoraisAnsys
SMoraisAnsys marked this pull request as ready for review July 29, 2026 07:36

@moe-ad moe-ad left a comment

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.

Thanks for the changes @SMoraisAnsys, I left a couple of comments.

There is one other thing I have been thinking about, why can't we just use the uv lock files automatically once detected rather than exposing an explicit input for it (similar to how there is no input for poetry). IMO, a project that already uses a lock file would expect its dependencies to be install from it.

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 ?

Comment thread build-library/action.yml Outdated
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.

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

python-version: ${{ env.MAIN_PYTHON_VERSION }}
attest-provenance: true
use-uv-lockfile: ${{ matrix.repository.name == 'pyansys-geometry' }}
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))

Comment thread .github/workflows/ci_cd_pr_flit.yml
Comment thread .github/workflows/ci_cd_pr_flit.yml
Comment thread .github/workflows/ci_cd_pr_flit.yml
Comment thread check-vulnerabilities/action.yml Outdated
Comment thread check-vulnerabilities/action.yml Outdated
@SMoraisAnsys

Copy link
Copy Markdown
Contributor Author

Thanks for the changes @SMoraisAnsys, I left a couple of comments.

There is one other thing I have been thinking about, why can't we just use the uv lock files automatically once detected rather than exposing an explicit input for it (similar to how there is no input for poetry). IMO, a project that already uses a lock file would expect its dependencies to be install from it.

I'm fine with detecting it and activating it by default. My only concern is the sudden change of behavior for people that still work with version tag and/or don't read every release note carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pipelines maintenance related enhancement General improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants