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

Add docs for uv pip compile and renovate #11204

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Feb 3, 2025

Support landed upstream

@zanieb zanieb added the documentation Improvements or additions to documentation label Feb 3, 2025
@zanieb zanieb force-pushed the zb/renovate-compile branch from b93b0ba to dda616c Compare February 3, 2025 22:53
@zanieb
Copy link
Member Author

zanieb commented Feb 3, 2025

cc @mkniewallner (as an authority on these docs)

@mkniewallner
Copy link
Contributor

Tried the feature in Renovate (from main branch, as their GitHub app uses a version that predates the feature), but there are several things missing/not working.

First, it doesn't seem to support dependencies defined in pyproject.toml at all, as I've tried:

and I ended up with different errors on the 3 attempts when running:

RENOVATE_TOKEN=<GITHUB_TOKEN> LOG_LEVEL=DEBUG npx renovate@latest mkniewallner/mkv-playground

With uv pip compile pyproject.toml -o requirements.txt I got:

 WARN: pip-compile error (repository=mkniewallner/mkv-playground)
       "fileMatch": "requirements.txt",
       "errorMessage": "Option -o not supported (yet)"

With uv pip compile pyproject.toml --output-file requirements.txt I got:

 WARN: pip-compile error (repository=mkniewallner/mkv-playground)
       "fileMatch": "requirements.txt",
       "errorMessage": "Option --output-file must have equal sign '=' separating it's argument"

With uv pip compile pyproject.toml --output-file=requirements.txt it seems that the header was at least fully handled, but then it showed that pyproject.toml does not look to be supported, and Renovate ended up "guessing" that the project uses Poetry and crashed as there is no [tool] section:

DEBUG: pip-compile: extracted command from header (repository=mkniewallner/mkv-playground)
       "fileName": "requirements.txt",
       "argv": ["uv", "pip", "compile", "pyproject.toml", "--output-file=requirements.txt"],
       "commandType": "uv"
DEBUG: Poetry: error parsing pyproject.toml (repository=mkniewallner/mkv-playground, packageFile=pyproject.toml)
       "err": {
         "message": "Schema error",
         "stack": "ZodError: Schema error\n    at Object.get error [as error] (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/zod/lib/types.js:55:31)\n    at fromZodResult (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/util/result.ts:60:67)\n    at Function.parse (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/util/result.ts:566:12)\n    at Object.extractPackageFile (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/modules/manager/poetry/extract.ts:19:36)\n    at extractPackageFile (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/modules/manager/index.ts:75:9)\n    at getManagerPackageFiles (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/extract/manager-files.ts:58:43)\n    at /home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/extract/index.ts:57:28\n    at async Promise.all (index 4)\n    at extractAllDependencies (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/extract/index.ts:54:26)\n    at extract (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/process/extract-update.ts:160:28)\n    at extractDependencies (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/process/index.ts:158:26)\n    at Object.renovateRepository (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/index.ts:71:9)\n    at attributes.repository (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/global/index.ts:206:11)\n    at start (/home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/global/index.ts:191:7)\n    at /home/mathieu/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/renovate.ts:19:22",
         "issues": {"tool": "Required"}
       }
 WARN: pip-compile: support for manager is not yet implemented (repository=mkniewallner/mkv-playground, packageFile=pyproject.toml)
       "manager": "pep621"
 WARN: pip-compile: failed to find dependencies in source file (repository=mkniewallner/mkv-playground, packageFile=pyproject.toml)

What did work though is defining dependencies in requirements.in (mkniewallner/mkv-playground@9f8323a): https://github.com/mkniewallner/mkv-playground/pull/23/files. But I'm pretty confident it suffers from the same limitations as above, meaning:

  • if uv pip compile requirements.in -o requirements.txt or uv pip compile requirements.in --output-file requirements.txt was used, Renovate won't be able to create updates
  • if uv pip compile requirements.in --output-file=requirements.txt was used, it will though

So in the current state, I would not recommend announcing support for it. I can raise the issues I've found in Renovate repository and/or work on some of the issues/features.

If support for -o <file> and --output-file <file> ends up being added, we could at least announce that requirements.in is handled, but not pyproject.toml.

Comment on lines +79 to +86
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
{
"pip-compile": {
fileMatch: ["(^|/)requirements\\.txt$"],
},
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
{
"pip-compile": {
fileMatch: ["(^|/)requirements\\.txt$"],
},
};
}
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
"pip-compile": {
fileMatch: ["(^|/)requirements\\.txt$"],
},
}

@zanieb
Copy link
Member Author

zanieb commented Feb 4, 2025

Thank you so much! Appreciate it.

I guess I should have tried it.. :)

@zanieb zanieb marked this pull request as draft February 4, 2025 00:03
@adrianeboyd
Copy link

Now that the github app has updated to a newer version of renovate, I tried the version of replacing pip-compile with uv pip compile in the headers (with --output-file=), and end up with this error:

ExecError: Command failed: uv pip compile requirements.in --output-file=requirements.txt
/bin/sh: 1: uv: not found

    at ChildProcess.<anonymous> (/usr/local/renovate/lib/util/exec/common.ts:119:11)
    at ChildProcess.emit (node:events:536:35)
    at ChildProcess.emit (node:domain:489:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)

I can see it installing python and pip-tools in the logs, so possibly there's somewhere else in the config settings to add uv as a tool, but I don't know where. I also tried adding [tool.uv] section to pyproject.toml but run into the same poetry error as mentioned earlier in this thread.

@mkniewallner
Copy link
Contributor

Now that the github app has updated to a newer version of renovate, I tried the version of replacing pip-compile with uv pip compile in the headers (with --output-file=), and end up with this error:

ExecError: Command failed: uv pip compile requirements.in --output-file=requirements.txt
/bin/sh: 1: uv: not found

    at ChildProcess.<anonymous> (/usr/local/renovate/lib/util/exec/common.ts:119:11)
    at ChildProcess.emit (node:events:536:35)
    at ChildProcess.emit (node:domain:489:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)

I can see it installing python and pip-tools in the logs, so possibly there's somewhere else in the config settings to add uv as a tool, but I don't know where. I also tried adding [tool.uv] section to pyproject.toml but run into the same poetry error as mentioned earlier in this thread.

Renovate installs the tools it needs based on the package managers it detects. In Renovate, uv pip compile support was added on top of the existing pip-compile manager, but there is one missing piece it seems, as the required tools are constructed here and here, which for now always assume that pip-tools is used, and doesn't handle uv.

As this is an issue in Renovate itself, feel free to open a discussion on Renovate repository to report the issue.

@mkniewallner
Copy link
Contributor

As this is an issue in Renovate itself, feel free to open a discussion on Renovate repository to report the issue.

Actually, there is already a PR in review for handling this: renovatebot/renovate#34029.

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

Successfully merging this pull request may close these issues.

3 participants