pyufunc.cvt_py_to_dll#

pyufunc.cvt_py_to_dll(py_file, output_dir='')#

Convert a Python file to a DLL using Cython and setuptools.

Parameters:
  • py_file (str) – The path to the Python file to convert. It should have a .py or .pyx extension.

  • output_dir (str) – The directory where the DLL should be saved. Default is current directory.

Raises:

Notes

  • The function uses Cython to compile the Python file into a shared library (DLL).

  • It creates a temporary directory to perform the conversion and cleans it up afterwards.

  • The output DLL will have the same name as the input Python file (without extension).

Example

>>> import pyufunc as pf
>>> pf.cvt_py_to_dll('example.py', output_dir='output_directory')
>>> # This will convert 'example.py' to 'example.pyd (Windows)/example.so (Linux or Macos)'.
>>> import example # Now you can import the compiled module as a regular Python module.
Returns:

True if the conversion was successful, False otherwise.

Return type:

bool