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

Add archives in Git to Direct URL schema #1798

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

konstin
Copy link
Contributor

@konstin konstin commented Jan 31, 2025

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/

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
@webknjaz
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants