Skip to content

install uv and use for jtop installation and update related docs#748

Merged
johnnynunez merged 2 commits into
rbonghi:masterfrom
whitesscott:uv-install-jtop-without-sudo
Nov 5, 2025
Merged

install uv and use for jtop installation and update related docs#748
johnnynunez merged 2 commits into
rbonghi:masterfrom
whitesscott:uv-install-jtop-without-sudo

Conversation

@whitesscott
Copy link
Copy Markdown
Contributor

@whitesscott whitesscott commented Nov 4, 2025

Modified scripts/install_jtop_torun_without_sudo.sh to install and use 'uv' as the Python package manager instead of pipx.

Updated README.md to reference scripts/install_jtop_torun_without_sudo.sh since the script was moved to the scripts directory.

Edited docs/nosudo.rst to note that the script now installs uv if needed and uses it to install jetson_stats.

Summary by Sourcery

Refactor the no-sudo installation script to use uv for Python package management, auto-install uv if needed, and streamline virtual environment setup, symlink creation, and systemd service configuration, and update related documentation.

Enhancements:

  • Replace pipx with uv in install_jtop_torun_without_sudo.sh, including auto-install of uv when missing
  • Simplify virtual environment creation and jetson_stats installation via uv, create user/root symlinks, and configure systemd service

Documentation:

  • Update README.md to reference the relocated scripts/install_jtop_torun_without_sudo.sh path
  • Revise docs/nosudo.rst to note that the script now installs and uses uv for jetson_stats installation

Modified scripts/install_jtop_torun_without_sudo.sh to install and use 'uv'
as the Python package manager instead of pipx.

Updated README.md to reference scripts/install_jtop_torun_without_sudo.sh
since the script was moved to the scripts directory.

Edited docs/nosudo.rst to note that the script now installs uv if needed
and uses it to install jetson_stats.
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Nov 4, 2025

Reviewer's Guide

Refactored the no-sudo installation workflow by consolidating to the fast ‘uv’ package manager (auto-installing uv, creating a uv-managed venv, installing jetson_stats, and setting up symlinks and a systemd service) and updated documentation to point at the new script location and describe uv usage.

Sequence diagram for the new jtop installation workflow using uv

sequenceDiagram
    actor User
    participant Script as "install_jtop_torun_without_sudo.sh"
    participant System as "System (apt, curl, etc.)"
    participant uv as "uv (Python package manager)"
    participant Venv as "Python venv"
    participant Service as "systemd service"
    User->>Script: Run installation script
    Script->>System: Install prerequisites (curl, ca-certificates, python3-pip)
    Script->>System: Check/install uv
    System->>Script: uv installed
    Script->>uv: Create Python venv
    uv->>Venv: venv created
    Script->>uv: Install jetson_stats in venv
    uv->>Venv: jetson_stats installed
    Script->>System: Create symlink to jtop binary
    Script->>Service: Create/overwrite systemd unit
    Script->>Service: Enable and start jtop service
    Service->>Script: Service running
    Script->>User: Installation complete
Loading

Class diagram for the updated installation script structure

classDiagram
    class InstallScript {
      +APP_NAME: string
      +PKG_NAME: string
      +VENV_DIR: string
      +JTOP_BIN: string
      +SYMLINK_PATH: string
      +SYSTEMD_UNIT: string
      +JTOP_REF: string
      +cleanup()
      +main()
    }
    class uv {
      +venv(path, python_version, seed)
      +pip_install(python_path, package_ref)
    }
    class System {
      +apt_update()
      +apt_install(packages)
      +ln_symlink(target, linkpath)
      +systemctl_reload()
      +systemctl_enable(service)
      +systemctl_restart(service)
      +systemctl_status(service)
    }
    InstallScript --> uv : uses
    InstallScript --> System : uses
Loading

File-Level Changes

Change Details Files
Rewrite install_jtop_torun_without_sudo.sh to use uv instead of pipx
  • Remove pipx mode and related dependency checks
  • Auto-install uv if missing and prepend ~/.local/bin to PATH
  • Create a Python venv with uv and install jetson_stats from a configurable git ref
  • Introduce configuration variables and an ERR trap for cleanup
  • Generate/update a systemd unit and symlink the jtop binary for both user and root
