openENTRANCE / openentrance

Definitions of common terms (variables, regions, etc.) for the openENTRANCE project
http://openentrance.eu
Apache License 2.0
30 stars 49 forks source link

iso_mapping empty #202

Closed willu47 closed 11 months ago

willu47 commented 1 year ago

The dictionary containing region mappings is empty in openentrance v0.3.dev74+gbe22752 when I use a non-editable install.

$ pip install git+https://github.com/openENTRANCE/openentrance.git@main#egg=openentrance
$ pip list
openentrance                  0.3.dev74+gbe22752
$ python -c 'from openentrance import iso_mapping; print(iso_mapping)'
{}

Because it is not possible to denote a dependency as required to be installed as editable under a Python package (e.g. in the install_requires section), this means I cannot distribute my package without requiring a manual editable install of the openentrance package.

willu47 commented 1 year ago

On further investigation, I found a hacky solution - you must use an editable install, so the following solves the issue:

$ pip install -e git+https://github.com/openENTRANCE/openentrance.git@main#egg=openentrance

To solve this so that the data structure is installed using pip, the data component of the openentrance package needs to be contained in the source code directory.

The pyscaffold docs has a good description of this, which enables use of importlib.resources

from importlib.resources import read_text, read_binary
data = read_text('my_package.sub_package', 'data.txt')
danielhuppmann commented 1 year ago

FWIW, the “editable“ install is specified in the installation instructions, see https://github.com/openENTRANCE/openentrance/tree/main/openentrance#installation-instructions.

But I understand that this can be easily overlooked and that a “standard pip install” would be preferable…

willu47 commented 1 year ago

Yes, but note the above:

Because it is not possible to denote a dependency as required to be installed as editable under a Python package (e.g. in the install_requires section of setup.cfg), this means I cannot distribute my package without requiring a manual editable install of the openentrance package.

danielhuppmann commented 1 year ago

Ok, now I got it why it's a problem...

How much of a headache is this for you? Or is there some timeline or release date by which you would be really happy if we came up with a better solution?

willu47 commented 1 year ago

It's a bit of a pain, but given that it only really causes our small team of 3 people a headache, probably not a priority for now. We can manage with the manual editable install until a fix comes along (or I submit a PR).

danielhuppmann commented 11 months ago

Against stumbled over this issue. I think that the newly added countries-module in the nomenclature package serves the needs better than the openentrance utility.

See https://nomenclature-iamc.readthedocs.io/en/stable/api/countries.html for more info.