diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..4d8026a --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,62 @@ +# Development Guidelines + +## Environment Setup + +### Prerequisites + +- Python 3.10+ +- Docker +- Make + +### Installation + +Create a virtual environment and install dependencies: + +```bash +make venv +make setup +``` + +This will install the project in editable mode, install dev tools, and set up git hooks. + +## Workflow + +### Dependency Management + +- **Lock dependencies**: Generates `requirements.txt` from `pyproject.toml`. + ```bash + make lock + ``` +- **Upgrade dependencies**: Updates packages to latest allowed versions. + ```bash + make upgrade + ``` +- **Verify compatibility of dependencies**: Checks each of the dependencies for python version compatibility, and marks dependencies that are not compatible with the given target version. + ```bash + # adjust py_version=3.xy as needed + make compatibility py_version=3.10 + ``` +- **Update SBOM**: Generate a Software Bill of Materials (SBOM) in `sbom.json` when dependencies are updated (tracked). + ```bash + make sbom + ``` +- **Audit dependencies**: Generates a security audit report in `audit.json` when dependencies are updated and review it (untracked). + ```bash + make audit + ``` + +### Quality Assurance + +- **Linting**: `make lint` +- **Formatting**: `make format` +- **Testing**: `make test` +- **Security Scan**: `make security` + +## Branch Naming Convention + +- `feature/`: For new features or functionality (e.g., `feature/add-login-page`). +- `fix/` or `bugfix/`: For fixing issues or bugs (e.g., `fix/header-formatting-issue`). +- `hotfix/`: For urgent, critical fixes in production (e.g., `hotfix/fix-db-connection-bug`). +- `release/`: For preparing new production releases (e.g., `release/v1.0.0` or `release/1.0.0`). +- `docs/`: For updating documentation. +- `chore/`: For maintenance tasks, dependency updates, or build improvements. \ No newline at end of file diff --git a/check_compatibility.py b/check_compatibility.py index 3804561..dcc1687 100644 --- a/check_compatibility.py +++ b/check_compatibility.py @@ -1,9 +1,9 @@ -import json import re import sys -import urllib.request from typing import List, Tuple +import httpx + def parse_dependencies(file_path: str) -> List[Tuple[str, str]]: dependencies = [] @@ -41,6 +41,13 @@ def extract_deps_from_string(raw_string: str) -> List[Tuple[str, str]]: return deps +def get_requires_python_data(url: str) -> str: + response = httpx.get(url) + response.raise_for_status() + data = response.json() + return data["info"].get("requires_python") or "Unknown" + + def get_python_requires(package: str, version: str) -> str: if version == "latest": url = f"https://pypi.org/pypi/{package}/json" @@ -48,16 +55,12 @@ def get_python_requires(package: str, version: str) -> str: url = f"https://pypi.org/pypi/{package}/{version}/json" try: - with urllib.request.urlopen(url) as response: # nosec B310 - data = json.loads(response.read().decode()) - return data["info"].get("requires_python") or "Unknown" + return get_requires_python_data(url) except Exception: # Fallback to latest if specific version fails try: url = f"https://pypi.org/pypi/{package}/json" - with urllib.request.urlopen(url) as response: # nosec B310 - data = json.loads(response.read().decode()) - return data["info"].get("requires_python") or "Unknown" + return get_requires_python_data(url) except Exception as e: return f"Error: {e}"