scripts/install_jtop_torun_without_sudo.sh
Update README to reference moved install script
  • Change download path to scripts/install_jtop_torun_without_sudo.sh
  • Adjust chmod and invocation instructions accordingly
README.md
Document uv requirement and usage in nosudo guide
  • Note that the install script now auto-installs uv if needed
  • Explain that uv is used to install jetson_stats in the venv
docs/nosudo.rst

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

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Avoid hard‐coding python3.12 in uv venv creation—either detect the system’s default python3 or allow the user to override the interpreter for broader compatibility.
  • Before creating the venv and installing from a git URL, ensure prerequisites like python3-venv and git are installed so uv pip install won’t fail on missing system packages.
  • Unify systemd unit handling by consistently using the $SYSTEMD_UNIT variable (instead of mixing $SYSTEMD_UNIT and ${APP_NAME}.service) when enabling and restarting the service.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Avoid hard‐coding python3.12 in uv venv creation—either detect the system’s default python3 or allow the user to override the interpreter for broader compatibility.
- Before creating the venv and installing from a git URL, ensure prerequisites like python3-venv and git are installed so uv pip install won’t fail on missing system packages.
- Unify systemd unit handling by consistently using the $SYSTEMD_UNIT variable (instead of mixing $SYSTEMD_UNIT and ${APP_NAME}.service) when enabling and restarting the service.

## Individual Comments

### Comment 1
<location> `scripts/install_jtop_torun_without_sudo.sh:56` </location>
<code_context>
-    exit 1
-  fi
+# This makes 'jtop' (user) and 'sudo jtop' (root) work correctly
+sudo ln -sf "$JTOP_BIN" "$SYMLINK_PATH"
+echo "Symlink created: $SYMLINK_PATH"
+
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Overwriting the system-wide symlink without backup or warning may cause issues.

Check if /usr/local/bin/jtop already exists before overwriting, and either back it up or notify the user to prevent disrupting existing setups.
</issue_to_address>

### Comment 2
<location> `scripts/install_jtop_torun_without_sudo.sh:63-67` </location>
<code_context>
-  echo "Creating ${UNIT_FILE}…"
-  sudo tee "${UNIT_FILE}" >/dev/null <<EOF
+echo "Creating systemd service: $SYSTEMD_UNIT"
+sudo tee "$SYSTEMD_UNIT" >/dev/null <<EOF
 [Unit]
-Description=Jetson Stats (jtop)
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Overwriting the systemd unit file without preserving customizations may cause loss of user changes.

Recommend backing up the existing unit file or notifying the user before overwriting to avoid unintended loss of custom configurations.

```suggestion
if [ -f "$SYSTEMD_UNIT" ]; then
    BACKUP_UNIT="${SYSTEMD_UNIT}.bak"
    echo "Existing systemd unit file detected: $SYSTEMD_UNIT"
    echo "Backing up current unit file to: $BACKUP_UNIT"
    sudo cp "$SYSTEMD_UNIT" "$BACKUP_UNIT"
fi

echo "Creating systemd service: $SYSTEMD_UNIT"
sudo tee "$SYSTEMD_UNIT" >/dev/null <<EOF
[Unit]
Description=Jetson Stats (jtop service)
After=network.target
```
</issue_to_address>

### Comment 3
<location> `docs/nosudo.rst:21-22` </location>
<code_context>
+3. **Install uv. Then install jtop with uv**
+
+   - Uses uv pip install --python ""$HOME/.local/share/jtop/bin/python" --upgrade "git+https://github.com/rbonghi/jetson_stats.git"
+   - to install the latest jtop version in the users environment.

-   - Uses ``pipx install "git+https://github.com/rbonghi/jetson_stats.git"`` to install the latest version in an isolated user environment.
</code_context>

<issue_to_address>
**issue (typo):** Missing apostrophe in "users environment"; should be "user's environment".

Please update to "user's environment" for correct grammar.

```suggestion
   - Uses uv pip install --python ""$HOME/.local/share/jtop/bin/python" --upgrade "git+https://github.com/rbonghi/jetson_stats.git"
   - to install the latest jtop version in the user's environment.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread scripts/install_jtop_torun_without_sudo.sh
Comment thread docs/nosudo.rst Outdated
spell check

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@johnnynunez johnnynunez merged commit 7230469 into rbonghi:master Nov 5, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants