install uv and use for jtop installation and update related docs#748
Merged
johnnynunez merged 2 commits intoNov 5, 2025
Merged
Conversation
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.
Contributor
Reviewer's GuideRefactored 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 uvsequenceDiagram
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
Class diagram for the updated installation script structureclassDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
spell check Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Documentation: