Skip to content

Commit f2b6879

Browse files
committed
chore: migrate project configuration from setup.py to pyproject.toml
1 parent 38a7af8 commit f2b6879

File tree

8 files changed

+391
-80
lines changed

8 files changed

+391
-80
lines changed

.github/workflows/pypi-publish.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ jobs:
2929
steps:
3030
- name: Checkout
3131
uses: actions/checkout@v4
32-
- name: Install dependencies
33-
run: |
34-
pip install twine
35-
- name: Run package build
36-
run: |
37-
python setup.py sdist
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v4
35+
with:
36+
version: "latest"
37+
38+
- name: Set up Python
39+
run: uv python install 3.12
40+
41+
- name: Build package
42+
run: uv build
43+
3844
- name: Publish package to PyPI
3945
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,26 @@ on:
1717

1818
jobs:
1919
Tests:
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
2323
python-version: [3.12]
2424
steps:
2525
- name: Checkout
2626
uses: actions/checkout@v4
2727

28-
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v5
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v4
3030
with:
31-
python-version: ${{ matrix.python-version }}
32-
- name: Generate dependencies
31+
version: "latest"
32+
33+
- name: Set up Python ${{ matrix.python-version }}
34+
run: uv python install ${{ matrix.python-version }}
35+
36+
- name: Install dependencies and run linting
3337
run: |
34-
pip install -e ".[dev]"
35-
ruff check .
38+
uv sync --group dev --all-extras
39+
uv run ruff check .
40+
3641
- name: Run tests
37-
run: python -m unittest discover -s tests
42+
run: uv run python -m pytest tests/ -v

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

README.md

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,41 @@
55
### The Problem
66

77
When working with AI prompts, it is often necessary to provide code context to the model to generate useful responses. This can be a time-consuming task, especially when working with large codebases.
8-
CCprompt is a tool designed to extract code context for AI prompts based on provided function or class names. It supports both Python and JavaScript/TypeScript codebases.
8+
CCprompt is a tool designed to extract code context for AI prompts based on provided function or class names. It supports both Python codebases.
99
Providing such context can help AI models generate more accurate and relevant responses.
1010

1111
## Features
1212

13-
- Supports Python languages, JavaScript/TypeScript support coming soon.
14-
- Extracts functions or classes and their inheritance chains.
15-
- Configurable via a JSON configuration file or command-line arguments.
16-
- Excludes virtual environment directories if needed.
17-
- zero dependencies if you are using it for python.
13+
- Supports Python codebase.
14+
- Extracts functions or classes and their inheritance chains
15+
- Configurable via a JSON configuration file or command-line arguments
16+
- Excludes virtual environment directories if needed
17+
- Zero runtime dependencies for Python-only usage
18+
- Optional JavaScript support via esprima
1819

1920
## Installation
2021

22+
### Using uv (recommended)
23+
24+
```bash
25+
uv add ccprompt
26+
```
27+
28+
### Using pip
29+
2130
```bash
2231
pip install ccprompt
2332
```
2433

34+
### Development Setup
35+
36+
```bash
37+
git clone https://github.com/Samk13/ccprompt.git
38+
cd ccprompt
39+
uv sync
40+
uv run ccprompt --help
41+
```
42+
2543
## Usage
2644

2745
### first time usage
@@ -61,25 +79,55 @@ ccprompt --help
6179

6280
## Development
6381

64-
```bash
65-
pip install -e .["dev"]
66-
```
67-
68-
## Commands
82+
### Quick Start
6983

7084
```bash
71-
# installs development dependencies specified in setup.py
72-
make install
85+
# Install dependencies
86+
uv sync
7387

74-
# Runs tests
88+
# Run tests
7589
make test
7690

77-
# Check linting issues
91+
# Check code style
7892
make lint-check
7993

80-
# Runs linting and fixes issues
81-
make lint-fix
94+
# See all available commands
95+
make help
96+
```
8297

