Metadata-Version: 2.4
Name: dcprac-algorithms
Version: 0.1.2
Summary: Python implementations of classic distributed computing algorithms.
Author: dcprac
License-Expression: MIT
Project-URL: Homepage, https://example.com/dcprac-algorithms
Project-URL: Repository, https://example.com/dcprac-algorithms
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Distributed Computing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# dcprac-algorithms

Python package version of your Java implementations for:

- Banker's Algorithm
- Berkeley Time Synchronization (kept as `berkely` for compatibility with your naming)
- Bully Election Algorithm
- Distributed Global Average (ring neighbors)
- Raymond Mutual Exclusion (simplified simulation)
- Ricart-Agrawala Mutual Exclusion
- Single socket chat server/client
- Group communication server/client

## Install locally

```bash
pip install -e .
```

## Quick usage

```python
from dc_algorithms import (
    is_safe_state,
    synchronize_times,
    run_bully_election,
    run_distributed_global_average,
    RaymondMutex,
    evaluate_ricart_request,
)

safe, seq = is_safe_state(
    allocation=[[0, 1], [1, 0]],
    max_demand=[[1, 1], [1, 1]],
    available=[1, 0],
)
print(safe, seq)
```

## Build package

```bash
python -m pip install --upgrade build twine pkginfo
python -m build
```

This creates artifacts in `dist/`.

## Publish to PyPI

```bash
python -m twine check dist/*
python -m twine upload dist/*
```

If prompted for credentials, use:

- Username: `__token__`
- Password: your PyPI API token (starts with `pypi-`)

PowerShell example:

```powershell
$env:TWINE_USERNAME="__token__"
$env:TWINE_PASSWORD="pypi-xxxxxxxxxxxxxxxx"
python -m twine upload dist/*
```

## CLI commands (after pip install)

```bash
dc-server --host 0.0.0.0 --port 5000
dc-client --host localhost --port 5000
dc-groupserver --host 0.0.0.0 --port 5001
dc-groupclient --host localhost --port 5001
```

Before publishing, update at least:

- `version` in `pyproject.toml`
- `project.urls` in `pyproject.toml`
- author metadata if needed
