Migrate to Poetry packaging and restructure codebase #21

Merged
Sudo-Ivan merged 23 commits from codebase-improvements into master 2025-12-01 18:24:25 +00:00
Showing only changes of commit 5fc13dc61a - Show all commits

View File

2
@@ -74,16 +74,20 @@ The Electron build artifacts will still live under `dist/` for releases.
The backend uses Poetry with `pyproject.toml` for dependency management and packaging. Before building, run `python3 scripts/sync_version.py` (or `make sync-version`) to ensure the generated `src/version.py` reflects the version from `package.json` that the Electron artifacts use. This keeps the CLI release metadata, wheel packages, and other bundles aligned. The backend uses Poetry with `pyproject.toml` for dependency management and packaging. Before building, run `python3 scripts/sync_version.py` (or `make sync-version`) to ensure the generated `src/version.py` reflects the version from `package.json` that the Electron artifacts use. This keeps the CLI release metadata, wheel packages, and other bundles aligned.
### Build artifact locations
Both `poetry build` and `python -m build` generate wheels inside the default `dist/` directory. The `make wheel` shortcut wraps `poetry build -f wheel` and then runs `python scripts/move_wheels.py` to relocate the generated `.whl` files into `python-dist/` (the layout expected by `scripts/test_wheel.sh` and the release automation). Use `make wheel` if you need the artifacts in `python-dist/`; `poetry build` or `python -m build` alone will leave them in `dist/`.
coderabbitai[bot] commented 2025-12-01 17:53:28 +00:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion | 🟠 Major

Inconsistent Python invocation: use python3 consistently.

Line 46 uses python while line 75 uses python3 for the same sync_version.py script. Since Python 3 is standard and line 75 explicitly specifies python3, line 46 should do the same for consistency.

Apply this diff:

 The Python build is driven entirely by Poetry now. Run `python scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that:

-python -m poetry install
+python3 scripts/sync_version.py
-make wheel  # produces a wheel in python-dist/ that bundles the public assets
+make wheel

Or more simply, update line 46:

-Run `python scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that:
+Run `python3 scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

### Python packaging

The Python build is driven entirely by Poetry now. Run `python3 scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that:

🤖 Prompt for AI Agents
In README.md around lines 44 to 51, the invocation for the sync_version script
uses `python` while elsewhere (line 75) `python3` is used; update the command on
line 46 to use `python3` (i.e., replace `python scripts/sync_version.py` with
`python3 scripts/sync_version.py`) so the README consistently references Python
3 for running the script.

Addressed in commits 284517b to 3848613

_🛠️ Refactor suggestion_ | _🟠 Major_ **Inconsistent Python invocation: use `python3` consistently.** Line 46 uses `python` while line 75 uses `python3` for the same `sync_version.py` script. Since Python 3 is standard and line 75 explicitly specifies `python3`, line 46 should do the same for consistency. Apply this diff: ```diff The Python build is driven entirely by Poetry now. Run `python scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that: -python -m poetry install +python3 scripts/sync_version.py -make wheel # produces a wheel in python-dist/ that bundles the public assets +make wheel ``` Or more simply, update line 46: ```diff -Run `python scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that: +Run `python3 scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that: ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion ### Python packaging The Python build is driven entirely by Poetry now. Run `python3 scripts/sync_version.py` or `make sync-version` before packaging so `pyproject.toml` and `src/version.py` match `package.json`. After that: ``` </details> <!-- suggestion_end --> <details> <summary>🤖 Prompt for AI Agents</summary> ``` In README.md around lines 44 to 51, the invocation for the sync_version script uses `python` while elsewhere (line 75) `python3` is used; update the command on line 46 to use `python3` (i.e., replace `python scripts/sync_version.py` with `python3 scripts/sync_version.py`) so the README consistently references Python 3 for running the script. ``` </details> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 284517b to 3848613
### Building with Poetry ### Building with Poetry
```bash ```bash
# Install dependencies # Install dependencies
poetry install poetry install
# Build the package # Build the package (wheels land in dist/)
poetry build poetry build
# Install locally for testing # Install locally for testing (consumes dist/)
pip install dist/*.whl pip install dist/*.whl
``` ```