Skip to content

Commit 48832c3

Browse files
farhanclaude
andcommitted
build: migrate to uv, pyproject.toml, and PEP 735 dependency groups
- Replace setup.py/setup.cfg with pyproject.toml (PEP 621 static metadata) - Switch from pip-compile to uv with PEP 735 dependency groups; commit uv.lock - Update tox.ini to use tox-uv>=1 and uv-venv-lock-runner - Update CI to use astral-sh/setup-uv; SHA-pin all actions - Migrate .coveragerc config into pyproject.toml - Update Makefile: upgrade → uv lock --upgrade; requirements → uv sync - Remove requirements/ directory and stale config files - Retain pylint/isort/pycodestyle/pydocstyle/mypy as quality linters - Add static version = "3.1.0", replace hardcoded __version__ with importlib.metadata - Remove setuptools-scm, dynamic version, and redundant base dependency group - Fix sdist: include xapi_db_load/tests, prune example_configs/logs/private_configs - Remove deprecated license classifier superseded by PEP 639 - Remove codecov.yml with invented patch coverage threshold - Add doc8 to doc dependency group, remove twine duplicate Part of openedx/public-engineering#506 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 180db98 commit 48832c3

30 files changed

Lines changed: 2888 additions & 1650 deletions

.coveragerc

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

.github/workflows/ci.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
1-
name: Run all tests & checks
1+
name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
workflow_call:
88

99
jobs:
1010
run_tests:
11-
name: tests
11+
name: ${{ matrix.toxenv }}
1212
runs-on: ubuntu-latest
1313
strategy:
14+
fail-fast: true
1415
matrix:
15-
python-version: [ '3.12' ]
16-
permissions:
17-
# Gives the action the necessary permissions for publishing new
18-
# comments in pull requests.
19-
pull-requests: write
20-
# Gives the action the necessary permissions for pushing data to the
21-
# python-coverage-comment-action branch, and for editing existing
22-
# comments (to avoid publishing multiple comments in the same PR)
23-
contents: write
16+
python-version: ["3.12"]
17+
toxenv: [py]
2418

2519
steps:
26-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
27-
- name: setup python
28-
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
20+
- name: Checkout repository
21+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
2925
with:
30-
python-version: ${{ matrix.python-version }}
26+
enable-cache: true
27+
python-version: "${{ matrix.python-version }}"
3128

32-
- name: Install pip
33-
run: pip install -r requirements/pip.txt
29+
- name: Install CI dependencies
30+
run: uv sync --group ci
3431

35-
- name: Install Dependencies
36-
run: pip install -r requirements/ci.txt
32+
- name: Run tox
33+
run: uv run tox -e ${{ matrix.toxenv }}
3734

38-
- name: Run Tests
39-
run: tox
35+
- name: Upload coverage to Codecov
36+
if: matrix.toxenv == 'py' && matrix.python-version == '3.12'
37+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6.0.2
38+
with:
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
flags: unittests
41+
fail_ci_if_error: true

MANIFEST.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
include CHANGELOG.rst
22
include LICENSE.txt
33
include README.rst
4-
include requirements/base.in
5-
include requirements/constraints.txt
6-
recursive-include xapi-db-load *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg *.csv
4+
recursive-include xapi_db_load *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg *.csv

Makefile

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,24 @@ docs: ## generate Sphinx HTML documentation, including API docs
2929
tox -e docs
3030
$(BROWSER)docs/_build/html/index.html
3131

32-
# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
33-
PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS)
34-
35-
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
36-
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
37-
pip install -r requirements/pip-tools.txt
38-
pip install -qr requirements/pip.txt
39-
# Make sure to compile files after any other files they include!
40-
$(PIP_COMPILE) --allow-unsafe --rebuild -o requirements/pip.txt requirements/pip.in
41-
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
42-
pip install -qr requirements/pip.txt
43-
pip install -r requirements/pip-tools.txt
44-
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
45-
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
46-
$(PIP_COMPILE) -o requirements/doc.txt requirements/doc.in
47-
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
48-
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
49-
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
32+
upgrade: ## update the uv.lock file with the latest packages satisfying pyproject.toml
33+
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
34+
uv lock --upgrade
5035

