Skip to content

Modernize packaging and prepare drawcal for PyPI#4

Merged
rsgalloway merged 5 commits into
masterfrom
chore/pyproject-packaging
May 31, 2026
Merged

Modernize packaging and prepare drawcal for PyPI#4
rsgalloway merged 5 commits into
masterfrom
chore/pyproject-packaging

Conversation

@rsgalloway
Copy link
Copy Markdown
Contributor

@rsgalloway rsgalloway commented May 31, 2026

This pull request introduces several important updates to the drawcal project, focusing on modernizing the packaging and distribution, improving event file validation, updating copyright and project metadata, and enhancing compatibility and maintainability. The changes include migrating to PEP 517/518 build standards with a new pyproject.toml, improving event input validation and error handling, and updating documentation and CI workflows.

Packaging and distribution modernization:

  • Migrated from setup.py to a modern pyproject.toml build system, specifying metadata, dependencies, and project configuration for PEP 517/518 compliance. Removed the legacy setup.py and test script. [1] [2] [3]
  • Added a GitHub Actions workflow (.github/workflows/tests.yml) to run tests across Python 3.8–3.12, improving CI coverage and reliability.

Event input validation and error handling:

  • Enhanced the read_events function to validate that event files are lists of lists, ensure each date is a valid string in M/D/YYYY format, and provide clear error messages for invalid files or JSON.
  • Improved the random event generator in get_events to respect the actual number of days in each month, preventing out-of-range dates.

Codebase and API improvements:

  • Refactored imports in __init__.py and cli.py to lazily load heavy dependencies, improving startup performance and keeping package metadata lightweight. [1] [2] [3]
  • Added a _text_size helper to ensure text rendering works across different Pillow versions. [1] [2] [3]
  • Fixed a bug in event rendering logic to correctly detect the start of an event.

Documentation and metadata updates:

  • Updated the README.md with new installation, build, and event file format instructions. [1] [2]
  • Updated copyright notices throughout the codebase and in the LICENSE to reflect the new copyright holder and project name. [1] [2] [3] [4] [5] [6]

These changes collectively modernize the project, improve user experience, and ensure better maintainability and reliability going forward.

@rsgalloway rsgalloway self-assigned this May 31, 2026
@rsgalloway rsgalloway added the enhancement New feature or request label May 31, 2026
@rsgalloway rsgalloway marked this pull request as ready for review May 31, 2026 02:38
@rsgalloway rsgalloway requested a review from Copilot May 31, 2026 02:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Modernizes drawcal for PyPI distribution while tightening event-file validation and adding CI/test coverage to improve reliability and maintainability.

Changes:

  • Migrates packaging from setup.py/requirements.txt to PEP 517/518 via pyproject.toml and adds a GitHub Actions test workflow.
  • Improves event generation/reading: month-aware random events plus stricter JSON structure/date parsing with clearer failures.
  • Refactors imports for cheaper package import, updates rendering helpers for Pillow compatibility, and adds regression tests with fixtures.

Reviewed changes

Copilot reviewed 15 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Defines modern build metadata, dependencies, and entry points for PyPI.
.github/workflows/tests.yml Adds CI matrix to run tests across Python 3.8–3.12.
README.md Updates install/build/upload instructions and documents events JSON format.
lib/drawcal/__init__.py Makes draw_calendar a lazy import to keep metadata import lightweight.
lib/drawcal/cli.py Moves envstack initialization into CLI runtime and lazily imports renderer.
lib/drawcal/events.py Adds month-aware bounds in get_events and validates JSON events structure/dates.
lib/drawcal/drawlib.py Adds _text_size helper and fixes event start detection logic.
lib/drawcal/config.py Updates copyright header (no functional change).
tests/test_package.py Adds import/metadata and symbol exposure tests.
tests/test_events.py Adds tests for invalid JSON/dates and month-bounded random events.
tests/test_render.py Adds fixture-based render regression test.
tests/fixtures/march-2025-events.json Provides deterministic events for render fixture test.
tests/fixtures/march-2025-expected.png Adds expected image fixture for render regression.
LICENSE Updates license header/copyright holder naming.
.gitignore Adds ignores for build artifacts and agent/codex files.
bin/drawcal Updates shebang/copyright header for script wrapper.
setup.py Removes legacy setuptools packaging.
requirements.txt Removes legacy dependency pin file.
lib/drawcal/test.py Removes legacy in-package test script in favor of tests/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/drawcal/events.py
Comment thread tests/test_render.py Outdated
Comment thread tests/test_events.py Outdated
Comment thread tests/test_events.py Outdated
@rsgalloway rsgalloway merged commit 480da0f into master May 31, 2026
5 checks passed
@rsgalloway rsgalloway deleted the chore/pyproject-packaging branch May 31, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants