Search code examples
anacondacondaappveyorminicondaconda-build

conda-forge recipe for python package with a fortran extension not working on appveyor


I am trying to get a conda-build recipe to pass all the CI tests on conda-forge/staged-recipes. Here is a link to the pull request The python package has a fortran extension and uses numpy.distutils in the setup.py to build the extension. Circle CI for Linux, Travis-CI for OSX pass, but I cannot get Appveyor for Windows to work with the conda-build recipe.

When using Miniconda for the Appveyor build for Windows and Travis CI build for OSX and Linux for the package repo everything works and the tests pass. I can also get the conda-build recipe to work locally on Windows and Linux, but as you can see from the pull request to conda-forge the tests do not pass for Windows using Appveyor.

The import test fails to load the fortran extension with ImportError: DLL load failed: The specified module cannot be found. The extension module is copied to the site-packages directory, copying build\lib.win-amd64-3.6\timml\besselaesnew.cp36-win_amd64.pyd C:\bld\timml_1541596078787\_h_env\Lib\site-packages\timml, so I am stumped why it is not being found. I read about the differences between .pyd and dll, and tried --compiler=mingw32 instead of --compiler=msvc as mentioned here. That still didn't work. I also added zlib to the host and run section, after reading this and that didn't help.

Any tips to get a conda-build recipe for python package with a fortran extension working on Appveyor would be greatly appreciated. The compiler args in the setup.py file for windows is copied below in case that matters.

if os.name == "nt": compile_args = ["-static-libgcc", "-Wall", "-shared"]


Solution

  • The issue was with the difference between dll and .pyd files and the compiler specification. After looking at the conda-forge-pinning conda_build_config.yaml, the way to choose mingw instead of msvc is:

    requirements:
      build:
        - {{ compiler('fortran') }}
        - {{ compiler('m2w64_c') }}  # [win]
        - {{ compiler('m2w64_fortran') }}  # [win]