Skip to content

Commit ec05ac1

Browse files
committed
Add archives in Git to Direct URL schema
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
1 parent 736275c commit ec05ac1

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎extra/specifications/schemas/direct-url.schema.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
},
6767
"subdirectory": {
6868
"$ref": "#/definitions/subdirectory"
69+
},
70+
"file": {
71+
"type": "string"
6972
}
7073
},
7174
"required": ["url"]

‎source/specifications/direct-url-data-structure.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ A top-level ``subdirectory`` field MAY be present containing a directory path,
133133
relative to the root of the VCS repository, source archive or local directory,
134134
to specify where ``pyproject.toml`` or ``setup.py`` is located.
135135

136+
.. _direct-url-data-structure-archives-in-git:
137+
138+
Archives in Version Control
139+
---------------------------
140+
141+
A top-level ``file`` field MAY be present for VCS repositories, containing the
142+
location of an archive relative to the root of a VCS repository. The filename
143+
of the path must be a valid distribution name. This key is mutually exclusive
144+
with ``subdirectory``. Note that ``file`` has no PEP 508 equivalent.
145+
136146
.. _direct-url-data-structure-registered-vcs:
137147

138148
Registered VCS

0 commit comments

Comments
 (0)