raphaelquast / EOmaps

A library to create interactive maps of geographical datasets
https://eomaps.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
339 stars 25 forks source link

Optimizing dependencies #208

Closed banesullivan closed 11 months ago

banesullivan commented 11 months ago

Is your feature request related to a problem? Please describe. EOmaps has quite a few hard requirements under it's basic installation mode: pip install EOmaps. I'm curious if we could trim down the requirements to a critical few to minimize the impact of installing EOmaps?

I realize that many of these dependencies are indeed mission-critical (matplotlib, numpy, cartopy), but other dependencies may be more for user convenience or used for specific tasks.

Keeping the core, hard dependencies of a Python package slim ensures that the package remains lightweight and easy to install, reducing the risk of compatibility issues and dependency conflicts. Leveraging Python packaging's structure for optional dependencies allows for greater flexibility and customization, enabling users to tailor the package to their specific needs without being burdened by unnecessary components.

However, I want you to do whatever makes the most sense for most users. If you think most users want all of these, give them all of these! I just thought I'd raise this as it was a bit of a red flag to see so many dependencies without any optional.

Describe the solution you'd like Would it make sense to group some of these dependencies using extras_requires (or optional-dependencies in the new setuptools paradigm)? I think you'll have a better understand of which groups to implement but I'm imagining something like:

Perhaps remove the following:

And set the dependencies as:

dependencies = [
    'numpy',
    'pandas',
    'matplotlib>=3.4',
    'cartopy>=0.20.0',
    'pyproj',
    'geopandas',
    'click',
]

[project.optional-dependencies]
all = ['EOmaps[wms,features]']
wms = [
    'owslib',
    'cairosvg',
    'requests'
]
features = [
    'mapclassify',
    'xmltodict',
    'descartes',
    'pyepsg',
    'scipy',
]

I see that you are already handling many of these dependencies as "optional" in a sense, like here:

https://github.com/raphaelquast/EOmaps/blob/71361494f5af1fb6674c9862339d0e40946f5e89/eomaps/shapes.py#L1269-L1274

But this isn't well handled everywhere:

https://github.com/raphaelquast/EOmaps/blob/71361494f5af1fb6674c9862339d0e40946f5e89/eomaps/shapes.py#L259

As a second part of this issue/request, I'm curious if you could make sure that optional dependencies are well-handled throughout the library: raising user-friendly exceptions when not available (as you have above)

Describe alternatives you've considered

If nothing else, I think it would be great to explain the purpose of each dependency

Additional context Add any other context or screenshots about the feature request here.

raphaelquast commented 11 months ago

@banesullivan Thank you for opening this issue!

I agree that EOmaps is currently installing a lot of optional dependencies that are not needed for basic functionalities.

The reason why I choose to be quite extensive at the moment is twofold: 1) I wanted EOmaps to become a package that is intended for a broad audience of geo-data scientists, and not all of them are experts in what's going on behind the scenes of a python package. If optional dependencies require some c++ libraries like GDAL, PROJ, running pip install geopandas after a conda install -c conda-forge eomaps can potentially break the whole environment and from my experience this is one of the main reasons why I encounter a lot of people that think it is difficult to setup python for geo-data analysis. 2) My main target from the start was to use conda since it solved all problems I ever had with (geo related) python environments. Now the biggest problem here is that conda has no suitable "easy-to-use" machinery for optional dependencies (such as pip). Setting up meta-packages similar to matplotlib-base would be nice, but it just feels like a lot of work (and maintenance work) if I want to support multiple different sets of dependencies. (see https://github.com/conda/conda/issues/7502)

I am unsure if implementing optional dependencies with pip and keeping the full install on conda is a good idea or if this might cause confusion. On the other hand, I am not sure how I would even implement a conda metapackage... Any help/insights on this are very much appreciated!

Concerning the handling of optional dependencies.... I need to explicitly test this to be 100% sure but in general I think that optional dependencies should already be treated as expected (except that they are installed...)!

on packages that might be removed

raphaelquast commented 11 months ago

First draft for optional dependency groups now implemented in the PR that implements the switch from setup.py to pyproject.toml: #216 !

raphaelquast commented 11 months ago

Optional pip dependency groups are now included in EOmaps v8.0 (see #205)!