Skip to content

Commit ca56145

Browse files
Merge pull request davidusb-geek#541 from polyfloyd/develop-uv
Update development documentation to use uv
2 parents 778218b + 548dfd3 commit ca56145

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

docs/develop.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Here you may also wish to add the add the original/upstream repository as a remo
2121
A command example may be:
2222
```bash
2323
# on GitHub, Fork url, then:
24-
git clone https://github.com/<YOURUSERNAME>/emhass.git
24+
git clone git@github.com:<YOURUSERNAME>/emhass.git
2525
cd emhass
2626
# add remote, call it upstream
27-
git remote add upstream https://github.com/OWNER/REPOSITORY.git
27+
git remote add upstream https://github.com/davidusb-geek/emhass.git
2828
```
2929

3030
## Step 2 - Develop
@@ -37,39 +37,39 @@ We can use python virtual environments to build, develop and test/unittest the c
3737

3838
_confirm terminal is in the root `emhass` directory before starting_
3939

40-
**Install requirements**
41-
```bash
42-
python3 -m pip install -r requirements.txt #if on ARM, try setting --extra-index-url=https://www.piwheels.org/simple
43-
```
44-
4540
**Create a developer environment:**
4641

42+
Using the [`uv` package manager](https://docs.astral.sh/uv/):
4743
```bash
48-
python3 -m venv .venv
44+
# With the 'test' packages to run unit tests locally.
45+
uv sync --extra test
46+
# If on ARM, try adding piwheels as an index.
47+
#uv sync --extra test --index=https://www.piwheels.org/simple
4948
```
5049

51-
**Activate the environment:**
50+
Using virtualenv and pip:
51+
```bash
52+
virtualenv .venv
5253

53-
- linux:
54+
# Then activate the virtualenv, see below...
5455

56+
# With the 'test' packages to run unit tests locally.
57+
python3 -m pip install -e '.[test]'
58+
```
59+
60+
To activate the virtualenv, created by either uv or pip:
61+
- Linux:
5562
```bash
5663
source .venv/bin/activate
5764
```
58-
5965
- windows:
60-
6166
```cmd
6267
.venv\Scripts\activate.bat
6368
```
6469

70+
This installs dependencies and creates a `.venv` virtualenv in the working directory.
6571
An IDE like VSCode should automatically catch that a new virtual env was created.
6672

67-
**Install the _emhass_ package in editable mode:**
68-
69-
```bash
70-
python3 -m pip install -e .
71-
```
72-
7373
**Set paths with environment variables:**
7474

7575
- Linux
@@ -79,6 +79,8 @@ python3 -m pip install -e .
7979
export SECRETS_PATH="${PWD}/secrets_emhass.yaml" ##optional to test secrets_emhass.yaml
8080
export DATA_PATH="${PWD}/data/"
8181
```
82+
Optionally, use [direnv](https://direnv.net/) to have these variables handled for you.
83+
8284
- windows
8385
```batch
8486
set "OPTIONS_PATH=%cd%/options.json" & :: optional to test options.json
@@ -91,20 +93,17 @@ python3 -m pip install -e .
9193
_Make sure `secrets_emhass.yaml` has been created and set. Copy `secrets_emhass(example).yaml` for an example._
9294

9395
**Run EMHASS**
94-
9596
```bash
96-
python3 src/emhass/web_server.py
97+
python3 ./src/emhass/web_server.py
9798
```
98-
or
99+
or
99100
``` bash
100101
emhass --action 'dayahead-optim' --config ./config.json --root ./src/emhass --costfun 'profit' --data ./data
101102
```
102103

103104
**Run unittests**
104-
105105
```bash
106-
python3 -m pip install -e '.[test]'
107-
python3 -m unittest discover -s ./tests -p 'test_*.py'
106+
pytest
108107
```
109108

110109
### Method 2: VS-Code Debug and Run via Dev Container

0 commit comments

Comments
 (0)