# IPM native integration (app.ipm) This folder contains the Python wrapper that calls the native refifc libraries. Quick summary - Wrapper import path: `app.ipm.simple_refrig_api`. - Windows DLLs: place under `app/ipm/lib/windows/`. - Linux shared objects (.so): place under `app/ipm/lib/linux/`. The wrapper prefers `app/ipm/lib/` at runtime and falls back to the package directory. Important: native binaries are large and often licensed. Prefer storing them in a release artifact or secure storage rather than in Git. -------------------------------- Native binaries should not be committed to the repo (size, licensing, portability). The repo contains a `.gitignore` rule excluding `app/ipm/lib/windows/*.dll`. CI/CD - Store binaries in a secure artifact repository (releases, internal storage, S3, etc.). - During CI, download them and copy into `app/ipm/lib/` before building the image or deploying. Quick local test 1. Copy the binaries into the correct folder (e.g. `app/ipm/lib/windows/refifc.dll`). 2. Test locally: ```powershell .venv\Scripts\python -c "import app.ipm.simple_refrig_api as s; r=s.Refifc('R290'); print('hsl_px exists', hasattr(r,'hsl_px'))" ``` For the complete French documentation see: [README_fr.md](README_fr.md) ````markdown # IPM native integration (app.ipm) This folder contains the Python wrapper that calls the native refifc libraries. Goals - Centralize the Python wrapper under `app/ipm` so application code can import `app.ipm.simple_refrig_api`. - Provide a clear location for native binaries (DLLs for Windows, .so for Linux). Where to place native binaries - Windows (local/dev): place DLL files in `app/ipm/lib/windows/`. - Linux (container/production): place .so files in `app/ipm/lib/linux/`. The wrapper `app/ipm/simple_refrig_api.py` will look first in `app/ipm/lib/` (`windows` or `linux`) and fall back to the package directory if nothing is found. Do NOT commit native binaries -------------------------------- Native binaries should not be committed to the repo (size, licensing, portability). The repo contains a `.gitignore` rule excluding `app/ipm/lib/windows/*.dll` and `app/ipm/lib/linux/*.so`. CI/CD - Store binaries in a secure artifact repository (releases, internal storage, S3, etc.). - During CI, download them and copy into `app/ipm/lib/` before building the image or deploying. Quick local test 1. Copy the binaries into the correct folder (e.g. `app/ipm/lib/windows/refifc.dll`). 2. Test locally: ```powershell .venv\Scripts\python -c "import app.ipm.simple_refrig_api as s; r=s.Refifc('R290'); print('hsl_px exists', hasattr(r,'hsl_px'))" ``` Best practices - Avoid committing binaries in Git. - Record the exact origin and version of native binaries in release notes. - Provide small helper scripts (`scripts/copy-ipm-libs.*`) to automate copying binaries into build environments. For French documentation see: [README_fr.md](README_fr.md) ```` # IPM native integration (app.ipm) — English (default) This is the default README for the `app/ipm` package. It is the English version. For the French version, see: [README_fr.md](README_fr.md) Short summary - The `app/ipm` package contains the Python wrapper for the native `refifc` libraries. - Place Windows DLLs in `app/ipm/lib/windows/` and Linux `.so` files in `app/ipm/lib/linux/`. See `README_en.md` for the full English documentation and `README_fr.md` for the French translation. # IPM native integration (app.ipm) Ce dossier contient l'enveloppe Python qui appelle les bibliothèques natives (refifc). But - centraliser le wrapper Python dans `app/ipm` pour que le code applicatif importe depuis `app.ipm.simple_refrig_api`. - fournir un emplacement clair pour les binaires natifs (DLL pour Windows, .so pour Linux). Où placer les binaires --------------------- - Windows (local/dev): placez vos DLL dans `app/ipm/lib/windows/`. - Linux (container/production): placez vos .so dans `app/ipm/lib/linux/`. Le wrapper `app/ipm/simple_refrig_api.py` recherche automatiquement, en priorité, le répertoire `app/ipm/lib/` (`windows` ou `linux`) puis retombe sur le répertoire du package si rien n'est trouvé. Ne pas committer les binaires ---------------------------- Les fichiers natifs ne doivent pas être committés dans Git (poids, licence, portabilité). Le dépôt contient une règle `.gitignore` qui exclut `app/ipm/lib/windows/*.dll` et `app/ipm/lib/linux/*.so`. Déploiement / Docker --------------------- Le Dockerfile doit copier les binaires appropriés dans le répertoire `app/ipm/lib/` au moment du build. Exemple (Linux image): ```Dockerfile FROM python:3.12-slim WORKDIR /app COPY . /app # Copier les libs natives Linux dans le bon dossier COPY path/to/linlibs/*.so /app/app/ipm/lib/linux/ RUN pip install --no-cache-dir -r requirements.txt CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] ``` Pour Windows-based artifacts (si vous buildissez une image Windows ou déployez sur Windows), copiez les DLL dans `app/ipm/lib/windows/`. CI/CD ----- - Stockez les binaires dans un artefact sécurisé (release, storage interne, S3, etc.). - Lors du pipeline, téléchargez-les et copiez-les dans `app/ipm/lib/` avant l'étape d'image ou de déploiement. Test rapide local ----------------- 1. Copier les binaires dans le bon dossier (ex: `app/ipm/lib/windows/refifc.dll`). 2. Lancer un shell Python depuis la racine du projet et tester : ```powershell .venv\Scripts\python -c "import app.ipm.simple_refrig_api as s; r=s.Refifc('R290'); print('hsl_px exists', hasattr(r,'hsl_px'))" ``` Bonnes pratiques ---------------- - Ne stockez pas les binaires dans Git. - Documentez dans votre release notes la provenance et la version exacte des fichiers natifs. - Préparez un script `scripts/fetch-ipm-libs.sh` (ou équivalent PowerShell) pour automatiser la récupération des binaires dans vos environnements de build. Si tu veux, j'ajoute un petit `scripts/` helper pour télécharger/copy automatiquement les binaires depuis un dossier central ou un storage.