Source distribution tarballs on pypi do not contain README.md, causing hatch-fancy-pypi-readme plugin to fail
Problem
The source distributions published to pypi presently cannot be built; attempts fail with: [code block] Inspecting the tarball to list non-`.py` content shows only: [code block] Notably, there is indeed no README.md file present.
Error Output
Error: ["Fragment file 'README.md' not found."]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Ensure README.md is included in source distributions for PyPI
The source distribution tarballs published to PyPI do not include the README.md file due to misconfiguration in the setup script. This omission prevents the hatch-fancy-pypi-readme plugin from functioning correctly, as it relies on the presence of the README.md file to generate the package's documentation.
Awaiting Verification
Be the first to verify this fix
- 1
Update setup.py to include README.md
Modify the setup.py file to ensure that README.md is included in the source distribution. This can be done by adding the README.md file to the 'packages' or 'package_data' argument.
pythonfrom setuptools import setup, find_packages setup( name='your_package_name', version='0.1', packages=find_packages(), include_package_data=True, package_data={'': ['README.md']}, long_description=open('README.md').read(), long_description_content_type='text/markdown', ) - 2
Rebuild the source distribution
After updating the setup.py file, rebuild the source distribution using the following command. This will create a new tarball that includes the README.md file.
bashpython setup.py sdist - 3
Upload the new source distribution to PyPI
Upload the newly created source distribution to PyPI using Twine. This ensures that the updated tarball, which now includes the README.md file, is available for users.
bashtwine upload dist/* - 4
Verify the uploaded package
Check the uploaded package on PyPI to confirm that the README.md file is included in the source distribution. You can download the tarball and inspect its contents to ensure the README.md is present.
bashpip download your_package_name --no-binary :all: # Then extract and check the contents
Validation
To confirm the fix worked, download the new source distribution from PyPI and extract it. Ensure that the README.md file is present in the extracted contents. Additionally, verify that the hatch-fancy-pypi-readme plugin functions correctly with the updated package.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep