To create an executable file for your Python code in a convenient and portable way, you can use a tool called setuptools
which provides a console_scripts
entry point.
First, install setuptools
if it is not already installed:
25 chars2 lines
Next, create a setup.py file in your project folder with the following contents:
main.py230 chars13 lines
This specifies the project name and version, the packages to include (using find_packages()
), and the entry point for the console script. In this example, the console script is called gistlib
and it calls the main()
function in the main
module of the gistlib
package.
You can adjust the entry point to match your project's structure and naming.
Finally, run the following command to create the executable file:
26 chars2 lines
This will create a gistlib
executable file in your system's PATH, which can be called from any directory in your terminal or command prompt.
gistlibby LogSnag