Skip to content

Conversation

@gregbell26
Copy link
Contributor

@gregbell26 gregbell26 commented Jan 4, 2025

There is a slight (but important) discrepancy between the docs and the actual behavior.

As observed here in this generated script:

[project.scripts]
     build_autograder = "autograder_cli.build_autograder:tool"
#!/usr/local/bin/python3
#-*- coding: utf-8 -*-
import re
import sys
from autograder_cli.build_autograder import tool
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(tool())

We see that the return value from the tool is used as the exit code.

I had my code setup to return True in the case of a success and False in the case of a failure, thinking that the generated code would simply discard that return value.

As such, adding this one line will make it clear what the function should be returning.


📚 Documentation preview 📚: https://python-packaging-user-guide--1770.org.readthedocs.build/en/1770/

@gregbell26 gregbell26 changed the title Correct typo in docs for project.scripts Correct typo in docs for [project.scripts] Jan 4, 2025
@gregbell26
Copy link
Contributor Author

This is mentioned as well in the docs here: https://packaging.python.org/en/latest/specifications/entry-points/#use-for-scripts, so I think it should be consistent.

@webknjaz webknjaz enabled auto-merge January 7, 2025 19:58
@webknjaz webknjaz added this pull request to the merge queue Jan 7, 2025
Merged via the queue into pypa:main with commit 7013651 Jan 7, 2025
7 checks passed
@gregbell26 gregbell26 deleted the patch-1 branch January 7, 2025 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants