Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Compile Python Packages with Library Compiler App

Note

MATLAB® Compiler SDK™ cannot compile MATLAB code that uses the MATLAB Python® interface.

To compile MATLAB code into a Python package:

  1. Open the Library Compiler app.

    1. On the toolstrip, select the Apps tab.

    2. Click the arrow at the far right of the tab to open the apps gallery.

    3. Click Library Compiler.

      Note

      You can also start the Library Compiler app using the libraryCompiler function.

  2. In the Application Type section of the toolstrip, select Python Package.

    Note

    If the Application Type section of the toolstrip is collapsed, expand it by clicking the down arrow.

  3. Specify the MATLAB files you want deployed in the package.

    1. In the Exported Functions section of the toolstrip, click the plus button.

      Note

      If the Exported Functions section of the toolstrip is collapsed, expand it by clicking the down arrow.

    2. In the file explorer that opens, locate and select one or more MATLAB files.

    3. Click Open to select the file and close the file explorer.

      The names of the selected files are added to the list and a minus button appears below the plus button. The name of the first file listed is used as the default application name and the default package name.

  4. Verify that the function defined in the selected files is properly mapped into a namespace.

  5. In the Packaging Options section of the toolstrip, specify how the installer will deliver the MATLAB Runtime with the package.

    Note

    If the Packaging Options section of the toolstrip is collapsed, expand it by clicking the down arrow.

    You can select one or both of the following options:

    • Runtime downloaded from web — Generates an installer that downloads the MATLAB Runtime installer from the web.

    • Runtime included in package — Generates an installer that includes the MATLAB Runtime installer.

    Note

    Selecting both options creates two installers.

    Regardless of the options selected the generated installer scans the target system to determine if there is an existing installation of the appropriate MATLAB Runtime. If there is not, the installer installs the MATLAB Runtime.

  6. Specify the name of any generated installers.

  7. In the Application Information and Additional Installer Options sections of the app, customize the look and feel of the generated installer.

    You can change the information used to identify the application data used by the installer:

    • Splash screen

    • Installer icon

    • Package version

    • Name and contact information of the package’s author

    • Brief summary of the package’s purpose

    • Detailed description of the package

    You can also change the default location into which the package is installed and provide some notes to the installer.

    All the provided information is displayed as the installer runs.

    For more information, see Customize the Installer.

  8. In the Files required for your application to run section of the app, verify that the files required by the deployed MATLAB functions are listed.

    Note

    These files are compiled into the generated binaries along with the exported files.

    In general, the built-in dependency checker will automatically populate this section with the appropriate files. However, if needed you can manually add any files it missed.

    For more information, see Manage Required Files in Compiler Project.

  9. In the Files installed for your end user section of the app, verify that any additional non-MATLAB files you want installed with the application are listed.

    Note

    These files are placed in the applications folder of the installation.

    This section automatically lists:

    • Generated package

    • Python setup script

    • Readme file

    You can manually add files to the list. Additional files can include documentation, sample data files, and examples to accompany the application.

    For more information, see Specify Files to Install with Application.

  10. Click the Settings button to customize the flags passed to the compiler and the folders to which the generated files are written.

  11. Click the Package button to compile the MATLAB code and generate any installers.

  12. Verify that the generated output contains:

    • for_redistribution — A folder containing the installer to distribute the package

    • for_testing — A folder containing the raw generated files to create the installer

    • for_redistribution_files_only — A folder containing only the files needed to redistribute the package

    • PackagingLog.txt — A log file generated by the compiler

Was this topic helpful?