Skip to content

ENH: Implement f2py2e with argparse #21923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 115 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
e8ff86e
ENH: Start refactoring f2py front-end
HaoZeke Oct 5, 2021
1c6867e
ENH: Start using logging
HaoZeke Oct 5, 2021
60740fd
ENH: Add more options for the new front-end
HaoZeke Oct 5, 2021
84890bf
ENH: Half the f2py options
HaoZeke Oct 5, 2021
b1d132f
ENH: Switch to using f2pyarg
HaoZeke Oct 18, 2021
bb0d5ec
ENH: Add f2py frontend stuff
HaoZeke Oct 18, 2021
e3136d4
FIX: f2pyarg --build-dir create directory if not present
NamamiShanker Jun 30, 2022
9fd7869
MAINT: Move f2pyarg helpers to service
NamamiShanker Jun 30, 2022
2cb37e3
FIX: Fix incorrect imports in f2pyarg service
NamamiShanker Jun 30, 2022
fe68428
MAINT: f2py check if input f2cmap file exists
NamamiShanker Jun 30, 2022
6d02396
MAINT: Fix --wrap-functions docs
NamamiShanker Jun 30, 2022
eb972f2
MAINT: f2pyarg Remove unnecessary flags
NamamiShanker Jul 2, 2022
9f5bdcb
MAINT: f2pyarg remove unnecessary flags
NamamiShanker Jul 2, 2022
7445850
MAINT: f2pyarg fix default values
NamamiShanker Jul 2, 2022
f035afa
FIX: f2pyarg transfer -h flag to generate_wrappers parser
NamamiShanker Jul 2, 2022
6d4a6d9
ENH: f2pyarg add file segregation method
NamamiShanker Jul 2, 2022
8b28a9b
ENH: Create temp dir for null builddir value
NamamiShanker Jul 2, 2022
f2e01c7
ENH: Chop callcrackfortran and move it to service. Add other helpers.
NamamiShanker Jul 2, 2022
f1e1b64
ENH: Initial f2pyarg main arg process function
NamamiShanker Jul 2, 2022
12a8d36
FIX: fix imports
NamamiShanker Jul 3, 2022
3413132
FIX: Set default verbosity to true like f2py2e
NamamiShanker Jul 3, 2022
8a2959b
MAINT: Remove unneccessary imports
NamamiShanker Jul 3, 2022
1299e5f
ENH: Handle overwrite-signature flag
NamamiShanker Jul 3, 2022
24a5c1a
ENH: update auxfuncs
NamamiShanker Jul 4, 2022
f5d61ca
ENH: Segregate pyf files
NamamiShanker Jul 4, 2022
8d76ee5
MAINT: Refactoring
NamamiShanker Jul 4, 2022
615b13e
MAINT: Rename _parse_postlist to _check_postlist
NamamiShanker Jul 4, 2022
744880c
Revert "ENH: update auxfuncs"
NamamiShanker Jul 5, 2022
2c2e7b7
FIX: Accept array of debug options rather that boolean flag
NamamiShanker Jul 5, 2022
9e3eaea
FIX: Default module name and default build directories
NamamiShanker Jul 5, 2022
7e0b754
MAINT: Fix typo and send pyf files to generate_files
NamamiShanker Jul 5, 2022
5990ffc
ENH: Send all required options to rules file
NamamiShanker Jul 5, 2022
4e79176
MAINT: Refactoring service
NamamiShanker Jul 5, 2022
56b7533
MAINT: Refactor for -c flag
NamamiShanker Jul 8, 2022
cdea12a
FIX: Change -c flag default val
NamamiShanker Jul 8, 2022
681c36a
ENH: Remove alternative macro flags for easier handling
NamamiShanker Jul 8, 2022
fdc859e
ENH: Add action class to process macros
NamamiShanker Jul 8, 2022
833e1cd
FIX: BoolAction string has no contains method error
NamamiShanker Jul 8, 2022
a261527
FIX: NPDLinkHelper setattr failure
NamamiShanker Jul 8, 2022
b3efb75
ENH: Add initial -c flag handling
NamamiShanker Jul 8, 2022
f218993
ENH: Add get_f2py_modulename function from np.distutils
NamamiShanker Jul 8, 2022
50232a6
FIX: _check_postlist verbosity error
NamamiShanker Jul 8, 2022
0204071
FIX: Change module_name to module
NamamiShanker Jul 8, 2022
7633678
FIX: Parse skip and only arguments
NamamiShanker Jul 8, 2022
e689a74
FIX: Segregate and return path of input files
NamamiShanker Jul 8, 2022
b82aa0d
FIX: data type of f77flags and f90flags
NamamiShanker Jul 11, 2022
e49b91a
FIX: Return signature file
NamamiShanker Jul 11, 2022
3ac82ae
MAINT: Refactor file segregation
NamamiShanker Jul 11, 2022
c1e7353
ENH: Support for -include<header> flag
NamamiShanker Jul 11, 2022
a9b056d
MAINT: Refactor wrapper generation settings
NamamiShanker Jul 11, 2022
2e415bd
FIX: Import f2py2e rather than f2py for run_main
NamamiShanker Jul 11, 2022
a95db5e
ENH: Generate comp flagsfrom parser namespace
NamamiShanker Jul 11, 2022
0ab3cb3
ENH: Add f2pyarg distutils compilation
NamamiShanker Jul 11, 2022
18809d9
FIX: link_resource default value
NamamiShanker Jul 11, 2022
3328d80
ENH: Add util file for f2py
NamamiShanker Jul 11, 2022
fc09d11
MAINT: Minor refactoring
NamamiShanker Jul 11, 2022
74a0fd8
FIX: Import f2py2e instead of f2py
NamamiShanker Jul 12, 2022
37ce8be
MAINT: Remove unused imports
NamamiShanker Jul 12, 2022
019c0e8
ENH: Use context manager for build_dir management
NamamiShanker Jul 12, 2022
8bbbc99
MAINT: Remove whitespaces
NamamiShanker Jul 12, 2022
2fb6ef6
FIX: Return after generating signature
NamamiShanker Jul 12, 2022
e690a50
FIX: Return string path of files
NamamiShanker Jul 12, 2022
7a3bf4f
FIX: Remove sneaky breakpoint
NamamiShanker Jul 12, 2022
ec0149c
MAINT: Remove unused build_dir function
NamamiShanker Jul 12, 2022
e58a3e3
FIX: Processing macros
NamamiShanker Jul 12, 2022
9829afb
FIX: f2cmap flag picking up positional args
NamamiShanker Jul 12, 2022
0c0a8fd
FIX: Print f2py version
NamamiShanker Jul 12, 2022
8b647aa
TST: Add f2pyarg modules to public api list
NamamiShanker Jul 13, 2022
39523e8
ENH: Add f2cmap support to f2pyarg compilation
NamamiShanker Jul 13, 2022
8d26dfb
ENH: Add typing support
NamamiShanker Jul 24, 2022
faf6044
ENH: Add typing support to f2pyarg
NamamiShanker Jul 24, 2022
073c1eb
FIX: Typing in f2py service file
NamamiShanker Jul 24, 2022
6ee477e
MAINT: Remove unnecessary imports
NamamiShanker Jul 24, 2022
818996f
FIX: Add pyf.src file support to f2pyarg
NamamiShanker Jul 24, 2022
b24509b
FIX: Remove os.path dependency from f2pyarg
NamamiShanker Jul 24, 2022
0606f6c
FIX: Remove os.path dependency from f2py service
NamamiShanker Jul 24, 2022
7fb2af1
FIX: Replace os.path with pathlib.Path
NamamiShanker Jul 24, 2022
a81091b
FIX: Typing
NamamiShanker Jul 24, 2022
6e00457
MAINT: Use boolean values instead of integers
NamamiShanker Jul 24, 2022
98f9b6e
MAINT: Refactorings
NamamiShanker Jul 24, 2022
b774d68
MAINT: Remove unnecessary comments
NamamiShanker Jul 24, 2022
f57e191
FIX: set_dependecies_dist potential bug
NamamiShanker Jul 24, 2022
eeaac5d
MAINT: Rename regex variables as module constants
NamamiShanker Jul 24, 2022
5d9f32a
MAINT: Replace os.path with pathlib.Path
NamamiShanker Jul 24, 2022
8307d1f
MAINT: Typing and pathlib related refactoring
NamamiShanker Jul 24, 2022
ee6f638
FIX: Passing rem to f2pyflags_dist
NamamiShanker Jul 24, 2022
8d89d65
FIX: Always convert f2cmap_file to Path type
NamamiShanker Jul 24, 2022
9596d42
MAINT: Apply changes from code review
NamamiShanker Jul 24, 2022
b93e054
MAINT: No need to use try..finally
NamamiShanker Jul 24, 2022
0d7da60
FIX: Return full path string
NamamiShanker Jul 24, 2022
83f84ce
FIX: Print name of PosiPath type variable
NamamiShanker Jul 24, 2022
4e1fcd4
MAINT: Refactorings from code review
NamamiShanker Jul 24, 2022
523d41f
MAINT: Refactorings from code review
NamamiShanker Jul 24, 2022
99d59db
FIX: Typing errors
NamamiShanker Jul 24, 2022
b181708
FIX: Replace builtin types with typing
NamamiShanker Jul 24, 2022
0a18b55
MAINT: Add docstring to explain open_build_dir
NamamiShanker Jul 24, 2022
b489d88
ENH: Add temporary comments
NamamiShanker Jul 24, 2022
3c69667
ENH: Use builtin types in place of typing
NamamiShanker Jul 25, 2022
9323b91
BUG: Seperate paths by colon
NamamiShanker Aug 7, 2022
3b04931
MAINT: Sort by alphabetical order
NamamiShanker Aug 7, 2022
8a23d37
MAINT: Fix typo
NamamiShanker Aug 12, 2022
e528972
ENH: Add custom string flags parsing
NamamiShanker Aug 12, 2022
df65a2e
FIX: Flag nargs
NamamiShanker Aug 18, 2022
e0637df
MAINT: Correct docstring
NamamiShanker Aug 18, 2022
c81e90b
BUG: "--noopt" flag bugfix
NamamiShanker Sep 7, 2022
3ac23f8
MAINT: Return Path object of tempdir
NamamiShanker Aug 24, 2022
0b2c031
BUG: Lower C wrapper defs by default for less buggy imports
NamamiShanker Aug 26, 2022
c910d6b
BUG: Read module name from pyf file without -c
NamamiShanker Aug 26, 2022
a35027e
Revert "BUG: Read module name from pyf file without -c"
NamamiShanker Aug 29, 2022
263e3f9
BUG: Change default value of lower flag
NamamiShanker Aug 31, 2022
9ef6974
BUG: Change default module name
NamamiShanker Aug 31, 2022
9e8756c
MAINT: Set Default empty gen False
NamamiShanker Aug 31, 2022
78b9b98
BUG: Get module name from postlist
NamamiShanker Aug 31, 2022
8ce9426
BUG: Shift files to the end of sys.argv
NamamiShanker Sep 7, 2022
5aa96cd
BUG: f2pyarg sort args fix
NamamiShanker Sep 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ENH: Support for -include<header> flag
  • Loading branch information
