Skip to content
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

Changes to the User Guide's Entry Points page #3355

Merged
merged 22 commits into from Jun 11, 2022

Conversation

codeandfire
Copy link
Contributor

Summary of changes

Console scripts section:

  • Added pyproject.toml snippet
  • Modified setup.py snippet (corrected indentation and removed unnecessary name, version, etc. fields)
  • Changed the example to use src-layout
  • Some changes in the wording etc.

Added GUI Scripts section:

  • Included setup.cfg / setup.py / pyproject.toml snippets
  • Added an example Hello world function that can be invoked through a GUI script

Other changes:

  • Added note on distinction between Console and GUI scripts
  • Added note on how installers like Pip create wrapper scripts around invoked functions
  • Included few lines stating that invoked functions should not accept any arguments and parse user input within the function body

Have not finished this yet. Will update here with further changes.

Pull Request Checklist

 - Using `src` layout for consistency with other examples in the
   documentation.
 - Using a tree diagram.
 - Showing a `setup.py` file in the diagram with a comment indicating
   that `setup.cfg` or `pyproject.toml` can also be used, again for
   consistency with other examples in the documentation.
 - Root directory is kept as `project_root_directory` to indicate that
   any name can be used.
 - I think there is no need to include name, version, `packages`, etc.
   They haven't been included in the equivalent `setup.cfg` snippet as
   well as in other snippets in the documentation.
 - Fixed up indentation by changing tabs to 4 spaces.
 - Added output of the command `python -m timmins`.
 - Added input and output when a console script is set up, i.e. when
   `hello-world` is run on the terminal.
 - Made separate section for `gui_scripts`
 - Added an example `hello_world()` function that can be invoked using
   a GUI script entry point
 - Added `setup.cfg`, `setup.py` and `pyproject.toml` configuration
   snippets
 - Added that running `hello-world` in the terminal will open up a GUI
   window.
This note has been taken from the Python Packaging user guide. I think
it will be of interest to users who want to understand what is the
difference between `console_scripts` and `gui_scripts`.
Removed a line stating that installers like Pip create wrapper scripts
around the function, and replaced it with a longer note at the end of
the GUI scripts section. This note includes a sample wrapper script
taken from the Python Packaging user guide. I think this longer note
along with an actual example of how the wrapper script might look like
will make it more clear to the user how console/GUI scripts work behind
the scenes.
Added two lines to make this clear to users. Also added that any parsing
of user input can take place within the body of the function using
regular command-line parsing utilities.
Changed the wording of the console scripts example, so that it is more
clear why `__main__.py` is required and why console scripts are a better
alternative.
Copy link
Contributor

@abravalheri abravalheri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for all the improvements @codeandfire!

docs/userguide/entry_point.rst Outdated Show resolved Hide resolved
docs/userguide/entry_point.rst Outdated Show resolved Hide resolved
docs/userguide/entry_point.rst Show resolved Hide resolved
docs/userguide/entry_point.rst Show resolved Hide resolved
codeandfire and others added 2 commits June 9, 2022 21:38
Co-authored-by: Anderson Bravalheri <andersonbravalheri+github@gmail.com>
`PySimpleGUI` must be added to package dependencies in order to run the example in the GUI scripts section.

Co-authored-by: Anderson Bravalheri <andersonbravalheri+github@gmail.com>
@abravalheri
Copy link
Contributor

@codeandfire, please let me know when you are happy and we can merge this change :)

@codeandfire
Copy link
Contributor Author

Sure @abravalheri, I just have some changes in mind for the second part of the page involving the plugin-related entry points, and I think I will finish them in a day. After that can we merge this commit?

@abravalheri
Copy link
Contributor

Yeah, of course, no rush.

Fixes warning emitted during `tox -e docs`
Snippet borrowed from Python Packaging user guide
 - Indicated that for Python versions lower than 3.8, the backport
   should be used.
 - Indicated that the only change that needs to be made while using the
   backport, is to replace `importlib.metadata` with
   `importlib_metadata`.
In the Advertising Behaviour section.
 - Defining multiple EPs under the same group
 - Loading an EP by its name
 - Loading all EPs in a given group
 - Old example was on loading entry points corresponding to console
   scripts.
 - Everything in that example has probably been included in the newer
   example.
@codeandfire
Copy link
Contributor Author

Hi @abravalheri, a bit late but I've finished my work on the Entry Points page. I have written a lot of new material, please let me know your feedback!

@codeandfire codeandfire marked this pull request as ready for review June 11, 2022 09:13
Copy link
Contributor

@abravalheri abravalheri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @codeandfire.
The changes in the documentation are superb, I am very glad to have you as a contributor.

docs/userguide/entry_point.rst Outdated Show resolved Hide resolved
docs/userguide/entry_point.rst Outdated Show resolved Hide resolved
@abravalheri abravalheri merged commit 7fc94d1 into pypa:main Jun 11, 2022
@codeandfire
Copy link
Contributor Author

Thank you @abravalheri for your kind words. It's a pleasure to contribute to Setuptools, especially when you as a maintainer are so helpful and responsive!

@codeandfire codeandfire deleted the entry-points-fix branch June 11, 2022 10:51
codeandfire added a commit to codeandfire/setuptools that referenced this pull request Jun 11, 2022
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.

None yet

2 participants