Introduction
Releasing software is an art that goes beyond writing good code—it’s about making your tool accessible, easy to install, and user-friendly. In Lab 9, I worked alone to finalize the release of Code Complexity Pro, a Python command-line tool for analyzing code complexity using Groq’s LLM API. This blog walks you through the release process, the challenges I faced, and how I overcame them.
Choosing Tools and Registry
I chose the following tools for the release:
-
Package Manager: Python’s
setuptools
for building the package andtwine
for uploading it. - Registry: PyPI for publishing the production-ready package. Before that, I tested it on TestPyPI.
These tools are industry standards for Python projects, and their documentation provided helpful guidance.
The Release Process
Here’s how I took Code Complexity Pro from development to release:
-
Tagging the Release:
- I created an annotated tag to mark the release version using Git:
git tag -a v1.1.2 -m "Final production release of Code Complexity Pro" git push --follow-tags
- Tags allowed me to fix a version snapshot in the repository for easy reference.
-
Building the Package:
- I used
setuptools
to create source (.tar.gz
) and wheel (.whl
) distributions:
python setup.py sdist bdist_wheel
- I used
- These files were stored in the
dist/
directory.
-
Uploading to TestPyPI:
- I first uploaded the package to TestPyPI for testing:
twine upload --repository testpypi dist/*
- This step ensured the package was functional before going live on PyPI.
-
Publishing to PyPI:
- After successful testing, I uploaded the package to the official PyPI:
twine upload dist/*
-
Testing Installation:
- I installed the package from PyPI on a clean environment to verify its functionality:
pip install code-complexity-pro
Challenges and How I Solved Them
1. Keyring Errors During twine upload
-
Issue:
twine
threw aNoKeyringError
because my environment didn’t support the keyring backend. -
Solution: I bypassed the keyring by directly entering the PyPI API token when prompted. Additionally, I configured a
.pypirc
file for future automation:
[pypi] repository = https://upload.pypi.org/legacy/ username = __token__ password = <your-api-token>
2. ModuleNotFoundError
in Tests
- Issue: My test files couldn’t locate modules due to incorrect import paths.
-
Solution: I updated all test imports to use fully qualified paths, e.g.,:
from code_complexity_pro.api_handler import send_code_to_groq
3. Feedback from User Testing
- During testing, it became apparent that lab patner was unsure how to set up API keys. To address this, I added detailed instructions to the
README.md
on configuring keys via.env
or a TOML file.
4. 403 Forbidden on PyPI Upload
- Issue: PyPI rejected uploads due to invalid authentication.
-
Solution: I regenerated an API token on PyPI and used it in the
.pypirc
configuration file.
What I Learned
- Packaging is Critical: Preparing a project for release requires thoughtful structuring of files, dependencies, and configurations.
-
Documentation Matters: Clear, step-by-step instructions in the
README.md
can prevent user confusion and ensure smooth adoption. - Testing is Invaluable: Testing the package in environments similar to a user’s setup revealed issues I wouldn’t have caught otherwise.
Changes Made for the Release
To prepare the project for release:
- Added a
setup.py
file for packaging. - Created a
.pypirc
file for easier uploads to PyPI. - Updated
README.md
with installation instructions, usage examples, and API key setup.
How Users Can Install and Use Code Complexity Pro
Installation
To install the latest version of Code Complexity Pro, run:
pip install code-complexity-pro==1.1.2
Usage
Analyze code complexity with the following commands:
- Analyze a Single File:
code_complexity_pro --files path/to/file.py --api-key your-api-key
- Analyze a Directory:
code_complexity_pro --files /path/to/directory/ --api-key your-api-key
- Save Results to a File:
code_complexity_pro --files file.py --output analysis_results.txt
For more detailed instructions, check the GitHub Repository.
Conclusion
Completing Lab 9 was a challenging but rewarding experience. It gave me a deeper appreciation for the release process and taught me how to ensure that users can install and use a project effortlessly. By improving documentation, refining configurations, and addressing user feedback, Code Complexity Pro is now a polished tool ready for the Python ecosystem.
Top comments (0)