-
Notifications
You must be signed in to change notification settings - Fork 35
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
Broken links on PyPI #752
Comments
You must use the full URLs for the README. PyPI does not support hosting your full documentation, only one page - the package "readme" (which is part of your metadata). If you want to have relative links in your on-disk/git |
OK I am taking a look at the hatch-fancy-pypi-readme repo, however since I am using setup.py, if you are able to point me at some specific source code within the repo I can use / repurpose, that would be helpful Thanks! |
Not tested and I used ChatGPT to write the expression, but something like this: import re
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read() Then I asked ChatGPT and this is what it gave me: import re
# Sample markdown text
long_description = """
Here is a [sample relative link](../path/to/page) in markdown format.
And here is another [relative link](../another/path) for demonstration.
And here is an [absolute link](https://example.com) to be ignored.
"""
# Base URL
base_url = "https://github.com/a/b"
def convert_to_absolute(match):
text = match.group(1)
relative_url = match.group(2)
absolute_url = f"{base_url.rstrip('/')}/{relative_url.lstrip('/')}"
return f"[{text}]({absolute_url})"
# Replace relative links with absolute links
long_description = re.sub(r'\[([^\[\]]+)\]\((?!https?://)([^/\(\)]+)\)', convert_to_absolute, long_description) That's not exactly how I'd write it, but hopefully that's close enough to help? |
OK thanks. Just as a brainstorm, it would be cool to be able to hook into the functionality of So desired usage would be something like: # this is the setup.py file
from setuptools import setup
from hatch_fancy_pypi_readme import fix_relative_links
long_description = fix_relative_links("README.md", base_url="https://github.com/user-name/repo-name")
setup(
# ...
long_description=long_description,
long_description_content_type="text/markdown"
# ...
) |
Do you have a specific reason for needing setuptools and |
Problem description
I am publishing my package to PyPI, and my repository's README file is displayed on PyPI as desired.
However all the markdown links in the README file that point to other documentation files in my repo are broken.
Because the README file markdown link is like this
[other file](/docs/other.md)
, PyPI sends the user to https://pypi.org/docs/other.md instead of to the relative file in my repo.What is the intended way to fix this issue? Absolute links is not what I'm looking for.
See:
The text was updated successfully, but these errors were encountered: