Publishing resume-enhancer to PyPI

harshil_patel

Harshil Patel

Posted on November 24, 2024

Publishing resume-enhancer to PyPI

Hi my name is Harshil and if you have read my previous blogs then you know that I am working on a Command line tool called resume-enhancer. ResumeEnhancer is a command-line tool that uses AI to optimize your resume for specific job descriptions. Input your current resume and job description, and it will suggest changes to highlight relevant skills, experience, and certifications without adding false information. It helps tailor your resume to increase your chances of getting hired. I was working on this tool for quite some time and here is my first blog I wrote when I started working on this.

I publish resume-enhancer to PyPI. This blog is about my experience of publishing my CLI tool to PyPI.

To begin with, I created a file called pyproject.toml and it contain logic for building the resume-enhancer. Below is the example of my pyproject.toml file for resume-enhancer and I will share some details about it.

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "resume-enhancer"
dynamic = ["version"]
description = "A CLI tool for optimizing and tailoring resumes based on job descriptions using AI."
readme = "README.md"
readme-content-type = "text/markdown"
license = {text = "MIT"}
authors = [
    { name = "Harshil Patel", email = "26harshilpatel11@gmail.com" }
]
homepage = "https://github.com/hpatel292-seneca/ResumeEnhancer"
requires-python = ">=3.11"
dependencies = [
    "annotated-types==0.7.0",
    "anyio==4.5.0",
    "certifi==2024.8.30",
    "charset-normalizer==3.3.2",
    "colorama==0.4.6",
    "distro==1.9.0",
    "groq==0.11.0",
    "h11==0.14.0",
    "halo==0.0.31",
    "httpcore==1.0.5",
    "httpx==0.27.2",
    "idna==3.10",
    "jiter==0.5.0",
    "log-symbols==0.0.14",
    "lxml==5.3.0",
    "openai==1.46.0",
    "pydantic==2.9.2",
    "pydantic_core==2.23.4",
    "pypdf",
    "python-docx==1.1.2",
    "requests==2.32.3",
    "six==1.16.0",
    "sniffio==1.3.1",
    "spinners==0.0.24",
    "termcolor==2.4.0",
    "tomli==2.0.2",
    "tqdm==4.66.5",
    "typing_extensions==4.12.2",
    "urllib3==2.2.3"
]

[project.optional-dependencies]
dev = [
    "black==24.10.0",
    "flake8",
    "pre-commit==4.0.1",
    "pytest==8.3.3",
    "pytest-xdist==3.6.1"
]

[project.scripts]
resume-enhancer = "app.resume_enhancer:main"

[tool.hatch.build.targets.wheel]
packages = ["app"]

# Dynamic versioning using Hatchling
[tool.hatch.version]
path = "app/_version.py"
Enter fullscreen mode Exit fullscreen mode

1. [build-system]

This is where you tell Python what tools to use to build your project. I chose Hatchling because it’s lightweight and gets the job done without unnecessary complexity. The requires line lists Hatchling as a dependency, and build-backend points to the module that actually handles the building process.

2. [project]

This is all about the “what” and “who” of your project:

  • name is the name of the tool people will search for on PyPI. In my case, it’s resume-enhancer.
  • dynamic: Instead of hardcoding the version number, I’m letting Hatchling handle it dynamically (more on that below).
  • description and readme: These give users an overview of the tool and display nicely on the PyPI project page. The description is short and sweet, and the readme points to my README.md file, which explains everything in detail.
  • license: I went with MIT because it’s simple and permissive.
  • authors: This is where I get to take some credit—my name and email go here.
  • homepage: A link to the GitHub repo so users can check out the source code, file issues, or contribute.
  • requires-python: I set a minimum Python version of 3.11 because I wanted to use its newer features.
  • dependencies: This is the shopping list of all the packages my tool needs to work. It includes things like openai (for the AI magic), pydantic (for validating data), and tqdm (for those cool progress bars).

3. [project.optional-dependencies]

This is the “extras” section for developers. I added a dev group here with tools like:

  • black: Makes sure the code is formatted nicely.
  • flake8: Keeps the code lint-free.
  • pytest: Makes testing easier.
  • pre-commit: Runs checks automatically before you commit code to avoid silly mistakes.

4. [project.scripts]

Here’s the cool part—this section makes the tool runnable from the command line. When someone installs resume-enhancer, they can just type resume-enhancer in the terminal to launch it. This works by pointing to the main function inside my app.resume_enhancer module.

