Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.vscode/*
.claude/*
98 changes: 6 additions & 92 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,110 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-xml
- id: debug-statements
- id: check-docstring-first
- id: requirements-txt-fixer

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
language_version: python3
args: [--line-length=88]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.284
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
additional_dependencies: [types-all]
args: [--ignore-missing-imports]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile=black, --line-length=88]

- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
hooks:
- id: prettier
types_or: [yaml, markdown, json]

- repo: https://github.com/adamchainz/django-upgrade
rev: 1.12.0
hooks:
- id: django-upgrade
args: [--target-version, "4.2"]

- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
additional_dependencies: [flake8]

- repo: https://github.com/pre-commit/mirrors-bandit
rev: v1.7.5
hooks:
- id: bandit
args: [-r, src/, -f, json, -o, bandit-report.json]
exclude: tests/

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.4.1
hooks:
- id: codespell
args: [--skip=*.pyc,*.pyo,*.pyd,__pycache__,.git,.tox,.venv,venv,env,.mypy_cache,.pytest_cache,*.egg-info,dist,build]

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
hooks:
- id: commitizen

- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
args: [--maxfail=1, --tb=short]

- id: docs-check
name: docs-check
entry: bash
language: system
pass_filenames: false
always_run: true
args: [-c, "cd docs && make html"]

- id: security-check
name: security-check
entry: safety
language: system
pass_filenames: false
always_run: true
args: [check, --json, --output, safety-report.json]
args: [--skip, "*.lock,*.pyc"]
100 changes: 29 additions & 71 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
.PHONY: help install install-dev test test-cov lint format type-check docs clean build release
.PHONY: help install install-dev test test-cov test-fast lint format type-check check docs docs-serve docs-clean clean build build-check release dev-setup ci demo validate show

help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

install: ## Install package in production mode
uv pip install -e .
uv sync --no-dev

install-dev: ## Install package in development mode with all dependencies
uv pip install -e ".[dev,test,docs]"
uv sync
pre-commit install

test: ## Run tests
pytest
uv run pytest

test-cov: ## Run tests with coverage
pytest --cov=depcon --cov-report=html --cov-report=term-missing
uv run pytest --cov=depcon --cov-report=html --cov-report=term-missing

test-fast: ## Run tests without coverage (faster)
pytest --no-cov
uv run pytest --no-cov

lint: ## Run linting
ruff check src/ tests/
black --check src/ tests/
lint: ## Check code style
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/

format: ## Format code
black src/ tests/
ruff check src/ tests/ --fix
uv run ruff format src/ tests/
uv run ruff check --fix src/ tests/

type-check: ## Run type checking
mypy src/
uv run ty check

check: lint type-check test ## Run all checks

Expand All @@ -43,81 +42,40 @@ docs-clean: ## Clean documentation build
rm -rf site/

clean: ## Clean build artifacts
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf .pytest_cache/
rm -rf .coverage
rm -rf htmlcov/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
rm -rf build/ dist/ *.egg-info/ .pytest_cache/ .coverage htmlcov/ .mypy_cache/ .ruff_cache/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete

build: ## Build package
uv build

build-check: ## Check built package
build-check: ## Build and verify package
uv build
uv pip install dist/*.whl
depcon --version

release: ## Release package (requires proper version bumping)
@echo "Make sure you have:"
@echo "1. Updated version in pyproject.toml"
@echo "2. Updated changelog"
@echo "3. Committed all changes"
@echo "4. Created and pushed tag"
@echo "Then run: uv publish"
release: ## Show release instructions
@echo "Release steps:"
@echo "1. Update version in pyproject.toml"
@echo "2. Update changelog"
@echo "3. Commit all changes"
@echo "4. Create and push tag: git tag v<version> && git push --tags"
@echo "5. GitHub Actions will publish to PyPI"

dev-setup: install-dev ## Set up development environment
@echo "Development environment set up!"
@echo "Run 'make check' to verify everything is working"
@echo "Development environment ready! Run 'make check' to verify."

ci: ## Run CI checks locally
pre-commit run --all-files
pytest --cov=depcon --cov-report=xml

security: ## Run security checks
safety check
bandit -r src/

benchmark: ## Run performance benchmarks
pytest --benchmark-only

profile: ## Profile the code
python -m cProfile -o profile.stats -m depcon.cli --help
python -c "import pstats; pstats.Stats('profile.stats').sort_stats('cumulative').print_stats(20)"

update-deps: ## Update dependencies
uv pip install --upgrade -e ".[dev,test,docs]"

check-deps: ## Check for outdated dependencies
uv pip list --outdated

install-hooks: ## Install pre-commit hooks
pre-commit install

update-hooks: ## Update pre-commit hooks
pre-commit autoupdate

run-hooks: ## Run pre-commit hooks on all files
pre-commit run --all-files
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
uv run ty check
uv run pytest --cov=depcon --cov-report=xml

demo: ## Run demo script
python examples/demo.py
uv run python examples/demo.py

validate: ## Validate pyproject.toml
depcon validate
uv run depcon validate

show: ## Show dependencies
depcon show

convert-example: ## Convert example requirements
depcon convert -r examples/requirements.txt --verbose

# Development shortcuts
dev: install-dev ## Alias for install-dev
check-all: check ## Alias for check
test-all: test-cov ## Alias for test-cov
format-all: format ## Alias for format
uv run depcon show
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# depcon

```text
|
__| _ _ __ __ _ _
/ | |/ |/ \_/ / \_/ |/ |
|
__| _ _ __ __ _ _
/ | |/ |/ \_/ / \_/ |/ |
\_/|_/|__/|__/ \___/\__/ | |_/
/|
\|
/|
\|
```

`depcon` is a modern, fully-featured tool for converting legacy `requirements.txt` files to the standardized `pyproject.toml` format with full PEP 621 support. It provides intelligent dependency grouping, validation, and seamless integration with modern Python packaging tools like `uv`, `hatchling`, and `setuptools`.

## Features

- **Full PEP 621 & PEP 735 Support**: Complete support for modern Python packaging standards
- **Full PEP 621, PEP 635 & PEP 735 Support**: Complete support for modern Python packaging standards
- **PEP 639 License**: Generates modern `license = "MIT"` SPDX string format
- **Intelligent Dependency Grouping**: Automatically categorizes dependencies into main, dev, test, and docs groups
- **PEP 735 include-group**: Dependency groups can reference other groups (e.g., dev includes test)
- **Proper Dependency Types**: Correctly distinguishes between dependency-groups (PEP 735) and optional-dependencies (PEP 621 extras)
- **Advanced Parsing**: Handles complex requirements files including pip-tools, editable installs, and URLs
- **Validation**: Built-in dependency validation and error checking
- **Multiple Build Backends**: Support for hatchling, setuptools, and poetry
- **Tool Integration**: Automatic configuration for uv, hatch, and other modern tools
- **Rich CLI**: Beautiful command-line interface with progress indicators and summaries
- **Flexible Configuration**: Extensive options for customization and control
- **Export & Sync**: Export dependencies to requirements.txt and sync between formats

## Installation
Expand Down Expand Up @@ -96,7 +96,7 @@ The main command for converting requirements files to modern pyproject.toml form
- `--project-name TEXT`: Project name (if creating new pyproject.toml)
- `--project-version TEXT`: Project version (if creating new pyproject.toml)
- `--project-description TEXT`: Project description (if creating new pyproject.toml)
- `--python-version TEXT`: Python version requirement (default: >=3.11)
- `--python-version TEXT`: Python version requirement (default: >=3.12)
- `--use-optional-deps / --use-dependency-groups`: Use optional-dependencies (PEP 621 extras) instead of dependency-groups (PEP 735)
- `--remove-duplicates / --keep-duplicates`: Remove duplicate dependencies across groups (default: remove)
- `--strict / --no-strict`: Strict mode: fail on parsing errors instead of warning
Expand Down Expand Up @@ -199,7 +199,7 @@ depcon convert \
--project-name "my-project" \
--project-description "A great Python project" \
--project-version "1.0.0" \
--python-version ">=3.9"
--python-version ">=3.12"

# Use different build backend
depcon convert -r requirements.txt --build-backend setuptools
Expand Down Expand Up @@ -272,7 +272,7 @@ depcon sync --dry-run

## Generated pyproject.toml Structure

The tool generates modern `pyproject.toml` files following PEP 621 and PEP 735 standards:
The tool generates modern `pyproject.toml` files following PEP 621, PEP 639, and PEP 735 standards:

```toml
[build-system]
Expand All @@ -283,7 +283,8 @@ build-backend = "hatchling.build"
name = "my-project"
version = "1.0.0"
description = "A great Python project"
requires-python = ">=3.11"
requires-python = ">=3.12"
license = "MIT"
dependencies = [
"requests>=2.25.0",
"numpy>=1.20.0",
Expand All @@ -296,8 +297,7 @@ security = [

[dependency-groups]
dev = [
"pytest>=7.0.0",
"black>=23.0.0",
{include-group = "test"},
"ruff>=0.1.0",
]
test = [
Expand All @@ -308,16 +308,13 @@ docs = [
"sphinx>=5.0.0",
"sphinx-rtd-theme>=1.0.0",
]

[tool.hatch.build.targets.wheel]
packages = ["src"]
```

### Understanding Dependency Types

- **`dependencies`**: Core runtime dependencies required for the package
- **`[project.optional-dependencies]`** (PEP 621): Installable extras (e.g., `pip install package[security]`)
- **`[dependency-groups]`** (PEP 735): Development dependencies for tools like `uv` (not installable extras)
- **`[dependency-groups]`** (PEP 735): Development dependencies for tools like `uv` (not installable extras). Supports `include-group` to compose groups.

## Supported File Formats

Expand Down Expand Up @@ -396,11 +393,11 @@ Comprehensive documentation is available at [https://lancereinsmith.github.io/de
- **[API Reference](https://lancereinsmith.github.io/depcon/api_reference)** - Detailed API documentation
- **[Examples](https://lancereinsmith.github.io/depcon/examples)** - Real-world usage examples
- **[Contributing](https://lancereinsmith.github.io/depcon/contributing)** - How to contribute to the project
- **[Chaneglog](https://lancereinsmith.github.io/depcon/changelog)** - Changelog
- **[Changelog](https://lancereinsmith.github.io/depcon/changelog)** - Changelog

## Contributing

Contributions are welcome! Please see our [Contributing Guide](docs/contributing.md), [Development Guide](docs/development.md), [Contributors](docs/contributors.md), and [Code of Conduct](docs/code_of_conduct.md) for details.
Contributions are welcome! Please see our [Contributing Guide](docs/contributing.md) for details.

### Quick Development Setup

Expand All @@ -410,7 +407,7 @@ git clone https://github.com/lancereinsmith/depcon.git
cd depcon

# Install in development mode
uv pip install -e ".[dev]"
uv sync

# Install pre-commit hooks
pre-commit install
Expand Down
Loading
Loading