DEV Community

Cover image for Publish a Python Package (Part-3)
datatoinfinity
datatoinfinity

Posted on

Publish a Python Package (Part-3)

Local Testing

Before publishing it publicly you want to try on your locally first.

Run

pip install dist/package-0.1-py3-none-any.whl

Package it is the name for file.
0.1 is version you defined in setup.py

If you type pip list you will see your package name.

pip list

For testing
Now, you will create new folder in your code editor and make python file, let say test.py

test.py
from package import hello
hello()

Now Add to CLI(command line interface) Command.

Setup.py

from setuptools import setup, find_packages
setup(
    name="datatoinfinity-hello-package",
    version="0.2",
    packages=find_packages(),
    install_requires=[

    ],
    entry_points={
        "console_scripts":[
            "package=package:hello",
        ],
    },
) 

Now if you notice closely I have changed the version number to 0.2. To update version number we need to reinstall it.

pip install dist/package-0.2-py3-none-any.whl --force-reintall

Now if you start you terminal again you just need to type:

Input:
package
Output:
Hello Datatoinfinity

Now in next part we will publish are package publicly.

Top comments (0)