|
1 | | ---8<-- "README.md" |
| 1 | +# Frequenz Python SDK |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +The Frequenz Python SDK is a development kit for interacting with the Frequenz development platform. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +First, you need to make sure you have Python installed (at least version 3.11): |
| 10 | + |
| 11 | +```console |
| 12 | +$ python3 --version |
| 13 | +Python 3.11.4 |
| 14 | +``` |
| 15 | + |
| 16 | +!!! note |
| 17 | + |
| 18 | + These instructions assume you are using a [POSIX compatible |
| 19 | + `sh`](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html) |
| 20 | + shell. |
| 21 | + |
| 22 | +If that command doesn't print a version newer than 3.11.0, you'll need to |
| 23 | +[download and install Python](https://www.python.org/downloads/) first. |
| 24 | + |
| 25 | +To install the SDK, you probably want to create a new virtual environment first: |
| 26 | + |
| 27 | +```sh |
| 28 | +mkdir my-sdk-project |
| 29 | +cd my-sdk-project |
| 30 | +python3 -m venv .venv |
| 31 | +. .venv/bin/activate |
| 32 | +``` |
| 33 | + |
| 34 | +!!! tip |
| 35 | + |
| 36 | + Using [`direnv`](https://direnv.net/) can greatly simplify this process as |
| 37 | + it automates the creation, activation, and deactivation of the virtual |
| 38 | + environment. The first time you enable `direnv`, the virtual environment |
| 39 | + will be created, and each time you enter or leave a subdirectory, it will be |
| 40 | + activated and deactivated, respectively. |
| 41 | + |
| 42 | + ```sh |
| 43 | + sudo apt install direnv # if you use Debian/Ubuntu |
| 44 | + mkdir my-sdk-project |
| 45 | + cd my-sdk-project |
| 46 | + echo "layout python python3" > .envrc |
| 47 | + direnv allow |
| 48 | + ``` |
| 49 | + |
| 50 | + This will create the virtual environment and activate it automatically for you. |
| 51 | + |
| 52 | +Now you can install the SDK by using `pip`: |
| 53 | + |
| 54 | +```sh |
| 55 | +python3 -m pip install frequenz-sdk |
| 56 | +``` |
| 57 | + |
| 58 | +To verify that the installation worked, you can invoke the Python interpreter and |
| 59 | +import the SDK: |
| 60 | + |
| 61 | +```console |
| 62 | +$ python3 |
| 63 | +Python 3.11.4 (main, Jun 7 2023, 10:13:09) [GCC 12.2.0] on linux |
| 64 | +Type "help", "copyright", "credits" or "license" for more information. |
| 65 | +>>> import frequenz.sdk |
| 66 | +>>> |
| 67 | +``` |
0 commit comments