Skip to content

Commit 3e99b95

Browse files
Modernize Build System and CI/CD with uv and PEP Standards (#123)
* build: migrate to uv, pin Python 3.10, and remove pip-tools - 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] * refactor: update version references to use standardized __version__ - 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 * ci: fully integrate GitHub Actions with uv project workflow - 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 * ci: optimize uv setup by pinning version and narrowing cache glob * Simplify workflows * Revert .gitignore change * Remove useless info in pyproject.toml * Remove unnecessary setup.py and requirements files * Drop Python 3.9 * Update uv.lock --------- Co-authored-by: Silvano Cerza <silvanocerza@gmail.com>
1 parent f2c95f9 commit 3e99b95

9 files changed

Lines changed: 1113 additions & 149 deletions

File tree

.github/workflows/cd_pypi.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ name: Release Python Package to pypi
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- "v*"
77

88
jobs:
99
publish:
10-
1110
runs-on: ubuntu-latest
1211

1312
environment:
@@ -18,19 +17,19 @@ jobs:
1817
id-token: write
1918

2019
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v3
20+
- name: Checkout
21+
uses: actions/checkout@v6
2322

24-
- name: Set up Python
25-
uses: actions/setup-python@v4
26-
with:
27-
python-version: '3.10'
23+
- name: Set up Python
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: "3.10"
2827

29-
- name: Install dependencies
30-
run: pip install -r requirements.txt
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v7
3130

32-
- name: Build package
33-
run: python setup.py sdist bdist_wheel
31+
- name: Build package
32+
run: uv build
3433

35-
- name: Publish package
36-
uses: pypa/gh-action-pypi-publish@release/v1
34+
- name: Publish package
35+
run: uv publish

.github/workflows/test.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1717

1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v6
2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v5
21+
uses: actions/setup-python@v6
2222
with:
2323
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v7
27+
2428
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install -r requirements.txt
29+
run: uv sync --all-groups
30+
2831
- name: Run tests
29-
run: pytest
32+
run: uv run pytest
3033
env:
3134
IPINFO_TOKEN: ${{ secrets.IPINFO_TOKEN }}

ipinfo/handler_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import sys
99

10-
from .version import SDK_VERSION
10+
from .version import __version__ as SDK_VERSION
1111

1212
# Base URL to make requests against.
1313
API_URL = "https://ipinfo.io"

ipinfo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SDK_VERSION = "5.4.1"
1+
__version__ = "5.4.1"

pyproject.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[project]
2+
name = "ipinfo"
3+
dynamic = ["version"]
4+
description = "Official Python library for IPInfo"
5+
readme = "README.md"
6+
authors = [
7+
{ name = "IPinfo", email = "support@ipinfo.io" }
8+
]
9+
license = { text = "Apache License 2.0" }
10+
requires-python = ">=3.10"
11+
dependencies = [
12+
"requests>=2.18.4",
13+
"cachetools==4.2.0",
14+
"aiohttp>=3.12.14,<=4",
15+
]
16+
17+
[project.urls]
18+
Homepage = "https://github.com/ipinfo/python"
19+
Documentation = "https://ipinfo.io/developers"
20+
21+
[build-system]
22+
requires = ["hatchling"]
23+
build-backend = "hatchling.build"
24+
25+
[tool.hatch.version]
26+
path = "ipinfo/version.py"
27+
28+
[tool.hatch.build.targets.wheel]
29+
packages = ["ipinfo"]
30+
31+
[dependency-groups]
32+
dev = [
33+
"pytest==8.4.1",
34+
"pytest-asyncio==1.1.0",
35+
"black==22.6.0",
36+
]

requirements.in

Lines changed: 0 additions & 12 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 88 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)