Skip to main content

A complete professional Python library project ready for PyPI

Project description

mylibrary

PyPI version Supported Python versions License: MIT

A clean, modern, and production-ready Python library boilerplate, packaged with the latest PEP standards using pyproject.toml and ready to be published to PyPI.


Table of Contents


Features

  • Modern Packaging: Configured using standard pyproject.toml with setuptools.
  • Clean Structure: Exposes a clear public interface at the package level.
  • Production Ready: Includes setup scripts, test structure, and automated publishing workflows.
  • Beginner Friendly: Well-documented codebase with simple CLI recipes.

Installation

Install the library directly from PyPI using pip:

pip install mylibrary

Usage

Once installed, you can import and use the library in your Python projects:

from mylibrary import answer

# Call the placeholder function
answer()

Project Structure

Here is an overview of the directory structure and what each file does:

mylibrary/
├── .github/
│   └── workflows/
│       └── publish.yml       # GitHub Actions workflow for automatic publishing to PyPI on release tags.
├── mylibrary/                # Main package directory.
│   ├── __init__.py           # Package entrypoint, handles public exports.
│   └── core.py               # Core logic and helper functions.
├── tests/                    # Unit and integration test suite.
│   ├── __init__.py
│   └── test_core.py          # Tests targeting core functionality.
├── .gitignore                # Patterns for Git to ignore.
├── LICENSE                   # MIT License text.
├── pyproject.toml            # Modern project metadata and build configuration.
└── README.md                 # Project documentation (this file).

Developer Guide

Local Development Setup

To work on the library locally, it is recommended to create a virtual environment and perform an editable install. This allows you to test your changes in real-time.

  1. Create and activate a virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  2. Install the package in editable mode with development dependencies:

    pip install --editable .[dev]
    

    (Note: If you add test dependencies, you can specify them in pyproject.toml under optional-dependencies. For now, you can also just run pip install pytest build twine.)

Testing

This project uses pytest for testing.

  1. Install testing tools:

    pip install pytest
    
  2. Run the test suite:

    pytest
    

Building the Package

To package the project into source distributions and wheels for PyPI:

  1. Install the build tool:

    pip install --upgrade build
    
  2. Build the distributions:

    python -m build
    

    This will generate a source archive .tar.gz and a built wheel .whl inside the dist/ directory.

Publishing to PyPI

Once the package is built, you can upload it to PyPI using twine.

  1. Install Twine:

    pip install --upgrade twine
    
  2. Validate the built package:

    python -m twine check dist/*
    
  3. Upload to TestPyPI (Recommended first step to verify):

    python -m twine upload --repository testpypi dist/*
    
  4. Upload to PyPI (Production):

    python -m twine upload dist/*
    

GitHub Actions CI/CD

An automated release workflow is configured in .github/workflows/publish.yml. When you push a Git tag matching v* (e.g. v0.0.1), the workflow will automatically:

  1. Set up the Python environment.
  2. Build the package distribution.
  3. Securely publish it to PyPI using PyPI's Trusted Publishing mechanism (OIDC).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mylibrary_abhinavbajpai-0.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mylibrary_abhinavbajpai-0.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file mylibrary_abhinavbajpai-0.0.1.tar.gz.

File metadata

  • Download URL: mylibrary_abhinavbajpai-0.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mylibrary_abhinavbajpai-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d69971c4c93813eb0b13214621810d1fd2f4edb9c6be49e37e18d576517b23dd
MD5 6a519583f454456d6d89a014d3885c14
BLAKE2b-256 92dde0408532aab7ff400c75e6e741b9d7ab0bdf6385ce3a1f974dadcdcc66f8

See more details on using hashes here.

File details

Details for the file mylibrary_abhinavbajpai-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mylibrary_abhinavbajpai-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b64d7e35e67614bb6c9286a5042a711bb7011425f64ce4c3095182dc9b264ed7
MD5 bc8ebdda71906a21a576bad45e59a587
BLAKE2b-256 9367ce714df2a70007f009141560a61dd0059971c11afaff8c7fa9d948f081b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page