package pyml
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=c1e979751ef933635ae6d7f69e1638a3accfd082b0b3a364c4305eb268a67f73af26e321beef4cf3b99ab2fe35ab642c03b005ad620b0268e22b4a09b6f7c1c0
doc/pyml/Py/index.html
Module PySource
OCaml Interface for Python.
Call initialize () first.
val initialize :
?library_name:string ->
?interpreter:string ->
?version:int ->
?minor:int ->
?verbose:bool ->
?debug_build:bool ->
unit ->
unitinitialize ~interpreter ~version ~minor ~verbose ~debug_build () finds and loads the Python library. This function should be called before any other functions, except if explicitely mentioned. If library_name is given, it is used as the path for the library to be loaded: in this case, version parameters are ignored. If library_name is not given, the library is searched as described below. version should specify the major version number of Python (2 or 3). minor should specify the minor version number. If no version number is given, the version of Python is determined by the output of the shell command python --version. If an interpreter executable name is given, this executable is used in place of python in the previous command line. The library is searched by using pkg-config if available, by considering system paths, and in the directory ../lib relatively to the directory where the python executable is. If the library has been statically linked with the executable, it will be used. When verbose is true (default: false), library filenames that are tried to be loaded are printed on standard error. debug_build specifies whether the Python library is a debug build: if the argument is left unspecified, debug build is detected automatically.
finalize () unloads the library. No other functions except initialize () should be called afterwards.
on_finalize f registers f () to be executed when finalize is executed.
is_initialized () returns true if the library is initialized (initialize () has been called and finalize () has not been called afterwards).
is_debug_build () returns true if the library is a debug build.
get_library_filename () returns Some filename where filename is the path to the Python library that has been loaded, or None if no Python library has been loaded (for example, if the library has been statically linked with the executable).
version () returns the version of the Python library. E.g. "3.5.1".
version_major () returns the major number (the first component) of the version of the Python library, either 2 or 3.
version_minor () returns the minor number (the second component) of the version of the Python library.
Either a filename or a channel. Channels suppose that the same C runtime has been used to compile both the Python library and the OCaml runtime. Warning: using channels is unsafe if runtimes differ (can lead to segmentation fault).
E (errtype, errvalue) is a Python error. errtype is the type of the exception. errvalue is the value.
The value NULL of the C Python API. null is useful for calling directly the functions of Pywrappers module. The value should not appear when using the functions of the Py module. This value is guaranteed to be the unique value associated to NULL.
Py.is_null v is true if and only if v is NULL. Since Py.none is guaranteed to be the unique value associated to NULL, Py.is_null v is equivalent to v == Py.null.
check_not_null v checks that v is not null and returns v. Raises the current Python error as exception otherwise.
The value None of Python. This value is guaranteed to be the unique value associated to None.
Py.is_none v is true if and only if v is None. Since Py.none is guaranteed to be the unique value associated to None, Py.is_none v is equivalent to v == Py.none.
Sets the program name (by default, Sys.argv.(0)). The function can be called before initialize () and the value is preserved from one initialization to the other.
Sets the path of the Python home. The function can be called before initialize () and the value is preserved from one initialization to the other.
Adds a path to Python search path. The function can be called before initialize () and the value is preserved from one initialization to the other.
Gets the program name (by default, Sys.argv.(0)). The function can be called before initialize ().
Gets the path of the Python home. The function can be called before initialize ().
Wrapper for Py_GetProgramFullPath.
Wrapper for Py_GetPrefix.
Wrapper for Py_GetExecPrefix.
Wrapper for Py_GetPath.
Wrapper for Py_GetVersion.
Wrapper for Py_GetPlatform.
Wrapper for Py_GetCopyright.
Wrapper for Py_GetCompiler.
Wrapper for Py_GetBuildInfo.
Interface for Python values of type Int if Python 2, Long if Python 3.
Represents an exception to be set with Err.set_error in a callback.
Represents an exception with traceback information to be set with Err.restore.
Equivalent to Import.import_module.
Equivalent to Import.import_module_opt.
Interface for Python values of type Bytes. With Python 2, aliases for String.
set_argv argv set Python's sys.argv.
last_value () returns the last value that was computed in the toplevel. We have Py.last_value = Py.Module.find (Py.Module.builtins ()) "_".
This printer pretty-prints E (ty, value) exceptions. It is automatically registered to Printexc.register_printer.
val compile :
source:string ->
filename:string ->
?dont_inherit:bool ->
?optimize:[ `Default | `Debug | `Normal | `RemoveDocstrings ] ->
[ `Exec | `Eval | `Single ] ->
Object.tcompile ~source ~filename ?dont_inherit ?optimize mode returns the bytecode obtained by compiling ~source. It is a wrapper for the built-in function compile(). GitHub issue #25