From ec05ac16a0c25753da8ec6b0ea266eaa82c5a894 Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 31 Jan 2025 15:34:28 +0100 Subject: [PATCH 1/4] 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 --- extra/specifications/schemas/direct-url.schema.json | 3 +++ source/specifications/direct-url-data-structure.rst | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/extra/specifications/schemas/direct-url.schema.json b/extra/specifications/schemas/direct-url.schema.json index 1e110b193f..46081e2b72 100644 --- a/extra/specifications/schemas/direct-url.schema.json +++ b/extra/specifications/schemas/direct-url.schema.json @@ -66,6 +66,9 @@ }, "subdirectory": { "$ref": "#/definitions/subdirectory" + }, + "file": { + "type": "string" } }, "required": ["url"] diff --git a/source/specifications/direct-url-data-structure.rst b/source/specifications/direct-url-data-structure.rst index a82537f0ad..2a1a07ad59 100644 --- a/source/specifications/direct-url-data-structure.rst +++ b/source/specifications/direct-url-data-structure.rst @@ -133,6 +133,16 @@ A top-level ``subdirectory`` field MAY be present containing a directory path, relative to the root of the VCS repository, source archive or local directory, to specify where ``pyproject.toml`` or ``setup.py`` is located. +.. _direct-url-data-structure-archives-in-git: + +Archives in Version Control +--------------------------- + +A top-level ``file`` field MAY be present for VCS repositories, containing the +location of an archive relative to the root of a VCS repository. The filename +of the path must be a valid distribution name. This key is mutually exclusive +with ``subdirectory``. Note that ``file`` has no PEP 508 equivalent. + .. _direct-url-data-structure-registered-vcs: Registered VCS From bb8ed34d15ad8f1fb3760d3e58ba02cbd49e0253 Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 24 Nov 2026 13:28:43 +0100 Subject: [PATCH 2/4] distribution name -> archive name --- source/specifications/direct-url-data-structure.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/specifications/direct-url-data-structure.rst b/source/specifications/direct-url-data-structure.rst index 2a1a07ad59..391e97e467 100644 --- a/source/specifications/direct-url-data-structure.rst +++ b/source/specifications/direct-url-data-structure.rst @@ -140,7 +140,7 @@ Archives in Version Control A top-level ``file`` field MAY be present for VCS repositories, containing the location of an archive relative to the root of a VCS repository. The filename -of the path must be a valid distribution name. This key is mutually exclusive +of the path must be a valid archive name. This key is mutually exclusive with ``subdirectory``. Note that ``file`` has no PEP 508 equivalent. .. _direct-url-data-structure-registered-vcs: From fa5bab7cfe36543274762b4a8c38d2becfc3d270 Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 24 Nov 2026 15:31:29 +0100 Subject: [PATCH 3/4] Use a schema reference for the Direct URL file field --- extra/specifications/schemas/direct-url.schema.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extra/specifications/schemas/direct-url.schema.json b/extra/specifications/schemas/direct-url.schema.json index 46081e2b72..811fd8c6d9 100644 --- a/extra/specifications/schemas/direct-url.schema.json +++ b/extra/specifications/schemas/direct-url.schema.json @@ -11,6 +11,9 @@ "subdirectory": { "type": "string" }, + "file": { + "type": "string" + }, "DirInfo": { "type": "object", "properties": { @@ -68,7 +71,7 @@ "$ref": "#/definitions/subdirectory" }, "file": { - "type": "string" + "$ref": "#/definitions/file" } }, "required": ["url"] From 7e73aaab582b76cf334f87a449a29931e5f1ab57 Mon Sep 17 00:00:00 2001 From: konstin Date: Sat, 28 Nov 2026 21:23:54 +0100 Subject: [PATCH 4/4] Use `path` instead of `file` --- extra/specifications/schemas/direct-url.schema.json | 6 +++--- source/specifications/direct-url-data-structure.rst | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extra/specifications/schemas/direct-url.schema.json b/extra/specifications/schemas/direct-url.schema.json index 811fd8c6d9..ea53cc4818 100644 --- a/extra/specifications/schemas/direct-url.schema.json +++ b/extra/specifications/schemas/direct-url.schema.json @@ -11,7 +11,7 @@ "subdirectory": { "type": "string" }, - "file": { + "path": { "type": "string" }, "DirInfo": { @@ -70,8 +70,8 @@ "subdirectory": { "$ref": "#/definitions/subdirectory" }, - "file": { - "$ref": "#/definitions/file" + "path": { + "$ref": "#/definitions/path" } }, "required": ["url"] diff --git a/source/specifications/direct-url-data-structure.rst b/source/specifications/direct-url-data-structure.rst index 391e97e467..d4f335b66d 100644 --- a/source/specifications/direct-url-data-structure.rst +++ b/source/specifications/direct-url-data-structure.rst @@ -138,10 +138,10 @@ to specify where ``pyproject.toml`` or ``setup.py`` is located. Archives in Version Control --------------------------- -A top-level ``file`` field MAY be present for VCS repositories, containing the +A top-level ``path`` field MAY be present for VCS repositories, containing the location of an archive relative to the root of a VCS repository. The filename of the path must be a valid archive name. This key is mutually exclusive -with ``subdirectory``. Note that ``file`` has no PEP 508 equivalent. +with ``subdirectory``. Note that ``path`` has no PEP 508 equivalent. .. _direct-url-data-structure-registered-vcs: