hostconf package¶
hostconf.configure module¶
Tools for emulating autoconf’s inspection abilities in pure (ok, almost) python.
-
class
hostconf.configure.Configure(name='hostconf', compiler=None, tmpdir=None, verbose=0, dry_run=0, debug=False)[source]¶ Bases:
objectBase class for common support aspects of the configuration process.
Parameters: - name – the name of the configuration instance
- compiler – specify which compiler to use (default: distutils)
- tmpdir – specify a temp-dir to use
- verbose – explain the process as it goes
- dry_run – do not actually do the testing (default: False)
- debug – engage debug infra (default: False)
Notes
Harvests distutils heavily to setup the tooling infra.
-
add_macro(macro, macro_value, config_value=None, quoted=False)[source]¶ Add a C-Pre-Procesor macro or define to the catalogue.
Parameters: - macro – name of the macro
- macro_value – value to assign
- config_value – value to add to the ‘config’ catalogue if different from macro_value
- quoted – put the macro_value into double-quotes
Returns: Nothing
-
check_decl(decl, header, includes=None, include_dirs=None, main=None)[source]¶ Verify a declaration is available in a header file.
Parameters: - decl – name of function to check in a library
- header – header file to inspect
- includes – optional list of headers to add after the system headers
- include_dirs – optional directories to add to the build path
- main – optional extra code lines for the main() function
Returns: boolean – True if the declaration is available.
Notes
Equivalent to AC_CHECK_DECL.
-
check_func_fork(fcn='fork')[source]¶ Inspect the system for unix fork function.
Parameters: fcn – supply the ‘fork’ function name (default: fork) Returns: True if available. Return type: boolean Notes
Emulates AC_FUNC_FORK
-
check_func_lstat()[source]¶ Check for the availability of lstat()
Parameters: None – Returns: True if available Return type: Boolean Notes
Emulate AC_FUNC_LSTAT
-
check_func_stat()[source]¶ Check for the availability of stat()
Parameters: None – Returns: True if available Return type: Boolean Notes
Emulate AC_FUNC_STAT
-
check_func_vfork()[source]¶ Inspect the system for unix vfork function.
Parameters: None. – Returns: True if available. Return type: boolean Notes
Emulates AC_FUNC_VFORK
-
check_getpw_r__draft()[source]¶ Check if getpw*_R() routines are POSIX-draft-like.
Parameters: None – Returns: True if available Return type: Boolean Notes
Emulates AC_FUNC_GETPW_R_DRAFT
-
check_getpw_r__posix()[source]¶ Check if getpw*_R() routines are POSIX-like.
Parameters: None – Returns: True if available Return type: Boolean Notes
Emulates AC_FUNC_GETPW_R_POSIX
-
check_header(header, includes=None, include_dirs=None, macros=None, pre_main=None, add_config=False)[source]¶ Check for the presence and usability of a set of headers.
Parameters: - headers – list of header file names to check
- includes – list of headers to add after the system headers
- include_dirs – directories to add to the build path
- macros – extra macros to define
- pre_main – lines of code to place before main()
- add_to_catalogue – optional - add to defaults
Returns: - boolean – True indicates the the successful inspection
of that particular header file.
Notes
Equivalent to AC_CHECK_HEADER
-
check_header_dirent()[source]¶ Inspect headers available which implement dirent.
Parameters: None – Returns: True if available. Return type: boolean Notes
Emulates AC_HEADER_DIRENT
-
check_header_sys_wait()[source]¶ Inspect the system’s availability of sys/wait.h
Parameters: None. – Returns: True if available. Return type: boolean Notes
Emulates AC_HEADER_SYS_WAIT
-
check_headers(headers, includes=None, include_dirs=None, macros=None, pre_main=None)[source]¶ Check for the presence and usability of a set of headers.
Parameters: - headers – list of header file names to check
- includes – list of headers to add after the system headers
- include_dirs – directories to add to the build path
- macros – extra macros to define
- pre_main – lines of code to place before main()
Returns: - listof booleans – True indicates the the successful inspection
of that particular header file.
Notes
Equivalent to AC_CHECK_HEADERS
-
check_lib(funcname, library=None, includes=None, include_dirs=None, libraries=None, library_dirs=None, msg_add_libs=False)[source]¶ Check for the presence and usability of a function in a library.
Parameters: - funcname – name of function to check in a library
- library – optional specific library to include
- includes – optional list of headers to add after the system headers
- include_dirs – optional directories to add to the build path
- libraries – optional list of libraries to add to the link command
- library_dirs – optional directories to add to the linker path
- msg_add_libs – optional report which libraries are being added to the output
Returns: - listof booleans – True indicates the the successful inspection
of that particular header file.
Notes
Equivalent to AC_CHECK_LIB
-
check_lib_link(funcname, library, includes=None, include_dirs=None, libraries=None, library_dirs=None)[source]¶ Verify which extra libraries are needed to link the given lib
Parameters: - funcname – name of function to check in a library
- library – optional specific library to include
- includes – optional list of headers to add after the system headers
- include_dirs – optional directories to add to the build path
- libraries – optional list of libraries to add to the link command
- library_dirs – optional directories to add to the linker path
Returns: - list of libs - libraries needed to link the function and lib.
- May return None when all linking fails
Notes
This has no specific autoconf counterpart.
-
check_member(type_name, member_name, includes=None, include_dirs=None)[source]¶ Inspect the system to see if it supports a specific C/C++ type-name
Parameters: - type_name – C/C++ type name or struct name
- member_name – structure member-name to check
- includes – optional - headers to add after the system headers
- include_dirs – optional - directories to add to the build path
Returns: True if available.
Return type: boolean
Notes
Emulate AC_CHECK_MEMBER
-
check_msg(item, item_in=None, extra=None)[source]¶ Common messaging routine to create autoconf style output.
Parameters: - item – name of item
- item_in – component it is inside
- extra – additional text
Returns: Nothing
-
check_msg_result(msg)[source]¶ Common message result in a similar format to autoconf.
Parameters: msg – message to display Returns: Nothing
-
check_stdc()[source]¶ Run a set of very basic checks on the most common items.
This will update the various catalogues with the results of checking the basic C infrastructure files
-
check_tool(tool, tool_args=None, verbose=True)[source]¶ Try to locate a tool.
Parameters: - tool – name of the tool
- tool_args – optional arguments for the tool
- verbose – add detail to the output
Returns: boolean – True if the tool is present
-
check_type(type_name, includes=None, include_dirs=None)[source]¶ Inspect the system to see if it supports a specific C/C++ type-name
Parameters: - type_name – C type-name to check for
- includes – optional - headers to add after the system headers
- include_dirs – optional - directories to add to the build path
Returns: True if available.
Return type: boolean
Notes
Emulate AC_CHECK_TYPES
-
check_type_pid_t()[source]¶ Inspect the system type name for pid_t.
Parameters: None. – Returns: True if available. Return type: boolean Notes
Emulates AC_TYPE_PID_T
-
check_type_signal()[source]¶ Inspect the system usage and type of signal.
Parameters: None. – Returns: True if available. Return type: boolean Notes
Emulates AC_TYPE_SIGNAL
-
check_type_size_t()[source]¶ Inspect the system type name for size_t.
Parameters: None. – Returns: True if available. Return type: boolean Notes
Emulates AC_TYPE_SIZE_T
-
check_use_system_extensions()[source]¶ Verify if the system uses standard system-extension definitions
Parameters: None – Returns: True if available. Return type: boolean Notes
Emulates AC_USE_SYSTEM_EXTENSIONS
-
generate_config_h(config_h, config_h_in)[source]¶ Generate a config.h format file based on the config.h.in template.
Parameters: - config_h – output filename
- config_h_in – input/template filename
-
generate_config_log(config_log)[source]¶ Write out a similar log file format to the config.log
Parameters: config_log – name of file to create
hostconf.backport module¶
Backport infrastructure to ensure older situations work correctly.
It turns out that older subprocess modules did not have the ‘run’ function. So, in effect, this is a backport of the run routine which will work in older systems. I’m modifying the package so that calls elsewhere to subprocess.run() don’t choke.
hostconf.config_errors module¶
Defining custom exception and error types for the configure process
-
exception
hostconf.config_errors.ConfigureError(message)[source]¶ Bases:
ExceptionSignal a fault in the configuration process.
Parameters: message – the message to pass up to the user
-
exception
hostconf.config_errors.ConfigureSystemHeaderFileError(headers, selection='one of')[source]¶ Bases:
hostconf.config_errors.ConfigureErrorSystem C-header files are not present
Parameters: - headers – list of headers
- selection – string indicating request (default: ‘one of’)
-
exception
hostconf.config_errors.ConfigureSystemLibraryError(fcn, test_libs)[source]¶ Bases:
hostconf.config_errors.ConfigureErrorSystem libraries do not contain adequate support.
Parameters: - fcn – name of function being checked
- test_libs – additional libraries inspected
Notes
It is assumed that the default system libraries are also checked.