Ronnie Atuhaire
Ronnie Atuhaire's Blog

Ronnie Atuhaire's Blog

Keeping Tabs With THW -3

Keeping Tabs With THW -3

Part 3 -- PyPI Push & Usage

Ronnie Atuhaire's photo
Ronnie Atuhaire
May 15, 2022

4 min read

Subscribe to my newsletter and never miss my upcoming articles

If you have been following this mini-series, I am so glad that you did and today we shall hit one of our final droplets in this sequel and upload or push our resources to PyPIfor distribution.

If you missed any part of this series, check it out here.

Creating a PyPI package is easy and I have an introductory article on how you too can easily create and share a resource with anyone out there.

Publishing it to PyPI and then pip installing it will make it available in the site-packages list of Python and we get to use it the usual way we import all other modules.

Assuming you are with me and this is our complete code so far. I won't change anything in that current code but you can go ahead and create a pull request if you want to contribute to it.

Let's create our file. Before, let's upgrade setup tools & wheel first with;

python -m pip install -user -upgrade setuptools wheel

Then the setup file;

import pathlib
from setuptools import setup

# The directory containing this file
HERE = pathlib.Path(__file__).parent

# The text of the README file
README = (HERE / "").read_text()

# This call to setup() does all the work
    description="Keeping Tabs With The Hashnode Writeathon (THW)",
    keywords='Hashnode Writeathon Challenges Blogging Tech',
    author="Ronnie Atuhaire",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.10",

You can also include a setup.cfg file that has the following data;


Now let's create thwAPI folder and shift all our project code in there;

So let's build our distribution from the file in the root project:

python sdist bdist_wheel



Upload the sdist on PyPI;

py -m twine upload dist/* --verbose


--verbose for logging errors and more details

And our project is live;


Visit it here

Let's pip install thwAPI and create another test file to get to use our own module;

pip show thwAPI would return;


Please read more about publishing on PyPI here if you did not understand anything.

In our file . Let this test file not be in the root folder of our project, infact create another folder and place it in there or run it completely outside of that folder to test locally on your machine.

# Testing PyPI Upload after pip install
from thwAPI import thw

# print(dir(thw))

# initialize = thw.THW()

API_URLs = ['',


for idx, url in enumerate(API_URLs):
    print(f"API {idx} ; Counter")
    count = thw.THW(url).count()

Estimated count at the time of writing this article;

Estimated Count At the time of execution;

Cloud Computing; There are currently 81 posts written!
Mobile Apps ; There are currently 73 posts written!
Web 3 ; There are currently 99 posts written!
Web Apps ; There are currently 264 posts written!


You could also add this code for your own testing;

for idx, url in enumerate(API_URLs):
    print(f"API {idx} ; Summary")
    summary = thw.THW(url).all_posts()

I am still having one post to submit under this mini-serieseven though the #TheHashnodeWriteathon is gaming today.

That article is going to be about automation with GitHub workflows and updating the package at PyPI.

That's it for today! Find all code and the entire project here.


Once again, hope you learned something today from my little closet.

Please consider subscribing or following me for related content, especially about Tech, Python & General Programming.

You can show extra love by buying me a coffee to support this free content and I am also open to partnerships, technical writing roles, collaborations and Python-related training or roles.

Buy Ronnie A Coffee You can also follow me on Twitter : Waiting for you!
Share this