Metadata-Version: 2.4
Name: ud-resolver
Version: 1.1.0
Summary: A universal dependency resolver supporting multiple package ecosystems
Author-email: Universal Dependency Resolver Team <team@udr.example.com>
License: MIT
Project-URL: Homepage, https://github.com/code-with-zeeshan/universal-dependency-resolver
Project-URL: Repository, https://github.com/code-with-zeeshan/universal-dependency-resolver
Project-URL: Documentation, https://github.com/code-with-zeeshan/universal-dependency-resolver
Keywords: dependency,resolver,package-manager,compatibility
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi<0.116,>=0.115.0
Requires-Dist: uvicorn<0.25,>=0.24
Requires-Dist: pydantic<3,>=2.5.0
Requires-Dist: aiohttp<4,>=3.9
Requires-Dist: requests<3,>=2.31
Requires-Dist: beautifulsoup4<5,>=4.12
Requires-Dist: packaging<24,>=23.2
Requires-Dist: tomli-w<2,>=1.0
Requires-Dist: toml<1,>=0.10
Requires-Dist: pyyaml<7,>=6.0.1
Requires-Dist: networkx<4,>=3.2.1
Requires-Dist: z3-solver<5,>=4.12
Requires-Dist: sqlalchemy<3,>=2.0.23
Requires-Dist: alembic<2,>=1.12
Requires-Dist: slowapi<1,>=0.1.9
Requires-Dist: email-validator<3,>=2.1
Requires-Dist: python-multipart<1,>=0.0.6
Requires-Dist: jinja2<4,>=3.1.2
Requires-Dist: structlog<25,>=24.1
Requires-Dist: prometheus-fastapi-instrumentator<7,>=6.1
Provides-Extra: system
Requires-Dist: psutil<6,>=5.9.6; extra == "system"
Requires-Dist: py-cpuinfo<10,>=9.0; extra == "system"
Requires-Dist: distro<2,>=1.8; extra == "system"
Requires-Dist: gputil<2,>=1.4; extra == "system"
Requires-Dist: nvidia-ml-py<13,>=12.535; extra == "system"
Provides-Extra: security
Requires-Dist: python-jose[cryptography]<4,>=3.3; extra == "security"
Requires-Dist: passlib[bcrypt]<2,>=1.7.4; extra == "security"
Requires-Dist: bcrypt<5; extra == "security"
Provides-Extra: dev
Requires-Dist: pytest<8,>=7.4; extra == "dev"
Requires-Dist: pytest-asyncio<1,>=0.21; extra == "dev"
Requires-Dist: pytest-cov<6,>=4.1; extra == "dev"
Requires-Dist: httpx<1,>=0.25; extra == "dev"
Requires-Dist: black<24,>=23.11; extra == "dev"
Requires-Dist: flake8<7,>=6.1; extra == "dev"
Requires-Dist: mypy<2,>=1.7; extra == "dev"
Requires-Dist: bandit<2,>=1.7; extra == "dev"
Provides-Extra: postgres
Requires-Dist: psycopg2-binary<3,>=2.9.9; extra == "postgres"
Requires-Dist: redis<6,>=5.0.1; extra == "postgres"
Requires-Dist: celery<6,>=5.3.4; extra == "postgres"
Requires-Dist: aiocache<1,>=0.12.2; extra == "postgres"
Provides-Extra: monitoring
Requires-Dist: opentelemetry-api<2,>=1.22; extra == "monitoring"
Requires-Dist: opentelemetry-sdk<2,>=1.22; extra == "monitoring"
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.43b0; extra == "monitoring"
Requires-Dist: opentelemetry-instrumentation-httpx>=0.43b0; extra == "monitoring"
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.22; extra == "monitoring"
Requires-Dist: sentry-sdk[fastapi]<2,>=1.39; extra == "monitoring"
Requires-Dist: python-socketio<6,>=5.11; extra == "monitoring"
Requires-Dist: prometheus-client<1,>=0.19; extra == "monitoring"
Provides-Extra: all
Requires-Dist: ud-resolver[monitoring,postgres,security,system]; extra == "all"
Dynamic: license-file

# Universal Dependency Resolver

Resolve dependencies across **PyPI (pip)**, **npm**, **Cargo**, **Go**, and more — detect conflicts, check system compatibility, and export to any format.

