uv
fda22761 - Allow users to provide pre-defined metadata for resolution (#7442)

Comment changes are shownComment changes are hidden
Commit
293 days ago
Allow users to provide pre-defined metadata for resolution (#7442) ## Summary This PR enables users to provide pre-defined static metadata for dependencies. It's intended for situations in which the user depends on a package that does _not_ declare static metadata (e.g., a `setup.py`-only sdist), and that is expensive to build or even cannot be built on some architectures. For example, you might have a Linux-only dependency that can't be built on ARM -- but we need to build that package in order to generate the lockfile. By providing static metadata, the user can instruct uv to avoid building that package at all. For example, to override all `anyio` versions: ```toml [project] name = "project" version = "0.1.0" requires-python = ">=3.12" dependencies = ["anyio"] [[tool.uv.dependency-metadata]] name = "anyio" requires-dist = ["iniconfig"] ``` Or, to override a specific version: ```toml [project] name = "project" version = "0.1.0" requires-python = ">=3.12" dependencies = ["anyio"] [[tool.uv.dependency-metadata]] name = "anyio" version = "3.7.0" requires-dist = ["iniconfig"] ``` The current implementation uses `Metadata23` directly, so we adhere to the exact schema expected internally and defined by the standards. Any entries are treated similarly to overrides, in that we won't even look for `anyio@3.7.0` metadata in the above example. (In a way, this also enables #4422, since you could remove a dependency for a specific package, though it's probably too unwieldy to use in practice, since you'd need to redefine the _rest_ of the metadata, and do that for every package that requires the package you want to omit.) This is under-documented, since I want to get feedback on the core ideas and names involved. Closes https://github.com/astral-sh/uv/issues/7393.
Author
Parents
  • crates
    • bench/benches
      • File
        uv.rs
    • distribution-types/src
      • File
        dependency_metadata.rs
      • File
        lib.rs
    • pep508-rs/src
      • File
        lib.rs
    • uv-cli/src
      • File
        options.rs
    • uv-dispatch/src
      • File
        lib.rs
    • uv-distribution/src
      • File
        distribution_database.rs
    • uv-resolver/src/lock
      • File
        mod.rs
      • snapshots
        • uv_resolver__lock__tests__hash_optional_missing.snap
        • uv_resolver__lock__tests__hash_optional_present.snap
        • uv_resolver__lock__tests__hash_required_present.snap
        • uv_resolver__lock__tests__missing_dependency_source_unambiguous.snap
        • uv_resolver__lock__tests__missing_dependency_source_version_unambiguous.snap
        • uv_resolver__lock__tests__missing_dependency_version_unambiguous.snap
        • uv_resolver__lock__tests__source_direct_has_subdir.snap
        • uv_resolver__lock__tests__source_direct_no_subdir.snap
        • uv_resolver__lock__tests__source_directory.snap
        • uv_resolver__lock__tests__source_editable.snap
    • uv-settings/src
      • File
        settings.rs
    • uv-types/src
      • File
        traits.rs
    • uv
      • src
        • commands
          • File
            build.rs
          • pip
            • File
              compile.rs
            • File
              install.rs
            • File
              sync.rs
          • project
            • File
              add.rs
            • File
              lock.rs
            • File
              mod.rs
            • File
              sync.rs
          • File
            venv.rs
        • File
          lib.rs
        • File
          settings.rs
      • tests
        • File
          lock.rs
        • File
          show_settings.rs
  • docs
    • concepts
      • File
        projects.md
      • File
        resolution.md
    • reference
      • File
        settings.md
  • File
    uv.schema.json