Skip to content

Commit 0871a83

Browse files
Update README.md
1 parent 9f88ae8 commit 0871a83

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

README.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,56 @@ Install system dependencies:
2626
sudo apt update
2727
sudo apt install -y libusb-1.0-0-dev libftdi1-dev pkg-config
2828
````
29-
### Clone the repository
29+
---
3030

31-
### Install the package
31+
### Option 1: Install from PyPI (recommended)
3232

33-
#### Option 1: System-wide (not recommended unless you know what you're doing)
34-
```sh
35-
sudo pip install .
33+
Create and activate a virtual environment:
34+
```bash
35+
python3 -m venv ~/.venv/pyectool
36+
source ~/.venv/pyectool/bin/activate
3637
```
37-
Or:
38+
Install from PyPI:
39+
```bash
40+
pip install pyectool
41+
```
42+
43+
Test installation (requires `sudo` to access the EC):
3844

3945
```bash
40-
sudo env "PIP_BREAK_SYSTEM_PACKAGES=1" pip install .
46+
sudo env "PATH=$PATH" python -c "from pyectool import ECController; ec = ECController(); print(ec.is_on_ac())"
4147
```
42-
(Required on modern distros like Ubuntu 24.04 due to PEP 668.)
48+
This will print `True` if the system is on AC power, or `False` if on battery.
49+
50+
---
51+
52+
### Option 2: Install from source
4353

44-
#### Option 2: Isolated virtual environment (recommended)
54+
Clone the repository:
55+
```bash
56+
git clone https://github.com/CCExtractor/libectool
57+
cd libectool
58+
```
59+
Create and activate a virtual environment:
4560
```bash
4661
python3 -m venv ~/.venv/pyectool
4762
source ~/.venv/pyectool/bin/activate
48-
pip install .
4963
```
50-
64+
Install the package:
65+
```bash
66+
sudo pip install .
67+
```
5168
### ⚠️ Important Note
5269

5370
After installation, **do not run Python from inside the `libectool/` directory**. It contains a `pyectool/` folder that may shadow the installed package.
5471

5572
Instead, test from a different directory:
5673

57-
```bash
58-
cd ..
59-
sudo python -c "from pyectool import ECController; ec = ECController(); print(ec.is_on_ac())"
60-
```
61-
62-
If you're using a virtual environment and want to preserve its `PATH`, use:
6374
```bash
6475
cd ..
6576
sudo env "PATH=$PATH" python -c "from pyectool import ECController; ec = ECController(); print(ec.is_on_ac())"
6677
```
67-
This ensures the correct Python from your virtual environment is used even with `sudo`.
68-
69-
---
78+
'env "PATH=$PATH"' preserve venv path and ensures the correct Python from your virtual environment is used even with `sudo`.
7079

7180
## Usage
7281

0 commit comments

Comments
 (0)