Skip to content

BUG: f2py -h doesn't accept more than one argument for --include-paths on Windows  #24533

Closed

Description

@afedynitch

Describe the issue:

The colon separator in f2py -h xxx.pyf --include-paths dir1:dir2 doesn't properly work on Windows. Only the first list item is parsed whereas the other ones throw errors.

Prepare the following pieces for reproduction:

dirs:
--incldir1/inc/
--incldir2
files:
fincl.f:

      SUBROUTINE DEMO

      IMPLICIT NONE
      INCLUDE 'inc/inclme'

      A = 1
      B = 2
      WRITE (6,*) 'Hello World.', A, B
      END SUBROUTINE

file incldir1/inc/inclme:

      INTEGER A, B
      COMMON /MYCOMMON/ A, B

Reproduce the code example:

Run in Powershell or cmd:
 
python -m numpy.f2py -h fincl.pyf fincl.f --include-paths "incdir2":"incdir1"

Error message:

python -m numpy.f2py -h fincl.pyf fincl.f --include-paths "incdir2":"incdir1" --overwrite-signature  
OSError: [Errno 2] No such file or directory: ':incdir1'. Skipping file ":incdir1".
Reading fortran codes...
        Reading file 'fincl.f' (format:fix,strict)
Line #5 in fincl.f:"      INCLUDE 'inc/inclme'"
        readfortrancode: could not find include file 'inc/inclme' in ;incdir2. Ignoring.
Post-processing...
        Block: demo
Applying post-processing hooks...
  character_backward_compatibility_hook
Post-processing (stage 2)...
Saving signatures to file ".\fincl.pyf"

Runtime information:

>>> import sys, numpy; print(numpy.__version__); print(sys.version)
1.25.2
3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 17:59:51) [MSC v.1935 64 bit (AMD64)]
>>> print(numpy.show_runtime())
WARNING: `threadpoolctl` not found in system! Install it by `pip install threadpoolctl`. Once installed, try `np.show_runtime` again for more detailed build information
[{'numpy_version': '1.25.2',
  'python': '3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 17:59:51) '
            '[MSC v.1935 64 bit (AMD64)]',
  'uname': uname_result(system='Windows', node='tapc604', release='10', version='10.0.22621', machine='AMD64')},
 {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],   
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2'],
                      'not_found': ['AVX512F',
                                    'AVX512CD',
                                    'AVX512_SKX',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL']}}]
None

Also occurs on "all" versions >= 1.19.5

Context for the issue:

We have a multiplatform code - chromo - with substantial fortran codebase and faced problems with f2py versions distributed in numpy >=1.20. Therefore, we cached the f2py signature files generated with 1.19.5 on linux and made them part of the repo. This approach masked this bug in Windows until the general f2py bug has been fixed in #22657 by @HaoZeke.

Since #22657 has been merged, we will remove our caching with the next numpy release. Until this problem shown above persists, we will have to stop distributing Windows binaries and suspend supporting it until the present bug is resolved. It doesn't appear very challenging to solve but the interface may need to accept other separators which are not colons on Windows.

Activity

  1. added this to the 1.26.0 release milestone on Aug 25, 2023
  2. charris commented on Aug 25, 2023

    @charris
    Member

    @HaoZeke Ping.

  3. HaoZeke commented on Aug 25, 2023

    @HaoZeke
    Member

    Thanks for the detailed bug report @afedynitch.
    However, I'm not convinced this is a bug in fp2y, the f2py2e parser splits by os.pathsep:

    numpy/numpy/f2py/f2py2e.py

    Lines 270 to 272 in 20b007f

    f7 = 0
    include_paths.extend(l.split(os.pathsep))
    elif f8:

    which means on Windows the call must be "incdir2";"incdir1", so:

    python -m numpy.f2py -h fincl.pyf fincl.f --include-paths "incdir2";"incdir1" --overwrite-signature

    Let me know if this works, and feel free to reopen if not :)

  4. afedynitch commented on Sep 2, 2023

    @afedynitch
    Author

    Hi,

    thanks! The correct syntax for windows is "path1;path2;path3", it needs quotes around the whole expression.
    So yea, it's not a bug, but the syntax on Windows could be made clearer in the docs.

    For those trying to handle this with CMake... to concatenate a list of paths one must use $<SEMICOLON> since the ";" character is special in many ways within CMake.

  5. added a commit that references this issue on Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions