Skip to content
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

Enable setting up version from .uv-version file #215

Closed
paduszyk opened this issue Dec 27, 2024 · 8 comments · Fixed by #233
Closed

Enable setting up version from .uv-version file #215

paduszyk opened this issue Dec 27, 2024 · 8 comments · Fixed by #233

Comments

@paduszyk
Copy link

The uv project changes dynamically, so keeping both local and CI version of uv might be challenging. In order to keep both versions consistent, I would suggest to enable pinning them in a "version" file.

For example, this can be achieved by adding an extra input variable:

name: uv

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  uv:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v4
        with:
          enable-cache: true
          version-file: .uv-version  # <- this is the idea of this issue
      - uses: actions/setup-python@v5
        with:
          python-version-file: .python-version
      - run: uv lock --locked

The file could be also auto-detected if neither version nor version-file is explicitly stated.

@eifinger
Copy link
Collaborator

Thank you for opening this issue. Can you please add context on how this would work locally? This seams to me like this is a feature request for uv itself to detect this file and automatically upgrade/downgrade itself depending on the content?

@my1e5
Copy link

my1e5 commented Jan 3, 2025

Related - uv 0.5.14 just added a new feature allowing you to specify a required-version

[tool.uv]
required-version = ">=0.5.0"

see https://docs.astral.sh/uv/reference/settings/#required-version and astral-sh/uv#10248

@my1e5
Copy link

my1e5 commented Jan 3, 2025

Also there is previous discussion here about pinning a uv version for use with setup-uv

@paduszyk
Copy link
Author

paduszyk commented Jan 3, 2025

@my1e5 Thanks!

But does astral-sh/setup-uv action respect this config? Suppose I will go with uv.toml:

required-version = "==0.5.14"

Will the action use that specifier when setting version input?

@homeworkprod
Copy link

It is my understanding uv itself will respect the required version; the action doesn't have to do that.

I had success with setting the required verson in pyproject.toml and removing the part of the action's configuration that set a specific version.

@eifinger
Copy link
Collaborator

eifinger commented Jan 8, 2025

It is my understanding uv itself will respect the required version; the action doesn't have to do that.

I had success with setting the required verson in pyproject.toml and removing the part of the action's configuration that set a specific version.

I guess this worked because you specified the latest version in pyproject.toml and by removing the version constraint in the action it defaulted to the latest version.

As explained in the docs:

If the version of uv does not meet the requirement at runtime, uv will exit with an error.

I will add support to automatically read the version from the required-version setting for this action.

@homeworkprod
Copy link

I guess this worked because you specified the latest version in pyproject.toml and by removing the version constraint in the action it defaulted to the latest version.

I don't seem to get what you're saying exactly. Is it about specifying the latest version (or specifically 0.5.14 as the first to support this) as minimum required version in pyproject.toml? And/or is it about the default version of the setup-uv action?

My goal was that the latest version of uv is being used in CI, and that works so far. For example, with required-version = ">=0.5.14" in pyproject.toml, the GitHub action, when run later, installed 0.5.15 as it became available.

eifinger added a commit that referenced this issue Jan 13, 2025
1. If defined use version input
2. If defined use uv-file input
3. If defined use pyproject-file input
4. Search for required-version in uv.toml in repo root
5. Search for required-version in pyproject.toml in repo root
6. Use latest

Closes: #215
@eifinger
Copy link
Collaborator

eifinger commented Jan 13, 2025

I added the following new behavior:

  1. If defined, use version input
  2. If defined, use uv-file input
  3. If defined, use pyproject-file input
  4. Search for required-version in uv.toml in repo root
  5. Search for required-version in pyproject.toml in repo root
  6. Use latest

It will be part of the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants