Skip to content

Add archives in Git to Direct URL schema - #1798

Open
konstin wants to merge 3 commits into
pypa:mainfrom
konstin:konsti/archives-in-git
Open

konstin wants to merge 3 commits into
pypa:mainfrom
konstin:konsti/archives-in-git

Conversation

@konstin

@konstin konstin commented Jan 31, 2025 •

Copy link
Copy Markdown
Contributor

Many packaging tools, such as pdm, hatch and uv, extend over PEP 621 allow relative paths in their pyproject.toml (pdm, hatch, uv). This means you can have a dependency on a git repository, and the package in that git repository has a dependency on another package in directory or file in that repository.

Currently, direct_url.json can only represent subdirectories in a git repository, but not files. This PR tries to fix this asymmetry and make this transitive source representable. It adds a new key file to direct_url.json that contains the relative path to a source distribution or a wheel. It is mutually exclusive with subdirectory, which does the same except pointing to a directory instead of a file.

Unlike other entries in direct_url.json, this can not be translated back to PEP 518 lacking both archive-in-git and relative path support in PEP 508. It is needed to correctly represent the installation for tools that do support relative paths in dependencies.

The name of the key is up for bikeshedding (as is other terminology that we want to align to existing usage).

CC @ofek (hatch), @frostming (pdm), @radoering (poetry) in hopes this is relevant for you too


📚 Documentation preview 📚: https://python-packaging-user-guide--1798.org.readthedocs.build/en/1798/

@webknjaz

Copy link
Copy Markdown
Member

@konstin try also starting a discussion on dpo — people are sometimes more active over there.

@rgommers rgommers added type: enhancement A self-contained enhancement or new feature component: specifications labels Nov 10, 2026

@rgommers rgommers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @konstin. This accumulated a merge conflict; could you rebase that and re-check it? Then I'll review again.

I did do a quick review pass (using Codex) - it identified that uv merged support recently in astral-sh/uv#10072 - can you check that this PR agrees with that?

Many packaging tools, such as pdm, hatch and uv, extend over PEP 621 allow relative paths in their pyproject.toml ([pdm](https://pdm-project.org/en/latest/reference/pep621/#relative-paths), [hatch](https://hatch.pypa.io/1.3/config/dependency/#local), [uv](https://docs.astral.sh/uv/concepts/projects/dependencies/#path)). This means you can have a dependency on a git repository, and the package in that git repository has a dependency on another package in directory or file in that repository.

Currently, `direct_url.json` can only represent subdirectories in a git repository, but not files. This PR tries to fix this asymmetry and make this transitive source representable. It adds a new key `file` to `direct_url.json` that contains the relative path to a source distribution or a wheel. It is mutually exclusive with `subdirectory`, which does the same except pointing to a directory instead of a file.

Unlike other entries in `direct_url.json`, this can not be translated back to PEP 518 lacking both archive-in-git and relative path support in PEP 518. It is needed to correctly represent the installation for tools that do support relative paths in dependencies.

The name of the key is up for bikeshedding.

CC @ofek (hatch), @frostming (pdm), @radoering (poetry) in hopes this is relevant for you too
@konstin
konstin force-pushed the konsti/archives-in-git branch from ca7b7b1 to f5742eb Compare November 24, 2026 12:23
@rgommers

Copy link
Copy Markdown
Contributor

it identified that uv merged support recently in astral-sh/uv#10072 - can you check that this PR agrees with that?

This is still open. It looks like uv uses path rather than file as the name, and that does end up in direct_url.json it looks like:

https://github.com/astral-sh/uv/blob/eb03cc21cf3f7e237bcf3e874444a9b0ba5bf04b/crates/uv-pypi-types/src/direct_url.rs#L51
https://github.com/astral-sh/uv/blob/eb03cc21cf3f7e237bcf3e874444a9b0ba5bf04b/crates/uv-pypi-types/src/direct_url.rs#L388-L398

This is a spec addition right, so is the idea you'd change the uv implementation if file gets added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: specifications type: enhancement A self-contained enhancement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants