Metadata-Version: 2.4
Name: pykit-dev
Version: 0.1.0
Summary: Minimalist, Type-Safe DevOps Library for Python
Author-email: F9-o <ifslx.pro@gmail.com>
License: MIT License
        
        Copyright (c) 2026
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0.0
Requires-Dist: typing_extensions>=4.0.0
Requires-Dist: requests>=2.31.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: types-requests; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file

<div align="center">

# pykit-dev

### Minimalist, Type-Safe DevOps Library for Python

[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code Style: Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
[![Type Checked](https://img.shields.io/badge/mypy-checked-blue)](https://mypy-lang.org/)

<p align="center">
  <b>Standardize your daily DevOps scripts with a clean, unified API.</b><br>
  Built for professionals who need reliability, structured logging, and zero-boilerplate.
</p>

</div>

---

## ⚡ Features

- **🛡️ Robust Runner**: Execute shell commands with built-in retries, timeouts, and safe result handling.
- **⚙️ Environment Manager**: Strict validation, type casting (int, bool, float), and precedence handling (System > .env > Default).
- **💓 Health Checks**: One-line checks for HTTP endpoints, TCP ports, and system processes.
- **📝 Unified Logger**: Professional JSON/Text logging out-of-the-box, ready for Splunk/Datadog.
- **📐 Type Safe**: 100% typed code base compatible with MyPy and VSCode Pylance.

## 🚀 Installation

```bash
pip install pykit-dev
```

## 📚 Quick Start

### 1. Command Execution (Runner)

Execute commands confidently with retry logic and detailed results.

```python
from pykit_dev.runner import run, CommandExecutionError

try:
    # Run with automatic retries and timeout
    result = run("curl https://api.example.com", retry=2, timeout=5)

    print(f"Status: {result.exit_code}")
    print(f"Output: {result.stdout}")

except CommandExecutionError as e:
    print(f"Failed after retries: {e}")
```

### 2. Environment Management (Env)

Forget manual `os.getenv` casting and checking.

```python
from pykit_dev.env import env

# Load from .env file (optional)
env.load(".env")

# Type-safe retrieval
db_url = env.require("DATABASE_URL")             # Raises error if missing
debug = env.get("DEBUG", default=False, cast=bool) # Returns True/False, not "true"
max_conn = env.get("MAX_CONN", default=10, cast=int)
```

### 3. Health Checks

Verify dependencies before starting your application.

```python
from pykit_dev.health import health, HealthCheckFailed

try:
    health.http("https://api.github.com")
    health.tcp("localhost", 5432)
    health.process(1234) # Check by PID
    print("✅ System Healthy")

except HealthCheckFailed as e:
    print(f"❌ Health Check Failed: {e}")
```

### 4. Professional Logging

```python
from pykit_dev.core.logger import logger

logger.info("Deployment started", {"env": "production"})
# Output: {"timestamp": "...", "level": "INFO", "message": "Deployment started", "extra": {"env": "production"}}
```

## 🛠️ Utilities

```python
from pykit_dev.utils import start_timer, slugify

timer = start_timer()
# ... task ...
print(f"Elapsed: {timer.stop()}s")
```

## 🤝 Contributing

Contributions are welcome! Please ensure all code passes `mypy` and `pytest`.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📄 License

Distributed under the MIT License. See `LICENSE` for more information.

---

<div align="center">
  Maintained by <a href="https://github.com/F9-o">@F9-o</a>
</div>
