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

Does not work with dependcies specified only as git repository in requirements.in without package name #98

Open
Glinte opened this issue Jan 26, 2025 · 5 comments
Labels
enhancement New feature or request manager:pip Relates to pip package manager manager:pip-tools Relates to pip-tools package manager

Comments

@Glinte
Copy link

Glinte commented Jan 26, 2025

One of my dependency is not on PyPI so I had to specify it like this

requirements.in:

git+https://github.com/Rapptz/discord-ext-menus

(I do realize that the more correct way to write this is discord-ext-menus @ git+https://github.com/Rapptz/discord-ext-menus while filing this issue)

requirements.txt:

discord-ext-menus @ git+https://github.com/Rapptz/discord-ext-menus
    # via -r requirements.in

It does not end up in my uv.lock and I have to add it manually via uv add git+https://github.com/Rapptz/discord-ext-menus

@Glinte Glinte changed the title Does not work with dependcies specified as git repository Does not work with dependcies specified as git repository in requirements.in/txt Jan 26, 2025
@mkniewallner
Copy link
Owner

Right now only PEP 508 dependencies are handled, but we should at least add a warning when we are not able to parse the dependency instead of silently skipping it.

Handling this shape of URLs is possible but only in a best-effort mode, as without the dependency name, we won't be able to know for sure the name of the package to add in the dependencies. We can guess it by parsing the last part of the URL for a git repository, but this won't handle cases where the package name is different from the last part of the URL.

For instance for https://github.com/fsspec/filesystem_spec, the Python package is fsspec, so if we try to add:

[project]
dependencies = ["filesystem_spec"]

[tool.uv.sources]
filesystem_spec = { git = "https://github.com/fsspec/filesystem_spec" }

When locking, we will end up with the following error:

$ uv lock
 Updated https://github.com/fsspec/filesystem_spec (216885a)
  × Failed to download and build `filesystem-spec @ git+https://github.com/fsspec/filesystem_spec`
  ╰─▶ Package metadata name `fsspec` does not match given name `filesystem-spec`

@Glinte
Copy link
Author

Glinte commented Jan 26, 2025

Yeah, it is just unfortunate that pip-tools/uv is able to resolve this because (I assume) they probably actually go into the git repo to find the package name+dependencies, and thus no warning is ever given to me that I am doing something wrong 🤷

@mkniewallner
Copy link
Owner

Yeah, it is just unfortunate that pip-tools/uv is able to resolve this because (I assume) they probably actually go into the git repo to find the package name+dependencies, and thus no warning is ever given to me that I am doing something wrong 🤷

Is it supported in uv? Even when using the alternative syntax (which allows defining a git dependency à la pip, without adding a source), it does not work and expects a strict PEP 508 format on my side (using version 0.5.24):

[project]
name = "foo"
version = "0.0.1"
dependencies = ["git+https://github.com/Rapptz/discord-ext-menus"]
$ uv lock
[...]
ValueError: invalid pyproject.toml config: `project.dependencies[0]`.
configuration error: `project.dependencies[0]` must be pep508

Same if using uv pip:

$ uv pip compile
[...]
ValueError: invalid pyproject.toml config: `project.dependencies[0]`.
configuration error: `project.dependencies[0]` must be pep508

While it does work fine when using PEP 508 format:

[project]
name = "foo"
version = "0.0.1"
dependencies = ["discord-ext-menus @ git+https://github.com/Rapptz/discord-ext-menus"]

@Glinte
Copy link
Author

Glinte commented Jan 26, 2025

It does not end up in my uv.lock and I have to add it manually via uv add git+https://github.com/Rapptz/discord-ext-menus

I guess not if you do it manually, but uv is able to resolve the package name if you do uv add

@Glinte Glinte changed the title Does not work with dependcies specified as git repository in requirements.in/txt Does not work with dependcies specified only as git repository in requirements.in/txt without package name Jan 26, 2025
@Glinte Glinte changed the title Does not work with dependcies specified only as git repository in requirements.in/txt without package name Does not work with dependcies specified only as git repository in requirements.in without package name Jan 26, 2025
@mkniewallner
Copy link
Owner

It does not end up in my uv.lock and I have to add it manually via uv add git+https://github.com/Rapptz/discord-ext-menus

I guess not if you do it manually, but uv is able to resolve the package name if you do uv add

Oh yeah indeed!

Maybe we could have a special case for those dependencies and use uv add --frozen <dependency_specification> instead of manually adding them in pyproject.toml. This would likely also solve other kind of dependencies like URLs to archives that do not conform to PEP 508 if they don't use <name> @ <url>.

@mkniewallner mkniewallner added enhancement New feature or request manager:pip Relates to pip package manager manager:pip-tools Relates to pip-tools package manager labels Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request manager:pip Relates to pip package manager manager:pip-tools Relates to pip-tools package manager
Projects
None yet
Development

No branches or pull requests

2 participants