Questions And Answers

More Tutorials

Python Package Using Setuptools

Python Package Using Setuptools:-

First, we are going to make a folder, and inside it, we are going to make a license and readme named text files ( we can also use the .md extension to create a markdown file instead of text, which is also a sort of text-based file with better editing ). These license files contain the copyright details, and the readme will contain instructions that you want to convey. Along with the text files, we are also going to make a package folder.

Now we will open our visual studio so we can make our work more simple and easier. We can open our visual studio with the same directory address by writing the command “code .” in our PowerShell. Now we will create a file, and along with it, we will also create an file in our package folder.

The package code is present in, and is used for its identification. In simple words, tells setuptools about our package.

In, we will write all the functions we want our package to have. We can use classes too for this cause. In, we have to import the setuptools module, and we are going to use its setup function here.

from setuptools import setup

We will provide it with some basic details about our package, such as:

name: The name of the package. We can give our package any name of our choice.
version: The starting version should be 0.1 because, with any update, it automatically increases it to one decimal place.
description: Here, we give a brief description of our package and its functionalities and uses.
long_description: In the long description we give an explanatory description of our package
author: We can specify the creator of the package here
packages: Here we give the name by which we want our package to be called or imported
install_requires: If our package has a prerequisite package, then we have to specify that here so both of them can work simultaneously and can perform better.

Now we are going to build our package. We are going to open our terminal window or PowerShell in the same directory, and we are going to install the wheel.

pip install wheel

and after that, we are going to make our package using the command

from setuptools import setup

python sdist bdist_wheel

Now our package is created, and we can install it using.

pip install package_name

And we can also import it in the same way

Import package_name


from setuptools import setup
description="This is code with harry package",
long_description = "This is a very very long description",


class Achha:
    def __init__(self):
        print("Constructor ban gaya")

    def achhafunc(self, number):
        print("This is a function")
        return number


In this page (written and validated by ) you learned about Python Package Using Setuptools

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.