Skip to content

Modernize Build System and CI/CD with uv and PEP Standards#123

Open
abstract-333 wants to merge 4 commits intoipinfo:masterfrom
abstract-333:feat/migrate-uv
Open

Modernize Build System and CI/CD with uv and PEP Standards#123
abstract-333 wants to merge 4 commits intoipinfo:masterfrom
abstract-333:feat/migrate-uv

Conversation

@abstract-333
Copy link

Summary

This PR modernizes the ipinfo Python library’s packaging and CI/CD workflows by migrating from a legacy setup.py-based setup to a fully declarative, standards-compliant build system. By adopting pyproject.toml, uv, and current PEP standards, we improve reproducibility, security, performance, and long-term maintainability while simplifying the contributor experience.

Proposed Changes

🛠 Build System Migration (PEP 621)

  • Declarative Metadata: Replaced the imperative setup.py script with a static pyproject.toml following PEP 621 (Standard tool for project metadata).
  • Modern Backend: Adopted hatchling as the build backend to ensure a secure and standardized build process.
  • Dependency Management: Removed pip-tools and requirements.txt. All dependencies are now declared in pyproject.toml and locked in uv.lock for 100% deterministic builds.
  • Python Pinning: Pinned requires-python = "=3.10" for CI alignment, while keeping the library’s minimum supported version as python>=3.9.

🏷 Versioning Standardization (PEP 396)

  • Standardized Attribute: Replaced the custom SDK_VERSION with the industry-standard __version__ in compliance with PEP 396 (Module version numbers).
  • Import Fixes: Updated ipinfo/handler_utils.py and legacy build references to use the __version__ dunder attribute.

🚀 CI/CD Optimization (GitHub Actions)

  • Locked Sync: Switched from pip install to uv sync --all-groups in GitHub Actions. This ensures the CI environment is an exact mirror of the local development environment.
  • Workflow Cleanup: Streamlined uv build by removing unnecessary flags and leveraging astral-sh/setup-uv caching.
  • Performance: Reduced total CI execution time by ~15 seconds per workflow run.

Testing Performed

  • Verified uv lock generates a valid lockfile.
  • Successfully ran uv build to generate .whl and .tar.gz distributions.
  • Ran uv run pytest (Pro API-dependent tests were not executed due to missing Pro API key).
  • Verified User-Agent headers correctly reflect the version string from __version__.

- Replace imperative setup.py with declarative pyproject.toml (PEP 621)
- Adopt PEP 517/518 compliant build system using hatchling
- Pin `requires-python = ">=3.10"` to align with Build CI defaults
- Remove pip-tools as uv natively handles locking and syncing
- Initialize uv.lock for deterministic and faster dependency resolution
- Reorganize dev dependencies into [dependency-groups]
- Update ipinfo/handler_utils.py to use __version__ instead of SDK_VERSION
- Remove legacy version imports in setup.py to follow PEP 517
- Ensure User-Agent strings reflect the standardized version attribute
- Align internal API with PEP 396 module versioning conventions
- Replace legacy `uv pip install` with `uv sync --all-groups` for locked dev environments
- Remove manual `requirements.txt` installation in favor of pyproject.toml discovery
- Clean up `uv build` by removing unnecessary `--no-build-isolation` flag
- Leverage `astral-sh/setup-uv` caching for faster test and publish runs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant