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

Spurious warning with --no-project --only-group <group>? #10743

Open
woodruffw opened this issue Jan 18, 2025 · 3 comments
Open

Spurious warning with --no-project --only-group <group>? #10743

woodruffw opened this issue Jan 18, 2025 · 3 comments
Assignees
Labels
question Asking for clarification or support

Comments

@woodruffw
Copy link

Hello! As always, thanks for all the amazing work you've done on uv and ruff.

I tried searching for an open issue for this, and couldn't find one. Please close with prejudice if there is one that I've missed!

Problem

This isn't a breaking problem per se, since it appears to work. However, it produces a spurious warning that I suspect is a holdover from an earlier restriction 🙂

I have a pyproject.toml that looks like this:

[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.maturin]
bindings = "bin"

[dependency-groups]
docs = ["mkdocs ~= 1.6", "mkdocs-material[imaging] ~= 9.5"]

Notably, the pyproject.toml has no [project] section (since it's a Maturin-based pure-Rust project that pulls all metadata from Cargo.toml). My goal is to ideally keep it that way, to reduce duplication between the two files.

With that configuration, I'm using uv run --no-project --only-group docs mkdocs build to build my (mkdocs-based) documentation.

Expected behavior

I expect uv run --no-project --only-group docs mkdocs build to produce no warnings, and run mkdocs correctly.

Actual behavior

The command warnings that --only-group docs and --no-project have no effect alongside each other, but then runs successfully:

$ uv run --no-project --only-group docs mkdocs build
warning: `--only-group docs` has no effect when used alongside `--no-project`
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /<blah>/zizmor/site_html
INFO    -  Documentation built in 0.84 seconds

Workarounds

I can add a dummy [project] section containing just a name key, which hushes the warning. However I think the warning is still spurious, since (IIUC) the semantics of PEP 735 dep groups are not dependent on project metadata at all.

@woodruffw
Copy link
Author

Actually, it looks like caching may have been masking a larger problem here: when I run the same --no-project --only-group docs command in CI, I get a command error for mkdocs:

uv run --no-project --only-group docs mkdocs build
warning: `--only-group docs` has no effect when used alongside `--no-project`
error: Failed to spawn: `mkdocs`
  Caused by: No such file or directory (os error 2)
make: *** [Makefile:7: site] Error 2
Error: Process completed with exit code 2.

(CI logs: https://github.com/woodruffw/zizmor/actions/runs/12847160565/job/35823153622)

Whereas locally this command succeeds.

@charliermarsh
Copy link
Member

Hmm, I think this is intentional behavior -- I wouldn't expect us to discover that pyproject.toml if it's lacking a [project] or [tool.uv.workspace] table. I'm guessing that if you run with --verbose, it says something like No project found? We don't have first-class support for "projects without a [project] table right now.

@charliermarsh charliermarsh added the question Asking for clarification or support label Jan 18, 2025
@woodruffw
Copy link
Author

Aha, indeed!

WARN Ignoring project discovery error due to `--no-project`: No `project` table found in: `/home/william/devel/zizmor/pyproject.toml`
warning: `--only-group docs` has no effect when used alongside `--no-project`

In that case, I think this is a feature request: it'd be great to be able to express dependency-groups in a pyproject.toml without requiring a [project] block!

But I can also understand if this is not a well-defined part of packaging, and I have a perfectly functional workaround 🙂

@charliermarsh charliermarsh self-assigned this Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

2 participants