Python Package Compiler
Description
The Python Package Compiler packages MATLAB® programs into Python® packages that you can integrate into Python applications. The interactive menus and dialog boxes used in the compiler
apps build compiler.build commands that are customized to your
specification.
Compiler app advantages include:
You can perform deployment tasks with a single intuitive interface.
You can organize your files in a MATLAB project.
Your project state persists between sessions.
You can load previously stored compiler tasks from a prepopulated menu.
You can package applications with an installer for distribution.
For more information, see Target-Specific Compiler Apps for MATLAB Code Deployment.
Open the Python Package Compiler App
MATLAB toolstrip: On the Apps tab, under Application Deployment, click the app icon.
MATLAB command prompt: Enter
pythonPackageCompiler.
Parameters
Files implementing MATLAB functions. Files must have one of the following extensions:
.m, .p, .mlx, or
.mexa64.
All files must be located in the project root folder to be added to the
project. To add MATLAB functions to the deployable archive., click Add Exported
Function and select your MATLAB file. In the Project panel, the file you selected gains the labels
Design and Exported Function File.
Package Info
Name of the generated Java® package.
Version number of the package.
Name of application author.
Email address of the application author.
Name of company that created the application.
Summary description of the package, specified as a character vector or a string scalar.
Detailed description of the package, specified as a character vector or a string scalar.
Output Locations
Path to folder where the build artifacts are generated.
Path to folder where the installer is generated.
Build Settings
Obfuscate folder structures, file names, and user code in the deployable archive.
If you enable this property, then folder structures and file names in the
deployable archive are obfuscated from the end user, and user code and data
contained in .m, .mlapp,
.p, .mat, MLX, SFX, and MEX files are
placed into a user package within the archive. Additionally, all
.m files are converted to P-files before packaging.
During runtime, MATLAB code and data is decrypted and loaded directly from the user package rather than extracted to the file system. MEX files are temporarily extracted from the user package before being loaded.
To manually include additional file types in the user package, add each file
type in a separate extension tag to the file
.matlabroot/toolbox/compiler/advanced_package_supported_files.xml
The following are not supported:
verfunctionCalling external libraries such as DLLs
Out-of-process MATLAB Runtime (C++ shared library for MATLAB Data Array)
Out-of-process MEX file execution (
mexhost,feval,matlab.mex.MexHost)Before R2023b:
.matfiles other than v7.3
Enabling this option is equivalent to using mcc with
-j and -s specified.
If you do not enable this property, then the deployable archive is not obfuscated. This is the default behavior.
Files Required for Package to Run
Support packages to include in the deployable archive. The dependency analysis
process detects and includes the required support packages automatically. Only the
specified support packages are included. To list installed support packages or
those used by a specific file, see compiler.codetools.deployableSupportPackages.
Additional files and folders to include in the deployable archive. To add the contents of a folder, click Add Folder. To add an individual file, click Add File.
Additional files to include in the deployable archive. The dependency analysis process detects and includes required data files automatically unless Automatically include data files that are provided as inputs to functions such as load and fopen is disabled.
To view the file analysis results, click View Analysis. To perform the dependency analysis process again, click Reanalyze.
Automatically include data files in the deployable archive.
If you enable this property, then data files that you provide as inputs to certain functions (such as
loadandfopen) are automatically included in the deployable archive. This is the default option.If you disable this property, then you must add data files to the package in the Custom Requirements section.
Samples
Generate and modify sample MATLAB files, which are compiled into Python code that demonstrates how to call a MATLAB exported function in the target language.
For each MATLAB sample file you include during packaging, a sample application in
the target language is generated in a folder named samples.
These samples are also included in the installer.
To upload a MATLAB script you have already written, click Add existing sample.
To generate a new MATLAB sample file, click Create new sample. This opens up a MATLAB script for you to edit. After packaging, the generated sample code calls your exported function using the same arguments as in the sample MATLAB script.
For more information, see Create Sample Code to Call Exported Function.
Installer Details
MATLAB Runtime delivery option, specified as one of the following.
Fetch MATLAB Runtime from mathworks.com during application installation — Option for the installer to download MATLAB Runtime from the MathWorks® website during application installation. This option is the default behavior.
Include MATLAB Runtime in application installer for offline installation — Option to include MATLAB Runtime within the installer so that it can be installed during application installation without connecting to the MathWorks website. Use this option if you think your end user might not have access to the internet.
Do not include MATLAB Runtime in application installer — Option to not install MATLAB Runtime during application installation. Use this option if you think your end user will install MATLAB Runtime using another method. (since R2024a)
Note
If you use either the Fetch or Include option, the full MATLAB Runtime will be installed. To create a minimal MATLAB Runtime installer that can run one or more specific MATLAB Runtime applications, see compiler.runtime.customInstaller. (since R2024b)
Name of the generated installer.
Path to folder where the application will be installed. The folder is located in the %ProgramFiles% folder of the target machine.
Notes about additional requirements for using the application.
Image file used as the installer splash screen, specified as a character vector or a string scalar. The splash screen icon will be resized to 400 pixels by 400 pixels.
Image file used as the icon for the installer.
Image file used as the installer logo, specified as a character vector or a string scalar. The logo will be resized to 112 pixels by 290 pixels.
Version History
Introduced in R2025aIn R2024b and earlier releases, you can generate Python packages using the Library Compiler. Starting in R2025a, use the Python Package Compiler to create Python packages.
In R2024b and earlier releases, the compiler apps generate output files in the
folders for redistribution, for
redistribution_files_only, and for testing. Starting in
R2025a, the compiler apps generate output files in a folder named after the compiler
task.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)