-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Use a trimmed version of README.md for PyPI #33637
Conversation
aeeccf3
to
2565fc7
Compare
2565fc7
to
6f81e3e
Compare
I think we do NOT want to maintain yet another README. My vision of is that the README will be automatically extracted from the main README by pre-commit (so ideally it should be placed in We could do it dynamically as well, but that would not fly with mostly declarative way how we want to build packages. So automatically generated file which is just truncated version of README.md commited in |
yes, good idea, will rather work on the extraction via pre-commit. |
6f81e3e
to
cdd8ae3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it
Really tiny NIT. in |
Super - Super NIT. It would also be great if the first line (or split in two lines) of the generated PYPIREADME.md contains something like that
You can also safely remove the Licence header when you generate it (though this might be a bit complex so we can leave it). The ASF requirement is that licence headers are present in files that are human-prepared, it does not have to be added to files which are automatically generated from other files. |
BTW. I REALLY wanted to add such comment in the .json files - but unfortunately, json specification does not allow comments (hence the README.md). |
98b8d92
to
5d50e00
Compare
@@ -22,7 +22,7 @@ author = Apache Software Foundation | |||
author_email = dev@airflow.apache.org | |||
url = https://airflow.apache.org/ | |||
version = attr: airflow.__version__ | |||
long_description = file: README.md | |||
long_description = file: generated/PYPI_README.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generated folder is included in the MANIFEST.in
https://github.com/apache/airflow/blob/main/MANIFEST.in#L42
So I am guessing this file will be available correctly and be used for the PyPI project listing description?
If someone can confirm my guess, would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can build the package with breeze release-management prepare-airflow-package --package-format sdist
and extract it to check if it’s in the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. And use "both" to generate both packages and you can also check if it is in METADATA of the .whl package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now.
Static check is failing with the below error:
I tried adding Am I missing something obvious or there's more to do 🤔 |
if not pypi_readme_file.exists(): | ||
pypi_readme_content = "" | ||
else: | ||
pypi_readme_content = pypi_readme_file.read_text() | ||
with readme_file.open("r") as readme: | ||
readme_content = readme.read() | ||
generated_pypi_readme_content = PYPI_README_HEADER | ||
for section in README_SECTIONS_TO_EXTRACT: | ||
section_content = extract_section(readme_content, section) | ||
generated_pypi_readme_content += section_content | ||
if pypi_readme_content != generated_pypi_readme_content: | ||
with pypi_readme_file.open("w") as generated_readme: | ||
generated_readme.write(generated_pypi_readme_content) | ||
console.print("\n[yellow]PyPI README.md content regenerated after update..\n") | ||
console.print("[red]Aborting the commit") | ||
console.print("You should check the changes made. Then simply 'git add --update .' and re-commit") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we just write the file every time? That simplifies this code a bit, and still shows a good enough message to the user:
Generate PyPI README...............................................................Failed
- hook id: generate-pypi-readme
- files were modified by this hook
if not pypi_readme_file.exists(): | |
pypi_readme_content = "" | |
else: | |
pypi_readme_content = pypi_readme_file.read_text() | |
with readme_file.open("r") as readme: | |
readme_content = readme.read() | |
generated_pypi_readme_content = PYPI_README_HEADER | |
for section in README_SECTIONS_TO_EXTRACT: | |
section_content = extract_section(readme_content, section) | |
generated_pypi_readme_content += section_content | |
if pypi_readme_content != generated_pypi_readme_content: | |
with pypi_readme_file.open("w") as generated_readme: | |
generated_readme.write(generated_pypi_readme_content) | |
console.print("\n[yellow]PyPI README.md content regenerated after update..\n") | |
console.print("[red]Aborting the commit") | |
console.print("You should check the changes made. Then simply 'git add --update .' and re-commit") | |
sys.exit(1) | |
readme_content = readme_file.read_text() | |
generated_pypi_readme_content = PYPI_README_HEADER | |
for section in README_SECTIONS_TO_EXTRACT: | |
section_content = extract_section(readme_content, section) | |
generated_pypi_readme_content += section_content | |
with pypi_readme_file.open("w") as generated_readme: | |
generated_readme.write(generated_pypi_readme_content) |
(If not, I have a number of comments on the original code, so lmk 👍)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this works very well. Very clean, thank you :)
Yes, I had all the ugly code earlier and the rich dependency for the console output & failing the commit with sys.exit which is no longer needed 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Writing file every time is fine. Now. The only thing that's left is just to ... run the pre-commit to fix some discrepancies :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still seeing static failures wrt #33637 (comment). Any suggestion for me that what we could do here?
9bd70fa
to
168908d
Compare
Yep. I think you found the fix in the last commit :) |
I am not sure. I did add the file to .rat-excludes, but it still fails, waiting for another run in the CI now, but I'm not hopeful :( |
@potiuk maybe it is it possible to switch these files to .jsonc, "JSON with Comments"? VSCode supports it for example (https://code.visualstudio.com/docs/languages/json#_json-with-comments), I am not sure if it is possible to easily include support in this project. |
Well. We need to read them in setup.py using nothing by stdlib of python in all versions we support. Otherwise I'd just use YAML. The file is read by |
We just need wait a bit (3 years 😀 ) for min Python 3.11 and we could use tomllib |
I added the license back to the generated file as the the exclude is not working. One failing test of MSSQL2017-latest, Py3.8: Core Providers[-amazon,google] Other Providers[amazon] WWW API Always CLI Providers[google] seems to be unrelated. |
just re-triggered the failed test, lets see if its a flaky one |
(cherry picked from commit 88a7a70)
closes: #33505
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.