Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ nghdl*
tags
build/
dist/
logs/*.log
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,35 @@ A huge thank you to all **149+ amazing people** who have contributed to eSim!
<p align="center"><em>149+ contributors and counting! <a href="https://github.com/fossee/esim/graphs/contributors">View all contributors →</a></em></p>

---
## 🛠️ Automated Tool Manager

The eSim repository includes an Automated Tool Manager for managing external EDA tools required by eSim on Ubuntu Linux systems.

The Tool Manager supports:

- **Ngspice** — Circuit Simulation
- **Verilator** — Digital Verification
- **GHDL** — VHDL Simulation
- **KiCad** — PCB Design

### Features

- Detect installed tools
- Install missing tools using APT
- Check dependencies
- Detect installed and available package versions
- Check for updates
- Upgrade installed tools
- Manage Tool Manager configuration
- Record tool-management operations
- Run automated unit tests

### Running the Tool Manager

From the eSim repository root:

```bash
python3 -m tools.esim_tool_manager

## 📞 Contact & Support

Expand Down
15 changes: 15 additions & 0 deletions config/esim_manager.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[system]
package_manager = apt

[esim]
installation_path = /opt/esim

[updates]
auto_check = true

[tools]
ngspice = ngspice
verilator = verilator
ghdl = ghdl
kicad = kicad

232 changes: 232 additions & 0 deletions docs/Task_5_Tool_Manager_Design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# Automated Tool Manager for eSim

## 1. Overview

The Automated Tool Manager is a Python-based command-line utility developed as part of the eSim Semester Long Internship Task 5.

The purpose of the Tool Manager is to simplify the management of external tools required by eSim.

The manager provides a centralized interface for detecting, installing, checking, updating, upgrading, and monitoring the required EDA tools.

Supported tools:

- Ngspice
- Verilator
- GHDL
- KiCad

The implementation is designed for Ubuntu Linux systems using APT.

## 2. Objectives

The main objectives are:

1. Detect installed eSim dependencies.
2. Identify missing dependencies.
3. Install supported tools using APT.
4. Detect installed package versions.
5. Check whether newer package versions are available.
6. Upgrade supported packages.
7. Maintain configuration settings.
8. Record tool-management activities.
9. Provide a simple command-line interface.
10. Provide automated tests for core functionality.

## 3. Architecture

The Tool Manager consists of independent Python modules:

cli.py
|
+-- detector.py
+-- installer.py
+-- dependency_checker.py
+-- version_checker.py
+-- update_checker.py
+-- upgrade_manager.py
+-- config.py
+-- logger.py
|
+-- APT / dpkg
|
+-- Ngspice
+-- Verilator
+-- GHDL
+-- KiCad

## 4. Modules

### detector.py

Detects whether supported tools are installed and retrieves their versions.

Supported tools:

- Ngspice
- Verilator
- GHDL
- KiCad

KiCad uses dpkg-query for version detection because it does not support the standard --version option.

### installer.py

Installs supported tools using APT.

Supported packages:

- ngspice
- verilator
- ghdl
- kicad

The installer verifies the installation after completion.

### dependency_checker.py

Checks whether all required eSim tools are installed.

The checker reports:

- Installed tools
- Missing tools
- Overall system status

### version_checker.py

Retrieves installed package versions and APT candidate versions.

### update_checker.py

Compares installed Debian package versions with the APT candidate versions using:

dpkg --compare-versions

Possible states include:

- Up to date
- Update available
- Not installed
- Unable to check

### upgrade_manager.py

Upgrades individual packages using APT and verifies the installed package version afterward.

### config.py

Manages configuration using Python's configparser.

Configuration file:

config/esim_manager.ini

### logger.py

Records Tool Manager operations in:

logs/tool_manager.log

Generated logs are excluded from Git.

### cli.py

Provides the interactive menu:

1. Scan Tools
2. Install Tool
3. Dependency Check
4. System Information
5. Check Updates
6. Upgrade Tool
7. Configuration
8. View Logs
9. Exit

### __main__.py

Provides the package entry point:

python3 -m tools.esim_tool_manager

## 5. Configuration

The default configuration is:

[system]
package_manager = apt

[esim]
installation_path = /opt/esim

[updates]
auto_check = true

[tools]
ngspice = ngspice
verilator = verilator
ghdl = ghdl
kicad = kicad

## 6. Testing

Tests are located in:

tests/esim_tool_manager/

The project uses Python's built-in unittest framework.

Run:

python3 -m unittest discover -s tests -v

Current tests cover:

- Installed tool detection
- Missing tool detection
- Supported tool validation
- Update comparison
- Up-to-date comparison
- Missing version handling

Current validation result:

Ran 6 tests
OK

## 7. System Requirements

The current implementation targets:

- Ubuntu Linux
- Python 3.x
- APT package manager
- dpkg

Supported tools:

- Ngspice
- Verilator
- GHDL
- KiCad

## 8. Security Considerations

Installation and upgrade operations use sudo because system package management requires administrative privileges.

The Tool Manager does not store passwords or authentication credentials.

Generated runtime logs are excluded from version control.

## 9. Future Improvements

Possible future improvements include:

- Graphical user interface
- Windows and macOS support
- Automatic rollback
- Remote package repository support
- Scheduled updates
- More comprehensive test coverage
- Additional eSim dependency support
- Integration with the existing eSim installation workflow
Empty file.
58 changes: 58 additions & 0 deletions tests/esim_tool_manager/test_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import unittest
from unittest.mock import patch

from tools.esim_tool_manager.detector import ToolDetector


class TestToolDetector(unittest.TestCase):

def test_detect_installed_tool(self):
detector = ToolDetector()

with patch(
"shutil.which",
return_value="/usr/bin/ngspice",
):
with patch.object(
detector,
"_get_version",
return_value="ngspice version 45.2",
):
result = detector.detect_tool(
"ngspice",
"ngspice",
)

self.assertTrue(result.installed)
self.assertEqual(result.name, "ngspice")
self.assertEqual(
result.version,
"ngspice version 45.2",
)

def test_detect_missing_tool(self):
detector = ToolDetector()

with patch(
"shutil.which",
return_value=None,
):
result = detector.detect_tool(
"ngspice",
"ngspice",
)

self.assertFalse(result.installed)
self.assertIsNone(result.version)

def test_supported_tools(self):
detector = ToolDetector()

self.assertIn("ngspice", detector.TOOLS)
self.assertIn("verilator", detector.TOOLS)
self.assertIn("ghdl", detector.TOOLS)
self.assertIn("kicad", detector.TOOLS)


if __name__ == "__main__":
unittest.main()
Loading