BlueOS icon indicating copy to clipboard operation
BlueOS copied to clipboard

core: Move to use UV as package manager (WIP)

Open joaomariolago opened this issue 10 months ago • 1 comments

Summary by Sourcery

Migrate core project to use UV as the package manager and restructure project dependencies

New Features:

  • Add pyproject.toml configuration for core services and libraries
  • Introduce UV package management configuration

Enhancements:

  • Consolidate project dependencies across services
  • Standardize Python version to 3.11+

Build:

  • Add core-level pyproject.toml with workspace configuration
  • Configure Python version and dependency sources

Chores:

  • Remove existing setup.py files
  • Standardize project structure with pyproject.toml
  • Update dependency management

joaomariolago avatar Apr 15 '25 20:04 joaomariolago

Reviewer's Guide

This pull request transitions the project to uv for Python package management. This was achieved by introducing pyproject.toml files for the workspace and individual packages (services/libraries), and standardizing on Python 3.11+. The Docker build process was updated to use uv for creating a virtual environment and installing dependencies from a uv.lock file. Legacy setup.py files and custom installation scripts were removed, and scripts for installing auxiliary Python tools were refactored for compatibility with the new uv-managed environment.

File-Level Changes

Change Details Files
Replaced setup.py files and custom installation scripts with uv and pyproject.toml for workspace-based package management.
  • Introduced a root pyproject.toml defining a UV workspace and a uv.lock file for deterministic builds.
  • Added pyproject.toml files for each library and service, specifying their respective dependencies and metadata.
  • Removed all legacy setup.py files and associated custom shell scripts (install-libs.sh, install-services.sh) for Python package installation.
core/pyproject.toml
core/uv.lock
core/.python-version
core/libs/commonwealth/pyproject.toml
core/libs/bridges/pyproject.toml
core/services/ardupilot_manager/pyproject.toml
core/services/versionchooser/pyproject.toml
core/services/helper/pyproject.toml
core/services/cable_guy/pyproject.toml
core/services/kraken/pyproject.toml
core/services/nmea_injector/pyproject.toml
core/services/ping/pyproject.toml
core/services/wifi/pyproject.toml
core/services/bridget/pyproject.toml
core/services/bag_of_holding/pyproject.toml
core/services/commander/pyproject.toml
core/services/beacon/pyproject.toml
core/services/pardal/pyproject.toml
core/services/log_zipper/pyproject.toml
core/libs/bridges/setup.py
core/libs/commonwealth/setup.py
core/libs/install-libs.sh
core/services/ardupilot_manager/setup.py
core/services/bag_of_holding/setup.py
core/services/beacon/setup.py
core/services/bridget/setup.py
core/services/cable_guy/setup.py
core/services/commander/setup.py
core/services/helper/setup.py
core/services/install-services.sh
core/services/kraken/setup.py
core/services/log_zipper/setup.py
core/services/nmea_injector/setup.py
core/services/pardal/setup.py
core/services/ping/setup.py
core/services/versionchooser/setup.py
core/services/wifi/setup.py
Updated the Docker build process to use uv for Python environment and dependency management.
  • Added a new multi-stage Docker build to install uv and then use it to create a virtual environment and install project dependencies via uv sync --frozen.
  • Modified the final Docker image to include the uv-managed virtual environment and updated the system PATH accordingly.
core/Dockerfile
Standardized the project to Python 3.11+.
  • Added a .python-version file specifying Python 3.11.9.
  • Defined requires-python = ">=3.11" in all pyproject.toml files.
core/.python-version
core/pyproject.toml
core/libs/**/pyproject.toml
core/services/**/pyproject.toml
Refactored installation scripts for ArduPilot Python utilities to integrate with the new uv environment.
  • Created core/tools/ardupilot_tools/setup-python-libs.sh to handle the installation of ArduPilot-specific Python scripts into the correct environment.
  • Introduced core/tools/install-python-libs.sh, executed during Docker build, to orchestrate these custom Python tool installations within the virtual environment.
  • Simplified core/tools/ardupilot_tools/bootstrap.sh to focus on firmware downloads, separating Python script setup.
core/tools/ardupilot_tools/bootstrap.sh
core/tools/ardupilot_tools/setup-python-libs.sh
core/tools/install-python-libs.sh
core/Dockerfile

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Apr 15 '25 20:04 sourcery-ai[bot]

Nice, great work!

I just noticed two library upgrades, missing license fields in the poetry module declarations, and an extra space on the shebang lines.

I've tested on a Pi5 going through all pages, checking both on the browser console and in the backend logs for any unusual behavior.

I've also run the pre-push hook locally, and it looks all good!

Thanks for the review. For information on this, as our license is not MIT, it was decided to remove the license field from each individual service and the shebang was mentioned on a previous conversation in more details. Library updates were needed for UV compatibility, I'll mention individually on each of the sub conversations.

joaomariolago avatar May 08 '25 19:05 joaomariolago