Hi! We are using a local index based off PEP 503 to serve our local packages.
It is not mentioned in PEP 503 (so it’s not officially part of the spec), but replacing links to dist files in the index with VCS links works if the #egg
fragment is used to specify package name and version.
i.e. replacing:
<!DOCTYPE html>
<html>
<body>
<a href="https://example.org/group/package-1.0.0.tar.gz">package-1.0.0.tar.gz</a>
</body>
</html>
with:
<!DOCTYPE html>
<html>
<body>
<a href="git+https://git@example.org/group/package@1.0.0#egg=package-1.0.0">package@1.0.0</a>
</body>
</html>
This allows us to install source-based distributions directly from our git repos. However, I am wondering if it might be by chance, or even somewhat of a hack, that this works since not part of PEP 503. Indeed, it states:
The href attribute MUST be a URL that links to the location of the file for download, and the text of the anchor tag MUST match the final path component (the filename) of the URL.
An issue is that since egg distributions are now deprecated (The Internal Structure of Python Eggs - setuptools 74.0.0.post20240830 documentation), the #egg
fragment, although currently supported by pip (pip install - pip documentation v24.2), seems a bad idea to use (or is it in plans to continue using egg_info
?)
Therefore:
- Is it conceivable to officially allow the index to point to a VCS?
- Is there a replacement for the
#egg
fragment? i.e. what can I use to specify package name and version when linking to VCS? Looking at pip’s source code, there doesn’t seem to be.
Naively, I tried to have our index set the anchor’s href value a PEP 508 URL:
package@git+https://git@example.org/group/package@1.0.0
but this fails with pip complaining that the trailing .0
is not a supported file format.
So while I can do from the CLI:
pip install package@git+https://git@example.org/group/package@1.0.0
,
I cannot use this link in my index since pip expects a file if an #egg
fragment is not present.
Conversely, if an #egg
fragment is present, pip doesn’t check if the link is to a file, and retains it as a candidate for installation.