5. [tool.hatch.build.targets.wheel]

This section tells Hatchling to include the app directory when building the package. It’s a simple way to make sure only the important files are packaged when the tool is uploaded to PyPI.

6. [tool.hatch.version]

This part makes versioning easy. Instead of manually updating the version every time I make changes, Hatchling reads it directly from a file (app/_version.py). It’s super handy, especially if you’re using automation tools for publishing.

Publishing Resume Enhancer to PyPI

Once my pyproject.toml file was ready, the next step was to package and publish Resume Enhancer. Since I’m working on Windows, I used Python commands to handle the build and upload process. Here’s how it works:

Step 1: Install Required Tools

Before you can publish, you need to make sure the necessary tools are installed. Run these commands to set everything up:

py -m pip install --upgrade build twine
Enter fullscreen mode Exit fullscreen mode
  • build is used to create the distributable package.
  • twine handles uploading the package to PyPI.

Step 2: Build the Package

To package the tool, I ran the following command in the project directory (the one containing pyproject.toml):

py -m build
Enter fullscreen mode Exit fullscreen mode

This creates a dist/ directory containing two files:

  • A source distribution (.tar.gz)
  • A built distribution (.whl)

These files are what you’ll upload to PyPI.

Step 3: Publish to PyPI

Once the package was built, I published it to PyPI with the following command:

py -m twine upload dist/*
Enter fullscreen mode Exit fullscreen mode

Twine will prompt you to enter your PyPI credentials. If you don’t have an account, you can create one here. Once you enter the credentials, Twine takes care of the rest, uploading your package to PyPI.

Changes Made for the Chosen Package Format and Registry

To package Resume Enhancer for PyPI, I didn’t need to make drastic changes to my codebase, but I did have to tweak a few things to meet the requirements of the chosen package format and registry. Here’s what I changed:

1. Added app/_version.py

To dynamically manage the version of the tool, I created a file called app/_version.py with the following content:

# Version file for Resume Enhancer Tool
__version__ = "1.0.2"
Enter fullscreen mode Exit fullscreen mode

This file acts as the single source of truth for the version number, making it easier to update in one place whenever I release a new version.

2. Configured the Version in the Code

In my config file, I imported the version from app/_version.py to ensure consistency throughout the tool. Here’s an example:

from app._version import __version__

# App Config
TOOL_NAME = "Resume Enhancer Tool"
VERSION = __version__
Enter fullscreen mode Exit fullscreen mode

By doing this, I can display the version wherever needed (e.g., in the CLI output) and ensure that it matches the version uploaded to PyPI.

User Testing Session: Insights and Improvements

I had one of my friends who test the Resume Enhancer tool. It was a great experience, as he easily navigated through the tool using the README as his guide and successfully ran it without encountering any issues. His feedback was incredibly valuable in ensuring that the tool and documentation were beginner-friendly and easy to use.

What Worked Well

  • Clear Documentation: My friend found the README straightforward and was able to install the tool, understand the commands, and use it effectively.
  • Smooth Functionality: The tool worked as expected, and he especially appreciated the examples in the Usage section, which helped him quickly test the core functionality.

Suggestions for Improvement

Although he had no trouble running the tool, he suggested adding:

  1. A Note on Installing Dependencies: He pointed out that while pip install resume-enhancer works, users might not realize they need to have pip set up correctly on their system. A small section explaining how to install pip and ensure Python is in the system PATH would help complete beginners.

How to Install and Use Resume Enhancer

Now that Resume Enhancer is live on PyPI, installing and using the tool is quick and easy! Here's how users can get started:

  • Install the Tool Open your terminal or command prompt and run:
   pip install resume-enhancer
Enter fullscreen mode Exit fullscreen mode
  • Verify Installation Check if the installation was successful by running:
   resume-enhancer --version
Enter fullscreen mode Exit fullscreen mode
  • Run the Tool To use the tool, provide the path to your resume and job description along with your API key:
   resume-enhancer --resume path_to_resume --description path_to_description --api_key groq_api_key
Enter fullscreen mode Exit fullscreen mode
  • Configuration File You can simplify command usage by creating a configuration file. Learn more about it here.

For detailed documentation and examples, check out the GitHub repository and the PyPI project page.

💖 💪 🙅 🚩
harshil_patel
Harshil Patel

Posted on November 24, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related