scikit-build f2py compile error with full path of signature file on Windows

Skip to first unread message

Johann Rohwer

Aug 26, 2022, 10:10:16 AM8/26/22

Hi all,

I am trying to port the build system for a python package (GitHub - PySCeS/pysces: The official PySCeS project source code repository.) from numpy.distutils to use scikit-build because of the deprecation of distutils (the package contains 2 Fortran extension modules wrapped with f2py). To get to know the system I’ve started with a minimal example that I've put together from reading the numpy/f2py and scikit-build documentation. I have been getting compile failures on Windows (on Linux and macOS everything works, I can build and install the module).

I have posted this on SO and on the Fortran discourse group but have not had any replies despite quite a number of reads. Perhaps anyone here can help out? Links to the other posts:

Minimal example (I attach the zipped full source tree of the package for reference if needed):


      PRINT*,"Hello from fortran"


!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module hi ! in 
    interface  ! in :hi
        subroutine hello ! in :hi:hi.f
        end subroutine hello
    end interface 
end python module hi

! This file was auto-generated with f2py (version:1.23.2).
! See:

During compilation with python build the build fails. In tracking it down I saw that ninja/cmake expands the full path of the source files and this is where it fails. To ensure that it is not a problem with the skbuild build system I verified that the failure can be reproduced on the command line using f2py on its own as follows - copy the Fortran files above to the same folder and then run in a command prompt:

(skbuild) Z:\Documents\Python\skbuild_test\simple\hello\shout>f2py.exe -m hi -c hi.pyf hi.f

(works and generates the .pyd and .dll files)

However, specifying the full path, fails:

(skbuild) Z:\Documents\Python\skbuild_test\simple\hello\shout>f2py.exe -m hi -c Z:/Documents/Python/skbuild_test/simple/hello/shout/hi.pyf Z:/Documents/Python/skbuild_test/simple/hello/shout/hi.f
running build
running config_cc
INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
INFO: build_src
INFO: building extension "hi" sources
creating C:
creating C:Users
creating C:Users\jr
creating C:Users\jr\AppData
creating C:Users\jr\AppData\Local
creating C:Users\jr\AppData\Local\Temp
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\\Documents
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\\Documents\Python
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\\Documents\Python\skbuild_test
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\\Documents\Python\skbuild_test\simple
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\\Documents\Python\skbuild_test\simple\hello
creating C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\\Documents\Python\skbuild_test\simple\hello\shout
INFO: f2py options: []
INFO: f2py: Z:/Documents/Python/skbuild_test/simple/hello/shout/hi.pyf
error: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:C:\\Users\\jr\\AppData\\Local\\Temp\\tmpdbudw6jh\\\\Documents\\Python\\skbuild_test\\simple\\hello\\shout'

The problem seems to be with the creating C:Users part leading to the malformed filename in the last line.

Specifying only the filename for hi.pyf but the full path for hi.f does work strangely enough, but as soon as the full path for hi.pyf is specified it fails. As mentioned, on Linux and macOS all works fine.

I could of course skip the .pyf file and then it works. However, the Fortran code I’m wrapping is F77 and needs to be redistributed in unmodified form due to licensing conditions, so I do need a custom .pyf file to integrate it into my Python module.


  • Windows 10 64-bit
  • MSVC 2022 build tools
  • mingw
  • python 3.10.6
  • numpy 1.23.2

I realize this may not be directly related to skbuild, since the error can be reproduced on the command line using only f2py, but perhaps someone here has seen anything similar? I honestly have no idea what is going on here.


Jean-Christophe Fillion-Robin

Dec 14, 2022, 5:46:27 PM12/14/22
to scikit-build
Hi Johann,

Thanks for reaching out and providing all these details.

In the process of transitioning to GitHub Discussions, I moved your question to

Thanks for understanding,

Ps: For details about our transition plan to GitHub Discussions, see
Reply all
Reply to author
0 new messages