To run the main function in your run.py file from the command line, you'll need to set the entry_points option in your setup.py file. This can be done by adding the following code:
setup(
OTHER_SETTINGS,
entry_points={"console_scripts": ["yourcmd= wallpaper.run:main"]},
)
This code creates an executable script called yourcmd
that runs the main function from the wallpaper.run
module when it's invoked from the command line. To run this script, simply open a new terminal and enter yourcmd
.
If you're not familiar with entry_points
(refer to this answer and this documentation), it's a way to define commands that can be run from the command line after installing your package. By specifying entry_points with "console_scripts" as the key, you can create executable scripts that run a function within your package. This is useful if you want to make your package easily accessible from the command line without users having to manually navigate to the package directory and run the file themselves.
For a real-world example, you can check out the setup.py
file for the open source project fast-entry_points.