NCAS-CMS / cfunits

A Python interface to UNIDATA’s UDUNITS-2 library with CF extensions:
http://ncas-cms.github.io/cfunits
MIT License
11 stars 8 forks source link

windows conda cfunits #28

Closed daniel-mohr closed 3 years ago

daniel-mohr commented 3 years ago

If I try to use cfunits from miniconda on windows I get:

python -c "import cfunits"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Miniconda\lib\site-packages\cfunits\__init__.py", line 47, in <module>
    from .units import Units  # noqa: F401
  File "C:\Miniconda\lib\site-packages\cfunits\units.py", line 226, in <module>
    assert 0 == _ut_unmap_symbol_to_unit(_ut_system, _c_char_p(b"Sv"), _UT_ASCII)
AssertionError

Sorry, I have no idea and also I'm not sure that this is an issue of cfunits. ?

davidhassell commented 3 years ago

Hi Daniel, which version of cfunits are you using?

davidhassell commented 3 years ago

(I should add that I have never tested cfunits on windows. I'll have a little look at the code ...)

daniel-mohr commented 3 years ago

Sorry, I'm also not familiar with windows. I just tried on github actions to run my software on windows and got more or less above error.

conda used cfunits-3.3.3.

I now created an explicit test for cfunit. Maybe this minimal test on windows could be integrated in the github actions here?

I got it running by explicit set an environment variable, e. g.:

jobs:
  windows-2016_test_cfunits:
    runs-on: windows-2016
    steps:
    - name: conda init powershell
      run: |
        &($env:CONDA + "\Scripts\conda") init powershell
    - name: install dependencies via conda
      run: conda install -c conda-forge cfunits
    - name: python -c "import cfunits"
      run: |
        $env:UDUNITS2_XML_PATH = $env:CONDA + "\Library\share\udunits\udunits2.xml"
        python -c "import cfunits"

  windows-2019_test_cfunits:
    runs-on: windows-2019
    steps:
    - name: conda init powershell
      run: |
        &($env:CONDA + "\Scripts\conda") init powershell
    - name: install dependencies via conda
      run: conda install -c conda-forge cfunits
    - name: python -c "import cfunits"
      run: |
        $env:UDUNITS2_XML_PATH = $env:CONDA + "\Library\share\udunits\udunits2.xml"
        python -c "import cfunits"

But I do not think this is a nice way. But unfortunately I do not know better to use conda and/or windows. :-(

davidhassell commented 3 years ago

Hi Daniel,

OK, good - the use of UDUNITS2_XML_PATH is documented at https://ncas-cms.github.io/cfunits/installation.html - I should have spotted the error message you were getting as being highlighted in that doc page! Thanks for working through it.

All the best, David

daniel-mohr commented 3 years ago

Hi David,

is it interesting for you to include such a github action for windows? Should I try?

Regards, Daniel

davidhassell commented 3 years ago

Hi Daniel - if you would like to submit a PR for that, that would be most welcome. David

daniel-mohr commented 3 years ago

Hi David,

I tried now to create a CI workflow in #29.

Regards, Daniel