NOAA-MDL / grib2io

Python interface to the NCEP G2C Library for reading and writing GRIB2 messages.
https://noaa-mdl.github.io/grib2io
MIT License
30 stars 11 forks source link

setup.py does not support pip installation inside conda environment using existing libg2c #98

Closed lboeman closed 12 months ago

lboeman commented 1 year ago

When the CONDA_PREFIX envvar is set , setup.py attempts to find libg2c inside the directory at CONDA_PREFIX. If the user has installed their dependencies at one of the typical non-conda locations, e.g. /usr/local then setup.py fails to find the library and throws an exception.

Steps to reproduce:

# Install [NCEPLIBS-g2c](https://github.com/NOAA-EMC/NCEPLIBS-g2c) into a "common" installation path.
conda create -n grib2io-setup-issue python=3.8
conda activate grib2io-setup-issue

# From source directory:
pip install .

This issue can be addressed using the G2C_DIR envvar, but this behavior seems unexpected.

It seems that either a conda-supplied or manually built g2c library could be supported by adjusting this section: https://github.com/NOAA-MDL/grib2io/blob/b9053dc4c76be162bc2311949573a89fa3c06485/setup.py#L26-L29 to prepend the dir at CONDA_PREFIX to the list of common dirs to search.

I'm happy to work up a PR for this issue if it's welcome.

EricEngle-NOAA commented 1 year ago

Hi @lboeman. PRs are welcome. A few things to keep in mind regarding this:

I am looking to release v2.0.1 in the next week or so. I'd like to get this in for that if possible.

lboeman commented 1 year ago

Hi @EricEngle-NOAA Thanks for the response.

I was unaware that the NCEPLIBS-g2c library was available via conda. I think that between G2C_DIR and conda availability of the libraries, my concerns are addressed since there are workarounds to installing from source/pip within a conda environment.

Considering your final point, this change may generate more problems than allowing users to work through the available options, especially for less experienced users on shared systems. I think that nudging conda users towards a conda installation and leaving G2C_DIR as an alternative is probably less problematic than making that assumption for the user.