Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ce9426

Browse files
NamamiShankerHaoZeke
authored andcommitted
BUG: Shift files to the end of sys.argv
1 parent 78b9b98 commit 8ce9426

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

numpy/f2py/f2pyarg.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from __future__ import annotations
1919

20+
import sys
2021
import argparse
2122
import logging
2223
import os
@@ -825,9 +826,16 @@ def process_args(args: argparse.Namespace, rem: list[str]) -> None:
825826
# Step 8: Generate wrapper or signature file if compile flag is not given
826827
generate_files(f77_files + f90_files, module_name, sign_file)
827828

829+
def sort_args(args: list[str]) -> list[str]:
830+
"""Sort files at the end of the list"""
831+
extensions = (".f", ".for", ".ftn", ".f77", ".f90", ".f95", ".f03", ".f08", ".pyf", ".src", ".o", ".out", ".so", ".a")
832+
if any(arg.endswith(extensions) for arg in args):
833+
return sorted(args, key=lambda arg: arg.endswith(extensions))
834+
828835
def main():
829836
logger = logging.getLogger("f2py_cli")
830837
logger.setLevel(logging.WARNING)
838+
sys.argv = sort_args(sys.argv)
831839
args, rem = parser.parse_known_args()
832840
# since argparse can't handle '-include<header>'
833841
# we filter it out into rem and parse it manually.

0 commit comments

Comments
 (0)