csdms / pymt

A Python toolkit for running and coupling Earth surface models
https://pymt.readthedocs.io
MIT License
52 stars 20 forks source link

Fix cfunits import error on Windows #84

Closed mcflugen closed 5 years ago

mcflugen commented 5 years ago

This fixes an issue on Windows where the units database could not be found (udunits2.xml). This resulted as an assertion error when importing cfunits from within pymt,

>>> import cfunits
Traceback (most recent call last):
...
    assert(0 == _ut_unmap_symbol_to_unit(_ut_system, _c_char_p(b'Sv'), _UT_ASCII))

The issue is that udunits2 library can not correctly find udunits2.xml in the default location. On Windows anyway. To fix this, I set the UDUNITS_XML_PATH environment variable in pymt/__init__.py to point to the path of udunits2.xml within the cfunits package. I do this for all platforms, not just Windows but I think that should be fine.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.03%) to 71.379% when pulling b583c440e7549b7b5a2be3806c06481346a4f6a0 on mcflugen/fix-cfunits-import-error-on-windows into cd191bec7202923b1280f9ee9e794c5269043b25 on master.