NamamiShanker authored and HaoZeke committed Aug 24, 2023
commit c1e73533501e2b965ea68a57a7bb080b51e664ba
88 changes: 46 additions & 42 deletions numpy/f2py/f2pyarg.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,9 @@ def __call__(self, parser, namespace, values, option_string=None):
# Main Process #
################

def get_additional_headers(rem):
return [val[8:] for val in rem if val[:8] == '-include']


def get_build_dir(args):
if(args.build_dir is not None):
Expand Down Expand Up @@ -630,7 +633,7 @@ def segregate_posn_args(args):
funcs[mode].append(arg)
return files, funcs['skip:'], funcs['only:']

def process_args(args):
def process_args(args, rem):
if args.help:
parser.print_help()
parser.exit()
Expand All @@ -641,53 +644,54 @@ def process_args(args):
build_dir = get_build_dir(args)
sign_file = get_signature_file(args, build_dir)

# Disutils receives all the options and builds the extension.
if(args.c):
sources = pyf_files + f77_files + f90_files
remove_build_dir = not bool(args.build_dir)
link_files = args.link_resource
include_dirs = args.include_dirs
library_dirs = args.library_path
libraries = args.library_name
define_macros = args.define_macros
undef_macros = args.undef_macros
else:
settings = {
'buildpath': build_dir,
'f2cmap': args.f2cmap,
'verbose': args.verbose,
'dorestdoc': args.rest_doc,
'dolatexdoc': args.latex_doc,
'shortlatex': args.short_latex,
'debug': args.debug_api,
'wrapfuncs': args.wrap_functions,
'do-lower': args.lower,
'include_paths': args.include_paths,
# Disabing these options from frontend
'emptygen': True,
'f2py_wrapper_output': None,
'coutput': None,
}