83-
# Formats code using Ruff
84-
make format
98+
### Available Make Commands
99+
100+
```bash
101+
# Dependencies and Setup
102+
make sync # Install dependencies with uv
103+
make install # Alias for sync
104+
make clean # Remove build artifacts and cache
105+
106+
# Development
107+
make run # Run ccprompt with debug logging
108+
make test # Run test suite with pytest
109+
make build # Build distribution packages
110+
111+
# Code Quality
112+
make lint-check # Check code style with ruff
113+
make lint-fix # Fix code style issues with ruff
114+
make format # Format and fix code with ruff
115+
116+
# Utilities
117+
make change-log # Show changes since last tag
118+
make help # Show all available commands
85119
```
120+
121+
## Requirements
122+
123+
- Python >=3.12
124+
- [uv](https://docs.astral.sh/uv/) (recommended) or pip
125+
126+
## Project Structure
127+
128+
This project uses modern Python packaging with:
129+
- **`pyproject.toml`** - Project configuration and dependencies
130+
- **`uv`** - Fast Python package manager
131+
- **`pytest`** - Testing framework
132+
- **`ruff`** - Code formatting and linting
133+
- **`hatchling`** - Build backend

makefile

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,56 @@
1-
.PHONY: test format lint install ruff-check
1+
.PHONY: test format lint install ruff-check sync build clean help
2+
3+
sync:
4+
uv sync --group dev --all-extras
25

36
install:
4-
pip install .[dev]
7+
uv sync --group dev --all-extras
58

69
dev-install:
7-
pip install -e .
10+
uv sync --group dev --all-extras
11+
12+
build:
13+
uv build
814

915
run:
10-
ccprompt --log_level DEBUG
16+
uv run ccprompt --log_level DEBUG
1117

1218
test:
13-
python -m unittest discover -s tests
19+
uv run pytest
1420

1521
format:
16-
ruff format . && ruff check . --fix
22+
uv run ruff format . && uv run ruff check . --fix
1723

1824
lint-check:
19-
ruff check .
25+
uv run ruff check .
2026

2127
lint-fix:
22-
ruff check . --fix
28+
uv run ruff check . --fix
2329

2430
change-log:
2531
# get the latest changes from the last tag for CHANGES.rst
26-
@git log $$(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s"
32+
@git log $$(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s"
33+
34+
help:
35+
@echo "Available commands:"
36+
@echo " sync - Install dependencies with uv"
37+
@echo " install - Alias for sync"
38+
@echo " dev-install - Alias for sync (for compatibility)"
39+
@echo " build - Build distribution packages"
40+
@echo " run - Run ccprompt with debug logging"
41+
@echo " test - Run test suite with pytest"
42+
@echo " format - Format and fix code with ruff"
43+
@echo " lint-check - Check code style with ruff"
44+
@echo " lint-fix - Fix code style issues with ruff"
45+
@echo " clean - Remove build artifacts and cache"
46+
@echo " change-log - Show changes since last tag"
47+
@echo " help - Show this help message"
48+
49+
clean:
50+
rm -rf dist/
51+
rm -rf build/
52+
rm -rf *.egg-info/
53+
rm -rf .pytest_cache/
54+
rm -rf .ruff_cache/
55+
find . -type d -name __pycache__ -exec rm -rf {} +
56+
find . -type f -name "*.pyc" -delete

pyproject.toml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "ccprompt"
7+
dynamic = ["version"]
8+
description = "Extract code context for AI prompts based on a function or class name."
9+
readme = "README.md"
10+
requires-python = ">=3.9"
11+
license = {text = "MIT"}
12+
authors = [
13+
{ name = "Sam Arbid", email = "[email protected]" },
14+
]
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"Operating System :: OS Independent",
18+
]
19+
dependencies = []
20+
21+
[dependency-groups]
22+
dev = [
23+
"pytest>=8.3.5",
24+
"ruff>=0.11.7",
25+
]
26+
27+
[project.optional-dependencies]
28+
javascript = ["esprima"]
29+
30+
[project.urls]
31+
Homepage = "https://github.com/Samk13/ccprompt"
32+
Repository = "https://github.com/Samk13/ccprompt"
33+
34+
[project.scripts]
35+
ccprompt = "ccprompt.main:main"
36+
37+
[tool.setuptools.dynamic]
38+
version = {attr = "ccprompt.__version__"}
39+
40+
[tool.setuptools.packages.find]
41+
where = ["."]
42+
include = ["ccprompt*"]
43+
44+
[tool.hatch.version]
45+
path = "ccprompt/__init__.py"
46+
47+
[tool.pytest.ini_options]
48+
testpaths = ["tests"]
49+
python_files = "test_*.py"
50+
python_functions = "test_*"
51+
python_classes = "Test*"
52+
addopts = "--verbose"
53+
54+
[tool.ruff.lint]
55+
# see: https://docs.astral.sh/ruff/configuration/
56+
# 1. Enable flake8-bugbear (`B`) rules, in addition to the defaults.
57+
# E W: https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
58+
# F: https://docs.astral.sh/ruff/rules/#pyflakes-f
59+
# I : https://docs.astral.sh/ruff/rules/#isort-i
60+
# PTH: https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
61+
select = ["E4", "E7", "E9", "F","I","PTH"]
62+
preview = true
63+
64+
# 2. Avoid enforcing line-length violations (`E501`)
65+
ignore = ["E501"]
66+
67+
# 3. Avoid trying to fix flake8-bugbear (`B`) violations.
68+
unfixable = ["B"]
69+
70+
# 4. Ignore `E402` (import violations) in all `__init__.py` files, and in selected subdirectories.
71+
[tool.ruff.lint.per-file-ignores]
72+
"__init__.py" = ["E402"]
73+
"**/{tests,docs,tools}/*" = ["E402"]
74+
75+
[tool.ruff.format]
76+
# Use single quotes in `ruff format` (commented out for now)
77+
# quote-style = "single"

setup.py

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

0 commit comments

Comments
 (0)