pyccel.commands.console module

pyccel.commands.console module#

class pyccel.commands.console.MyParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]#

Bases: ArgumentParser

Custom argument parser for printing help message in case of an error. See http://stackoverflow.com/questions/4042452/display-help-message-with-python-argparse-when-script-is-called-without-any-argu

error(message: string)[source]#

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

pyccel.commands.console.pyccel() None[source]#

Pyccel console command.

The Pyccel console command allows translating Python files using Pyccel in a command-line environment. This function takes no parameters and sets up an argument parser for the Pyccel command line interface.

The command line interface requires a Python file to be specified, and it supports various options such as specifying the output language (C, Fortran, or Python), compiler settings, and flags for accelerators like MPI, OpenMP, and OpenACC. It also includes options for verbosity, debugging, and exporting compile information. Unless the user requires the process to stop after a specific stage, Pyccel will execute the full translation and compilation process until a C Python extension module is generated, which can then be imported in Python. In addition, if the input file contains an if __name__ == ‘__main__’: block, an executable will be generated for the corresponding block of code.