5136
quality: ## check coding style with pycodestyle and pylint
52-
pylint xapi_db_load *.py
53-
pycodestyle xapi_db_load *.py
54-
pydocstyle xapi_db_load *.py
37+
pylint xapi_db_load
38+
pycodestyle xapi_db_load
39+
pydocstyle xapi_db_load
5540
mypy xapi_db_load
56-
isort --check-only --diff --recursive xapi_db_load *.py test_settings.py
57-
python setup.py bdist_wheel
41+
isort --check-only --diff xapi_db_load
42+
uv run python -m build
5843
twine check dist/*
5944
make selfcheck
6045

6146

6247
requirements: ## install development environment requirements
63-
pip install -r requirements/pip.txt
64-
pip install -r requirements/pip-tools.txt
65-
pip-sync requirements/dev.txt requirements/private.*
48+
uv sync --group dev
49+
uv tool install tox --with tox-uv
6650

6751
test: clean ## run tests in the current virtualenv
6852
pytest

codecov.yml

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

docs/conf.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,15 @@
1212
serve to show the default.
1313
"""
1414
import os
15-
import re
1615
import sys
1716
from datetime import datetime, UTC
17+
from importlib.metadata import PackageNotFoundError, version
1818
from subprocess import check_call
1919

20-
21-
def get_version(*file_paths):
22-
"""
23-
Extract the version string from the file.
24-
25-
Input:
26-
- file_paths: relative path fragments to file with
27-
version string
28-
"""
29-
filename = os.path.join(os.path.dirname(__file__), *file_paths)
30-
version_file = open(filename, encoding="utf8").read()
31-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
32-
if version_match:
33-
return version_match.group(1)
34-
raise RuntimeError("Unable to find version string.")
35-
36-
37-
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
38-
sys.path.append(REPO_ROOT)
39-
40-
VERSION = get_version("../xapi_db_load", "__init__.py")
20+
try:
21+
VERSION = version("xapi-db-load")
22+
except PackageNotFoundError:
23+
VERSION = "unknown"
4124

4225

4326
# If extensions (or modules to document with autodoc) are in another directory,

pyproject.toml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "xapi-db-load"
7+
version = "3.1.0"
8+
description = "Loads testing xAPI events into databases and LRSs"
9+
requires-python = ">=3.12"
10+
license = "AGPL-3.0"
11+
license-files = ["LICENSE.txt"]
12+
authors = [
13+
{name = "Open edX Project", email = "oscm@openedx.org"},
14+
]
15+
classifiers = [
16+
"Development Status :: 3 - Alpha",
17+
"Intended Audience :: Developers",
18+
"Natural Language :: English",
19+
"Operating System :: OS Independent",
20+
"Programming Language :: Python",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.12",
23+
]
24+
keywords = ["Python", "edx"]
25+
readme = "README.rst"
26+
27+
dependencies = [
28+
"chdb",
29+
"click",
30+
"clickhouse-connect[async]",
31+
"pyarrow",
32+
"pyyaml",
33+
"requests",
34+
"smart_open[s3]",
35+
"urwid",
36+
"uvloop",
37+
]
38+
39+
[project.scripts]
40+
xapi-db-load = "xapi_db_load.main:cli"
41+
42+
[project.urls]
43+
Repository = "https://github.com/openedx/xapi-db-load"
44+
"Issue tracker" = "https://github.com/openedx/xapi-db-load/issues"
45+
46+
[tool.setuptools.packages.find]
47+
exclude = ["docs*"]
48+
49+
[dependency-groups]
50+
# Each group mirrors its requirements/*.in file exactly.
51+
# "-r other.in" in the .in file → {include-group = "other"} here.
52+
53+
# From requirements/test.in
54+
test = [
55+
"pytest-asyncio",
56+
"pytest-cov",
57+
]
58+
59+
# From requirements/quality.in
60+
quality = [
61+
{include-group = "test"},
62+
"edx-lint",
63+
"isort",
64+
"mypy",
65+
"pycodestyle",
66+
"pydocstyle",
67+
"twine",
68+
]
69+
70+
# From requirements/doc.in
71+
doc = [
72+
{include-group = "test"},
73+
"build",
74+
"doc8",
75+
"Sphinx",
76+
"sphinx-book-theme",
77+
]
78+
79+
# From requirements/ci.in
80+
ci = [
81+
"tox",
82+
"tox-uv",
83+
]
84+
85+
# From requirements/dev.in (without pip-tools since that's replaced by uv)
86+
dev = [
87+
{include-group = "quality"},
88+
{include-group = "ci"},
89+
"diff-cover",
90+
]
91+
92+
[tool.uv]
93+
package = true
94+
95+
# DO NOT EDIT constraint-dependencies DIRECTLY.
96+
# This list is managed by `edx_lint write_uv_constraints`
97+
# and will be overwritten the next time `make upgrade` is run.
98+
# - GLOBAL constraints: edit edx_lint/files/common_constraints.txt
99+
# - REPO-SPECIFIC constraints: edit [tool.edx_lint].uv_constraints in this file
100+
constraint-dependencies = [
101+
"Django<6.0",
102+
"elasticsearch<7.14.0",
103+
]
104+
105+
[tool.edx_lint]
106+
# Repo-specific uv constraints merged with edx-lint's global constraints.
107+
# Local entries override global ones for the same package.
108+
# Run `make upgrade` to regenerate [tool.uv].constraint-dependencies.
109+
uv_constraints = []
110+
111+
[tool.coverage.run]
112+
branch = true
113+
source_pkgs = ["xapi_db_load"]
114+
omit = [
115+
"*/tests/*",
116+
]
117+
118+
[tool.coverage.report]
119+
show_missing = true
120+
121+
[tool.pytest.ini_options]
122+
addopts = "--cov xapi_db_load --cov-report term-missing --cov-report xml --log-level=INFO"
123+
norecursedirs = [".* docs requirements site-packages"]
124+
125+
[tool.isort]
126+
include_trailing_comma = true
127+
indent = " "
128+
line_length = 120
129+
multi_line_output = 3
130+
skip = ["migrations"]
131+
132+
[tool.mypy]
133+
python_version = "3.12"
134+
ignore_missing_imports = true
135+
check_untyped_defs = false
136+
warn_unused_ignores = true
137+
exclude = ["^docs/", "^build/", "^dist/"]
138+
139+
[[tool.mypy.overrides]]
140+
module = "xapi_db_load.tests.*"
141+
ignore_errors = true

requirements/base.in

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

0 commit comments

Comments
 (0)