I have a python tool that I run from the terminal and I would like to upload it as a bdist on Pypi to make a ready to use tool. (like an .exe on Windows)
While uploading it to Pypi (the test version of the service) I've used the command python -m build
which creates both the .tar.gz and .whl file.
When doing pip install MyTool
it installs the tool as a package, hence I cannot execute it from terminal (I mean just by calling the name of the package), I can execute it by running python3 path_to_....MyTool/MyTool.py
but this is not what the end-user is supposed to do.
The goal is to have:
pip install MyTool
(to install it)MyTool
or ./MyTool
(to execute it)I've tried to use the command python3 -m build --wheel
in order to just create the .whl file and upload it to a new project without the .tar.gz file but still doing pip install MyTool
it just installs the package (which i can import into my file) but I can't execute from terminal with ./MyTool
.
I include to screen to help solve the question:
Screen of the .toml file
Screen of the setup.cfg file
How to make MyTool into a ready to use python application?
Thanks for your help!!
I found the solution:
the setup.cfg
file was missing the options.entry_points
:
[options.entry_points]
console_scripts = tool = MyTool:main
The syntax for entry points is specified as follows:
<name> = [<package>.[<subpackage>.]]<module>[:<object>.<object>]
url: https://setuptools.pypa.io/en/latest/userguide/entry_point.html