How to Develop and publish package at Pypi library

Let’s start from scratch :

Step : 1

  1. Login to Pypi :

2. Click on mentioned marked below:

3. Create API token for authentication and save it , otherwise you can’t retrieve the key later.

Step : 2

4. Create folder structure:

5. Let’s discuss about contains of necessary files as below :


import setuptools

with open(“”, “r”, encoding=”utf-8") as fh:
long_description =

name=”pkglogger”, # Replace with your own username
author=”Avik Das”,
description=”This package help you to keep logs”,
“Bug Tracker”: “",
“Programming Language :: Python :: 2”,
“License :: OSI Approved :: MIT License”,
“Operating System :: OS Independent”,
package_dir={“”: “pkglogger”},

b. :

**#Developer : Avik Das**

1.pip install pkglogger==<version number>
2. **from** pkglogger **import** pkglogger
3. pkglogger.logger(‘path/’,’’,’’,’’,’’,’’,’’)
4. *var1* = directory where log file will be created
5. *var2* = Logger number
6. *var3* = Function name
7. *var4* = Task status
8. *var5* = Error
9. *var6* = Output path
10. *var7* = URL Link

c.pyproject.toml: ( Important step )

requires = [
build-backend = “setuptools.build_meta”

Here , mentioned all necessary packages that need to be imported while running this package after importing.

Step: 3

6. Open “cmd” / “powershell”.

7. Set the path within the package directory :

for cmd : cd /d <path>

for powershell : cd <path>

8. Run following commands sequentially :

a. py -m pip install — upgrade build

b. py -m build ( Now run this command from the same directory where pyproject.toml is located )

After this command, following files will be created :

Note : Before next command, check within “dist” ( generated by build command ) file whether the “Core Code” is there or not with “” file within “.tar” file as shown above.

c. py -m pip install — user — upgrade twine

d. py -m twine upload — repository testpypi dist/*

You will be prompted for a username and password. For the username, use __token__. For the password, use the token value, including the pypi- prefix. Use mouse right click for pasting the API Key in cmd/ powershell.

Now, check your pypi account where you can get to see your package.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store