Open-EO / openeo-geopyspark-driver

OpenEO driver for GeoPySpark (Geotrellis)
Apache License 2.0
26 stars 4 forks source link

Switch to "src layout" #406

Open soxofaan opened 1 year ago

soxofaan commented 1 year ago

In some situations/contexts the openeogeotrellis.collections subpackage conflicts with the collections module of stdlib: a naive import collections somewhere (maybe even in third party lib) loads geotrellis.collections which is not intended.

It's tempting to rename openeogeotrellis.collections as a fix, but that is actually just hiding a symptom of deeper misconfiguration issue: adding the openeogeotrellis folder itself to PYTHONPATH in some way (e.g. which happens automatically when setting it as "source folder" in PyCharm). This makes every (sub)module foo under openeogeotrellis importable with just import foo. Note that we have a lot of modules there with pretty generic names: catalogs, config, integrations, ml, backend, cli, logs, testing, utils, vault, etc. The risk on other conflicts with existing packages is not zero.

It's better, e.g. in PyCharm, to mark the project root folder as "source folder", but this makes a lot more resources importable than necessary.

This problem is one of the reasons to prefer the "src layout" over the more traditional "flat layout" (which we currently use) as discussed in https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/ .

soxofaan commented 1 year ago

cc @JeroenVerstraelen

soxofaan commented 1 year ago

note that switching to "src layout" involves more than just moving directories, e.g.: