diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..88ebebe7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort (python) +- repo: https://github.com/asottile/pyupgrade + rev: v3.9.0 + hooks: + - id: pyupgrade diff --git a/README.rst b/README.rst index 098db741..47d6b8f3 100644 --- a/README.rst +++ b/README.rst @@ -28,12 +28,12 @@ energy storages. Grid expansion measures are not part of this tool and will be instead part of 'eGo' https://github.com/openego/eGo .. warning:: - From now on eTraGo depends on a sector coupled data-model. This is not published on + From now on eTraGo depends on a sector coupled data-model. This is not published on the oedb yet, the data has to be created using `eGon-data `_. Not all functions and features are compatible to the sector coupled model yet. - - When you want to use eTraGo for optimizations, please use the latest release 0.8.0. + + When you want to use eTraGo for optimizations, please use the latest release 0.8.0. Installation @@ -46,7 +46,7 @@ command in order to install eTraGo.. .. code-block:: bash - $ pip3 install eTraGo + $ python -m pip install eTraGo Installation for Developers =========================== @@ -58,32 +58,52 @@ Clone the source code from github: $ git clone https://github.com/openego/eTraGo You can checkout to the dev branch and create new feature branches. -For the correct work-flow, please mind the +For the correct work-flow, please mind the `Dreissen Branching Model `_ -Use the pip -e to install eTraGo directly from the cloned repository: +Use the pip -e to install eTraGo directly from the cloned repository preferably into a +virtual environment: + +.. code-block:: + + $ python -m pip install -e /path/to/eTraGo/ + +For development purposes make sure to also install the development dependencies by +running: + +.. code-block:: + + $ python -m pip install -e /path/to/eTraGo/[dev] + +And setting up the pre-commit hooks: + +.. code-block:: + + $ pre-commit install + +If you prefer an anaconda environment feel free to use the supplied YML: .. code-block:: - $ pip3 install -e /path/to/eTraGo/ + $ conda env create -f d_py39_eTraGo.yml When you want to draw geographical features in the background of network plots, please install cartopy: .. code-block:: - $ pip3 install cartopy + $ python -m pip install cartopy If you run into problems when using cartopy, try to install shapely without binaries: .. code-block:: - $ pip3 install shapely --no-binary shapely + $ python -m pip install shapely --no-binary shapely Using a virtual environment =========================== -Before installing eTraGo, +Before installing eTraGo, you create a virtual environment (where you like it) and activate it: .. code-block:: bash @@ -92,7 +112,7 @@ you create a virtual environment (where you like it) and activate it: $ source venv/bin/activate $ cd venv -Inside your activated virtual environment you can +Inside your activated virtual environment you can install eTraGo with the pip command, as previously explained. diff --git a/d_py39_eTraGo.yml b/d_py39_eTraGo.yml new file mode 100644 index 00000000..11d34e3e --- /dev/null +++ b/d_py39_eTraGo.yml @@ -0,0 +1,19 @@ +name: d_py39_eTraGo +channels: + - conda-forge + - defaults +dependencies: + - python >= 3.8, < 3.10 + - pip + - conda-forge::contextily + - conda-forge::jupyterlab + - conda-forge::fiona + - conda-forge::pandas + - conda-forge::geopandas + - conda-forge::pyproj + - conda-forge::shapely + - conda-forge::rasterio + - conda-forge::geoalchemy2 + - conda-forge::pypsa == 0.20.1 + - pip: + - -e .[dev] diff --git a/setup.py b/setup.py index 8b6dde20..19f05546 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def read(*names, **kwargs): - with io.open( + with open( join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8"), ) as fh: @@ -68,6 +68,7 @@ def read(*names, **kwargs): "tsam", ], extras_require={ + "dev": ["black", "isort", "jupyterlab", "pre-commit", "pyupgrade"], "docs": ["sphinx >= 1.4", "sphinx_rtd_theme"], "gurobipy": ["gurobipy"], "cartopy": ["cartopy", "requests"],