On Fri, Aug 26, 2022 at 5:52 PM Johann Rohwer <j...@sun.ac.za> wrote:

> Hi all,
>
> First of all, I am not sure if this is the correct forum for f2py-related
> questions, but since f2py is part of numpy I thought I'd start here. Please
> point me to the correct place if I am mistaken.
>
This is the right mailing list indeed. Although f2py knowledge is a bit
scarce, and the few people that tend to work actively on f2py are more
responsive on GitHub I think. So opening an issue at
https://github.com/numpy/numpy/issues may yield a better response.

I am trying to port the build system for a python package (GitHub -
> PySCeS/pysces: The official PySCeS project source code repository.
> <http://github.com/PySCeS/pysces>) 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. I have been getting compile
> failures on Windows (on Linux and macOS everything works).
>
> 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:
>
>    - python - f2py compile error with signature file on Windows - Stack
>    Overflow
>    
> <https://stackoverflow.com/questions/73464905/f2py-compile-error-with-signature-file-on-windows>
>    - Fortran language discourse group
>    
> <https://fortran-lang.discourse.group/t/f2py-compile-error-with-full-path-of-signature-file-on-windows/4211>
>
> Minimal example:
>
> *hi.f*
>
>       SUBROUTINE HELLO()
>       PRINT*,"Hello from fortran"
>       END
>
> *hi.pyf*
>
> !    -*- 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:
> ! 
> https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e
>
> During compilation with python setup.py 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.
>
It's probably CMake doing that. Ninja is agnostic to that. In SciPy we have
.pyf files, but by design Meson writes out the `build.ninja` with only
relative paths for anything inside the source tree. So we haven't seen this
issue before.

That said, I agree that it's still expected to work with absolute paths
though, so it looks like an f2py bug.

It's probably not super hard to fix for one of the f2py folks with access
to a Windows machine. It may take a little while though - but please do
open a new issue.

Cheers,
Ralf


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.frunning buildrunning 
> config_ccINFO: unifing config_cc, config, build_clib, build_ext, build 
> commands --compiler optionsrunning config_fcINFO: unifing config_fc, config, 
> build_clib, build_ext, build commands --fcompiler optionsrunning 
> build_srcINFO: build_srcINFO: building extension "hi" sourcescreating 
> C:creating C:Userscreating C:Users\jrcreating C:Users\jr\AppDatacreating 
> C:Users\jr\AppData\Localcreating C:Users\jr\AppData\Local\Tempcreating 
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jhcreating 
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\src.win-amd64-3.10creating 
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\src.win-amd64-3.10\Documentscreating
>  
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\src.win-amd64-3.10\Documents\Pythoncreating
>  
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\src.win-amd64-3.10\Documents\Python\skbuild_testcreating
>  
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\src.win-amd64-3.10\Documents\Python\skbuild_test\simplecreating
>  
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\src.win-amd64-3.10\Documents\Python\skbuild_test\simple\hellocreating
>  
> C:Users\jr\AppData\Local\Temp\tmpdbudw6jh\src.win-amd64-3.10\Documents\Python\skbuild_test\simple\hello\shoutINFO:
>  f2py options: []INFO: f2py: 
> Z:/Documents/Python/skbuild_test/simple/hello/shout/hi.pyferror: [WinError 
> 123] The filename, directory name, or volume label syntax is incorrect: 
> 'C:C:\\Users\\jr\\AppData\\Local\\Temp\\tmpdbudw6jh\\src.win-amd64-3.10\\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.
> ------------------------------
>
> *NOTE:*
> 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.
> ------------------------------
>
> *System*
>
>    - Windows 10 64-bit
>    - MSVC 2022 build tools
>    - mingw 11.2.0.07112021
>    - python 3.10.6
>    - numpy 1.23.2
>
> I have no idea what is going on here.
>
> Thanks,
> Johann
>
>
> The integrity and confidentiality of this email are governed by these
> terms. Disclaimer <https://www.sun.ac.za/emaildisclaimer/default.aspx>
> Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende
> bepalings bereël. Vrywaringsklousule
> <https://www.sun.ac.za/emaildisclaimer/default.aspx>
> _______________________________________________
> NumPy-Discussion mailing list -- numpy-discussion@python.org
> To unsubscribe send an email to numpy-discussion-le...@python.org
> https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
> Member address: ralf.gomm...@googlemail.com
>
_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to