awesome-spectral-indices / spyndex

Awesome Spectral Indices in Python.
https://spyndex.readthedocs.io/
MIT License
191 stars 22 forks source link

Extras require for `spyndex` #17

Open bastiencyr opened 1 year ago

bastiencyr commented 1 year ago

Hello,

The current dependencies management includes dev packages like earthengine-api. earthengine-api is heavy and users of spyndex don't necessary need it. So it's better to mark this dependency as a dev dependency. You can for example use the extras_require key in setup.py file. It would looks like this :


import io
import os
import re

from setuptools import find_packages, setup

def read(filename):
    ...

setup(
    name="spyndex",
    version="0.3.0",
    [...]
    install_requires=[
        "dask>=2021.9.1",
        "matplotlib",
        "numpy",
        "pandas",
        "python-box>=6.0",
        "requests",
        "seaborn",
        "xarray",
    ],
  extras_require={
        "dev": ["earthengin-api", "eemont>=0.3.6"],
    },
)

You can then install the regular version of this package with pip install . or the dev version with pip install .[dev]

Thanks !

davemlz commented 1 year ago

Hi @bastiencyr!

Thank you for the suggestion! GEE is not a dev dep. But I understand what you are saying, and it makes sense. However, it is then unclear where to draw the line (or how many lines to draw, aka multiple extras). Someone using just rasterio would say that they don't need xarray in the deps.

I will keep it simple for now and leave them in deps, satisfying all possible needs. Nevertheless, if it causes trouble, please feel free to reopen this issue!

Best,

David

bastiencyr commented 1 year ago

Hey, You're right, GEE is indeed used in the code and I didn't see this: https://github.com/awesome-spectral-indices/spyndex/blob/main/spyndex/spyndex.py

However, ee and eemont are very heavy (~100Mb). Docker images built with spyndex take space. We can create profile and install spyndex with the right option. For example, pip install spyndex[all] to install all depedencies or pip install spyndex[ee] to install spyndex only with ee support. It can be done with the following configuration:

extras_require={
        "all": ["spyndex[ee]", "spyndex[rasterio]"},
        "ee": ["earthengin-api", "eemont>=0.3.6"],
        "rasterio": [...],
    },

I didn't test this configuration.

We can renamed this issue in "Create optional dependencies list to lighten the size of spyndex package" , and thus, I don't think this issue has to be closed.

davemlz commented 1 year ago

This is exactly what I wanted to avoid. But I understand you. I will keep this Issue open (and see what others thinks) and will think and work on it later on ;)