-
Notifications
You must be signed in to change notification settings - Fork 7
feat: use uv lock file #1427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: use uv lock file #1427
Changes from 20 commits
47051c2
4cef1c2
5ec64d2
f3cee24
83e60ca
53ed4db
5fe8fc6
b5c507e
48bc226
0ba1a55
10ddec7
41f5114
32cd596
940bac6
8e525b6
cc9b64f
6932c1a
1b687e1
759836d
c55b759
e0f044e
33d926e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -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'] | ||||
|
|
@@ -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' }} | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest creating a separate workflow ( Although
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' }} | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||||
|
|
@@ -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: | ||||
|
|
@@ -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' }} | ||||
|
SMoraisAnsys marked this conversation as resolved.
|
||||
| use-uv: ${{ matrix.repository.name == 'pyansys-geometry' }} | ||||
|
SMoraisAnsys marked this conversation as resolved.
|
||||
|
|
||||
| test-check-licenses-flit-projects: | ||||
| name: "Test check-licenses action for ${{ matrix.repository.name }} project" | ||||
|
|
@@ -291,6 +293,9 @@ jobs: | |||
| use-python-cache: false | ||||
| use-prek: ${{ matrix.use-prek }} | ||||
| checkout: false | ||||
| use-uv-lockfile: ${{ matrix.repository.name == 'pyansys-geometry' }} | ||||
|
SMoraisAnsys marked this conversation as resolved.
|
||||
| use-uv: ${{ matrix.repository.name == 'pyansys-geometry' }} | ||||
|
SMoraisAnsys marked this conversation as resolved.
|
||||
| skip-install: false | ||||
|
|
||||
| test-doc-style-flit-projects: | ||||
| name: "Test doc-style action for ${{ matrix.repository.name }} project" | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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 }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this is not possible because |
||
| 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 }} | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, why this change? Did the previous implementation start failing?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Use uv lock file |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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