Set up local environment - electricitymaps/electricitymaps-contrib GitHub Wiki

Setup Python development environment

  1. Ensure you are using Python 3.10 (We recommend using pyenv to handle different Python versions.)

  2. Ensure you have the dependency management tool uv installed by this guide.

  3. Ensure you have the dependency tool tesseract installed, following the instructions in this guide.

  4. From the root folder, install the dependencies in a virtual environment:

    uv sync -extra parsers
    

You can now run a few different commands:

uv run lint # linting
uv run test # run unit tests
uv run check # run both linting and tests

You might need to have zlib and libjpeg installed on your machine.

To ensure all dependencies required by opencv are installed, you can run apt-get update && apt-get install -y python3-opencv

Having problems?

First up, make sure you're using Python 3.10. Also, see Troubleshooting for fixes to common issues.

If it's still not working, please create an issue where you describe all steps you took as well as the version of uv you are using, how you installed it, python version and what steps are failing.

Code formatting

Your code contributions can't be merged with the codebase unless they respect the Electricity Maps contrib code formatting.

To check whether you code respects the formatting, you can run the following commands:

Python

uv run check

If you see that your code fails the formatting check, you can autoformat it by running:

uv run format

YAML, JSON and more:

npx prettier --check .

And if the check fails you can run the following command to fix it:

npx prettier --write .