```
udr resolve numpy@pypi torch@pypi
  → numpy 1.26.2, torch 2.1.2+cu121 (CUDA 12.1)
```

### Package availability

| Source | Install | Published via |
|--------|---------|---------------|
| **PyPI** | `pip install ud-resolver` | GitHub Actions on release |
| **GitHub Packages** | `pip install ud-resolver --index-url https://pypi.pkg.github.com/code-with-zeeshan/` | GitHub Actions on release |
| **GHCR (Docker)** | `docker pull ghcr.io/code-with-zeeshan/universal-dependency-resolver-backend:latest` | CI on every push |
| **GitHub Releases** | Binary downloads from [Releases](https://github.com/code-with-zeeshan/universal-dependency-resolver/releases) | Manual / CI tag |

> **PyPI note**: The package is published on PyPI as **`ud-resolver`** — install with `pip install ud-resolver`, *not* `universal-dependency-resolver`.

---

## The Problem

You have a project that depends on packages from multiple ecosystems. A Python script calls a Node service. A Docker image needs both `pip` and `apt` packages. A CI pipeline must pin every transitive dependency across all of them.

Existing tools only work within one ecosystem (`pip-compile`, `npm ls`, `bundler`). Cross-ecosystem conflicts go undetected until runtime. System compatibility (GPU, CUDA, OS version) is never checked.

This tool solves that.

## What It Does

```
Input:  ["requests>=2.25", "torch==2.0", "express@^4.18"]
                                ↓
               Fetch metadata from PyPI / npm / Conda / ...
               Detect target system (OS, GPU, Python, CUDA)
               Resolve conflicts with SAT solver
                                ↓
Output: Locked dependency tree + export (Dockerfile, requirements.txt, ...)
```

## Quick Example

```bash
curl -X POST http://localhost:8000/api/v1/packages/resolve \
  -H "Content-Type: application/json" \
  -d '{
    "packages": [
      {"name": "requests", "ecosystem": "pypi"},
      {"name": "express", "ecosystem": "npm"}
    ],
    "auto_detect_system": true
  }'
```

Returns a resolved dependency tree with all transitive deps, conflict status, and system compatibility notes.

| Feature | What it does |
|---------|--------------|
| **Multi-ecosystem** | PyPI (pip), npm, Cargo, Go, Conda, Maven, NuGet, RubyGems, Linux packages, Homebrew |
| **GPU-aware resolution** | Scans CUDA, cuDNN, GPU memory — resolves CUDA variants automatically |
| **System scan** | Detects OS, CPU, GPU, Python, Node.js, GCC, Java |
| **12 export formats** | Dockerfile, requirements.txt, package.json, docker-compose.yml, install.sh, CMakeLists.txt, pyproject.toml, environment.yml, Cargo.toml, build.gradle, pom.xml, Gemfile |
| **CI/CD ready** | CLI for pipelines, health check endpoint, structured logging |
| **Desktop app** | Cross-platform Electron app with integrated Python backend |

## Quick Start

### PyPI (recommended)

```bash
pip install ud-resolver
```

Install with extras for additional features:
```bash
pip install "ud-resolver[system]"       # GPU & system scanning
pip install "ud-resolver[monitoring]"   # OpenTelemetry & Sentry
pip install "ud-resolver[security]"     # Auth & JWT support
pip install "ud-resolver[postgres]"     # PostgreSQL + Redis + Celery
pip install "ud-resolver[all]"          # Everything
```

### GitHub Packages

```bash
pip install ud-resolver --index-url https://pypi.pkg.github.com/code-with-zeeshan/
```

This requires GitHub authentication. Create a [PAT](https://github.com/settings/tokens) with `read:packages` scope and use it in `~/.netrc` or `PIP_EXTRA_INDEX_URL`:

```bash
echo "machine pypi.pkg.github.com login $GITHUB_USER password $GITHUB_TOKEN" > ~/.netrc
pip install ud-resolver
```

### From source

```bash
git clone https://github.com/code-with-zeeshan/universal-dependency-resolver.git
cd universal-dependency-resolver
pip install -e .
```

### Use as CLI

```bash
# Start the API server
udr serve --port 8000

# Check system compatibility
udr check

# Resolve dependencies
udr resolve numpy pandas scikit-learn

# Resolve from other ecosystems
udr resolve react vue -e npm
udr resolve serde tokio -e crates

# Show system info
udr info

# Auto-detect manifests in project dir and lock all deps
udr lock

# Lock with explicit manifest
udr lock --manifest requirements.txt --manifest package.json

# Dry-run lock (no files written)
udr lock --dry-run

# Resolve with JSON output
udr resolve torch torchvision --format json
```

### Desktop app

```bash
cd desktop
npm install
npm start
```

The Electron app spawns the Python backend automatically and opens the Vue.js UI. Binary downloads are available from GitHub Releases.

### Web UI

```bash
cd frontend && npm install && npm run serve
# → http://localhost:8080
```

The frontend connects to the backend at `http://localhost:8000` (configurable via `VUE_APP_API_URL`).

### Use as Python Library

```python
import asyncio
from backend.core.data_aggregator import DataAggregator
from backend.core.conflict_resolver import ConflictResolver
from backend.core.system_scanner import SystemScanner
from backend.manifest_detector import ManifestDetector

async def main():
    scanner = SystemScanner()
    system_info = await scanner.scan_all()
    print(system_info["platform"]["system"], system_info["cpu"]["brand"])

    aggregator = DataAggregator()
    data = await aggregator.get_package_info("torch", ecosystem="pypi",
                                              include_dependencies=True,
                                              include_versions=True)
    print(data["name"], data["versions"])

    detector = ManifestDetector("./my-project")
    manifests = detector.detect()
    packages = detector.normalize(detector.parse_all(manifests))
    print(f"{len(packages)} packages found")

asyncio.run(main())
```

### Docker (production)

Pre-built images are available on **GitHub Container Registry (GHCR)**:

```bash
docker pull ghcr.io/code-with-zeeshan/universal-dependency-resolver-backend:latest
docker pull ghcr.io/code-with-zeeshan/universal-dependency-resolver-frontend:latest
```

Or build and run locally:

```bash
cp .env.example .env
docker compose up -d
docker compose exec backend alembic upgrade head

# Frontend:  http://localhost:8080
# API Docs:  http://localhost:8000/api/v1/docs
```

> **Note**: The Docker images are published automatically via CI on every push to `main` and on tags (`v*`).

## How It Works

```
Your request → Fetch metadata from ecosystem registries
                   ↓
            Scan target system (OS, GPU, Python, CUDA)
                   ↓
            Resolve conflicts with SAT solver
                   ↓
            Export to 12 formats
```

The system runs as a FastAPI service with optional PostgreSQL, Redis, and a Vue.js frontend.

## API Quick Reference

| Endpoint | Method | Purpose |
|----------|--------|---------|
| `/api/v1/packages/search` | GET | Search across ecosystems |
| `/api/v1/packages/{ecosystem}/{name}` | GET | Get package info |
| `/api/v1/packages/versions` | GET | List versions |
| `/api/v1/packages/resolve` | POST | Resolve dependencies |
| `/api/v1/packages/export` | POST | Export to any format |
| `/api/v1/packages/export-formats` | GET | Available export formats |
| `/api/v1/system/info` | GET | System information |
| `/api/v1/system/check-compatibility` | POST | Check dependency-system fit |
| `/api/v1/scan/github` | POST | Scan a GitHub repo |
| `/api/v1/scan/upload` | POST | Scan an uploaded archive |
| `/api/v1/scan/local` | POST | Scan a local directory |
| `/api/v1/health` | GET | Health check |

Full reference in [docs/API.md](docs/API.md).

## Testing

```bash
# Unit tests
python -m pytest tests/unit/

# Frontend tests
cd frontend && npm run test:unit

# E2E tests (requires Chromium)
cd frontend && npm run test:e2e
```

## Roadmap

| Priority | Feature | Status |
|----------|---------|--------|
| 🔴 High | Python SDK with async support | ✅ Done |
| 🔴 High | CLI tool for CI/CD | ✅ Done |
| 🟡 Medium | JavaScript/TypeScript SDK | Planned |
| 🟡 Medium | CI/CD integration examples (GitHub Actions, GitLab CI) | Planned |
| 🟡 Medium | SBOM export (CycloneDX, SPDX) | Planned |
| 🟡 Medium | Visual dependency graphs | Planned |
| 🟢 Low | Plugin system for custom ecosystems | Researching |

---

See [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md) for production deployment,
[CONTRIBUTING.md](CONTRIBUTING.md) to contribute,
and [LICENSE](LICENSE) for licensing (MIT).
