Skip to content

Is it possible to avoid re-checking direct URL dependencies each command? #10088

@MrNaif2018

Description

@MrNaif2018

Hi! Basically the package I want to install is not being updated on PyPI anymore, and I tried adding it using git url:
If I try to install a package via git, it fails because the package's .gitmodules dependends on some enterprise packages I have no access to (there is an open issue in pip about similar thing, but from what I understand it is not yet implemented anywhere in packaging standards to fix this issue)

$ uv add "karrio @ git+https://github.com/karrioapi/karrio@v2024.12rc9#subdirectory=modules/sdk"
Updating https://github.com/karrioapi/karrio (v2024.12rc9)                                                                                                                                                                       × Failed to download and build `karrio @ git+https://github.com/karrioapi/karrio@v2024.12rc9#subdirectory=modules/sdk`
  ├─▶ Git operation failed
  ╰─▶ process didn't exit successfully: `/opt/homebrew/bin/git submodule update --recursive --init` (exit status: 1)
      --- stderr
      Submodule 'insiders' (git@github.com:karrioapi/karrio-insiders.git) registered for path 'ee/insiders'
      Submodule 'ee/platform' (git@github.com:karrioapi/karrio-platform.git) registered for path 'ee/platform'
      Cloning into '/Users/alex/.cache/uv/git-v0/checkouts/06471d48525cdc12/00aef3669/ee/insiders'...
      ERROR: Repository not found.
      fatal: Could not read from remote repository.

      Please make sure you have the correct access rights
      and the repository exists.
      fatal: clone of 'git@github.com:karrioapi/karrio-insiders.git' into submodule path '/Users/alex/.cache/uv/git-v0/checkouts/06471d48525cdc12/00aef3669/ee/insiders' failed
      Failed to clone 'ee/insiders'. Retry scheduled
      Cloning into '/Users/alex/.cache/uv/git-v0/checkouts/06471d48525cdc12/00aef3669/ee/platform'...
      ERROR: Repository not found.
      fatal: Could not read from remote repository.

      Please make sure you have the correct access rights
      and the repository exists.
      fatal: clone of 'git@github.com:karrioapi/karrio-platform.git' into submodule path '/Users/alex/.cache/uv/git-v0/checkouts/06471d48525cdc12/00aef3669/ee/platform' failed
      Failed to clone 'ee/platform'. Retry scheduled
      Cloning into '/Users/alex/.cache/uv/git-v0/checkouts/06471d48525cdc12/00aef3669/ee/insiders'...
      ERROR: Repository not found.
      fatal: Could not read from remote repository.

      Please make sure you have the correct access rights
      and the repository exists.
      fatal: clone of 'git@github.com:karrioapi/karrio-insiders.git' into submodule path '/Users/alex/.cache/uv/git-v0/checkouts/06471d48525cdc12/00aef3669/ee/insiders' failed
      Failed to clone 'ee/insiders' a second time, aborting

So I tried installing the usual workaround way:
Btw uv add seems to not support this, but I manually edited pyproject.toml and ran uv sync:

$ uv add "karrio @ https://github.com/karrioapi/karrio/archive/v2024.12rc9.zip#subdirectory=modules/sdk"
  × Failed to build `redacted @ file:///Users/alex/stuff/myproject`
  ├─▶ Failed to parse entry: `karrio`
  ╰─▶ Fragments are not allowed in URLs: `https://github.com/karrioapi/karrio/archive/v2024.12rc9.zip#subdirectory=modules/sdk`
$ uv sync
Resolved 99 packages in 648ms
Uninstalled 2 packages in 12ms
Installed 2 packages in 4ms
 ~ karrio==2024.12rc3 (from https://github.com/karrioapi/karrio/archive/v2024.12rc9.zip#subdirectory=modules/sdk)

But the problem is, each time I run any uv command, e.g. uv run, it tries to re-check the dependency

$ uv run task api
Uninstalled 2 packages in 13ms
Installed 2 packages in 4ms
INFO:     Uvicorn running on http://127.0.0.1:8002 (Press CTRL+C to quit)

Is there any way to fix this? I tried adding metadata to pyproject.toml so that uv doesn't resolve it each time, like this:

[[tool.uv.dependency-metadata]]
name = "karrio"
version = "2024.12rc3"
requires-dist = [
    "jstruct",
    "xmltodict",
    "lxml",
    "lxml-stubs",
    "py-soap",
    "Pillow",
    "phonenumbers",
    "python-barcode",
    "PyPDF2",
]

But I get another error:

$ uv sync
Resolved 99 packages in 710ms
error: Since the package `karrio==2024.12rc3 @ direct+https://github.com/karrioapi/karrio/archive/v2024.12rc9.zip` comes from a direct dependency, a hash was expected but one was not found for direct URL source distribution

Is there a simpler way to "cache" the dependency? Thanks in advance!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions