pythonpippypiinstallation-package

How to distribute python apps using PyPI?


I'm trying to package my code and distribute it using PyPI. I want people to install my package and use it directly from the terminal as:

$pip install <package_name>
$<package_name>

What Package structure should I need to follow? How should I do this?

I've read this documentation. It doesn't have what I wanted. https://packaging.python.org/tutorials/packaging-projects/#a-simple-project

I'm expecting to package and distribute my app using PyPI. and execute directly from Terminal.


Solution

  • You should look into Command Line Scripts. They allow you to add shell commands to your setup, so that you can later run them from the shell.

    So if you want a script called package_name, first create a Python function that will be called when package_name is run from the shell. Say it's in package_file.main. Then you can add the following to your setup call:

    entry_points = {
        'console_scripts': ['package_name:package_file:main',],
    }