Metadata-Version: 2.4
Name: package-creation-mahdiznaidi
Version: 0.1.0
Summary: TP4 - Package Python complet avec tests, lint, docs et CI.
Author: Mehdi
Author-email: mehdi@example.com
Requires-Python: >=3.11,<3.13
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown

# TP4 - Package Python (Poetry, Tests, Docs, CI)

Projet réalisé en suivant le tutoriel **"Build Python Package"**.

## Objectif

Construire un package Python complet avec :

- structure `src/`
- tests unitaires (`pytest`, `pytest-cov`)
- lint/format (`ruff`) + hooks `pre-commit`
- documentation Sphinx
- workflows GitHub Actions (tests + déploiement docs)
- préparation à la publication PyPI

## Arborescence

```text
.
├── .github/workflows/
│   ├── sphinx_doc.yaml
│   └── tests.yaml
├── docs/
│   ├── _static/
│   ├── _templates/
│   ├── Makefile
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   └── modules.rst
├── src/package_creation_tutorial/
│   ├── __init__.py
│   ├── main.py
│   └── string_ops.py
├── tests/
│   └── test_string_ops.py
├── .gitignore
├── .pre-commit-config.yaml
├── main.py
├── pyproject.toml
└── README.md
```

## Prérequis

- Python 3.11+ (3.12 recommandé)
- Poetry
- Git

Installation de Poetry (exemple avec `pipx`) :

```bash
pipx install poetry
```

## 1) Build local du package

```bash
poetry install --with dev
poetry build
poetry run python main.py
```

Le script affiche :

- la chaîne originale
- sa version inversée
- le nombre de voyelles
- la chaîne avec capitalisation par mot

## 2) Tests et couverture

```bash
poetry run pytest
poetry run pytest --cov src/
```

## 3) Git / GitHub (rappel)

```bash
git init
git add .
git commit -m "initial project setup"
git remote add origin <URL_DU_REPO>
git push -u origin main
```

## 4) Ruff + pre-commit

```bash
poetry run ruff check --fix .
poetry run pre-commit install
poetry run pre-commit run --all-files
```

Configuration : `.pre-commit-config.yaml` avec hook `ruff`.

## 5) Documentation Sphinx

Build local :

```bash
cd docs
make html
```

Sous Windows :

```powershell
cd docs
.\make.bat html
```

Fichier généré :

- `docs/build/html/index.html`

## 6) GitHub Actions

Deux workflows sont fournis :

- `.github/workflows/tests.yaml` : exécute les tests à chaque push/PR
- `.github/workflows/sphinx_doc.yaml` : build docs + publication `gh-pages`

### Configuration GitHub à faire

1. Dans le dépôt GitHub : `Settings > Actions > General`
2. Activer `Read and write permissions` pour `GITHUB_TOKEN`
3. Dans `Settings > Pages`, choisir la branche `gh-pages`

## 7) Publication sur PyPI

Configurer le token :

```bash
poetry config pypi-token.pypi <VOTRE_TOKEN>
```

Publier :

```bash
poetry build
poetry publish
```

## Commandes utiles

```bash
poetry run python -m package_creation_tutorial.main
poetry run pytest -q
poetry run ruff check .
```

## Auteur

Mehdi (TP4 DataViz)