file_gen_options = {
'module': module_name,
'skipfuncs': skip_funcs,
'onlyfuncs': only_funcs,
'verbose': args.verbose,
'include_paths': args.include_paths,
'do-lower': args.lower,
'debug': args.debug_api,
'wrapfuncs': args.wrap_functions,
}
headers = get_additional_headers(rem)
# TODO: Refine rules settings. Read codebase and remove unused ones
rules_setts = {
'module': module_name,
'buildpath': build_dir,
'dorestdoc': args.rest_doc,
'dolatexdoc': args.latex_doc,
'shortlatex': args.short_latex,
'verbose': args.verbose,
'do-lower': args.lower,
'f2cmap_file': args.f2cmap,
'include_paths': args.include_paths,
'coutput': None,
'f2py_wrapper_output': None,
'emptygen': True,
}
crackfortran_setts = {
'module': module_name,
'skipfuncs': skip_funcs,
'onlyfuncs': only_funcs,
'verbose': args.verbose,
'include_paths': args.include_paths,
'do-lower': args.lower,
'debug': args.debug_api,
'wrapfuncs': args.wrap_functions,
}
capi_maps_setts = {
'f2cmap': args.f2cmap,
'headers': headers,
}
auxfuncs_setts = {
'verbose': args.verbose,
'debug': args.debug_api,
'wrapfuncs': args.wrap_functions,
}

wrapper_settings(rules_setts, crackfortran_setts, capi_maps_setts, auxfuncs_setts)


generate_files(f77_files + f90_files, module_name, sign_file, file_gen_options, settings)

def main():
logger = logging.getLogger("f2py_cli")
logger.setLevel(logging.WARNING)
args = parser.parse_args()
process_args(args)

args, rem = parser.parse_known_args()
# since argparse can't handle '-include<header>'
# we filter it out into rem and parse it manually.
process_args(args, rem)

if __name__ == "__main__":
main()