suffixes
: can be used to force the file extension
by_code
setup_code
: code needed to prepare the filename_code
filename_code
: code that outputs a the DLL filename from
installation
dest_path
: target directory
when
:
jump to
The recommended way goes by filename. The
by_code
version is still in flux and depends on compile time importing code, making it vulernable to compile time issues in many ways.
- module-name: 'vosk'
dlls:
- from_filenames:
prefixes:
- 'libvosk'
anti-bloat:
- description: 'remove tests'
context: ''
module_code: 'from hello import world'
replacements_plain: ''
replacements_re: ''
replacements: ''
change_function:
'get_extension': 'un-callable'
append_result: ''
append_plain: ''
when: ''
If you want to replace code, for example to remove dependencies, you can do that here.
description
: description of what this
anti-bloat
does
context
:
module_code
: replace the entire code of a module with it
replacements_plain
: search an replace plain strings
replacements_re
: search an replace regular expressions
replacements
: search a plain string and replace with an
expression result
change_function
: replace the code of a function.
un-callable
removes the function
append_result
: append the result of an expression to module code
append_plain
: append plain text to the module code
when
:
jump to
coming soon
implicit-imports: - depends: - 'ctypes' pre-import-code: '' post-import-code: '' when: 'version("package_name") >= (1, 2, 1)'
depends
: modules that are required by this module
pre-import-code
: code to execute before a module is imported
post-import-code
: code to execute after a module is imported
when
:
jump to
In this example, environment variables needed to resolve the path of the Qt plugins and the fonts directory are used. This is only needed on Linux and on standalone, and here is how the standard configuration does it. And there there more mundane implicit requirements, that come from the package using an extension module and on the inside
cv2
.
- module-name: 'cv2' - depends: - 'cv2.cv2' - 'numpy' - 'numpy.core' - pre-import-code: - | import os os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = os.path.join(os.path.dirname(__file__), 'qt/plugins') os.environ['QT_QPA_FONTDIR'] = os.path.join(os.path.dirname(__file__), 'qt/fonts') when: 'linux and standalone'
options: checks: - description: 'fix crash' console: 'yes' macos_bundle: 'yes' macos_bundle_as_onefile: 'no' support_info: 'warning' when: 'macos'
If a module requires specific options, you can specify them here, to make sure the user is informed of them.
description
: description of what this does
console
: whether the console should be enabled. Choose between
yes
,
no
,
recommend
macos_bundle
: Choose between
yes
,
no
,
recommend
macos_bundle_as_onefile
: Choose between
yes
,
no
support_info
: Choose between
info
,
warning
,
error
when
:
jump to
On macOS, the popular
wx
toolkit will not work unless the application is a GUI program. The result is a crash without any information to the user. It also will not work unless it’s in a macOS bundle. So this configuration will make sure to warn or error out in case these modes are not enabled.
- module-name: 'wx' options: checks: - description: 'wx will crash in console mode during startup' console: 'yes' when: 'macos' - description: 'wx requires program to be in bundle form' macos_bundle: 'yes' when: 'macos'
import-hacks: - package-paths: - 'vtkmodules' package-dirs: - 'win32comext' find-dlls-near-module: - 'shiboken2' when: "True"
package-paths
:
package-dirs
:
find-dlls-near-module
:
coming soon
If this expression matches, the entry is executed, otherwise not. This expression is a normal string evaluated by Python’s eval function. Nuitka provides variables for this.
Example of an expression:
macos and python3_or_higher
These variables are currently available:
macos
:
True
if OS is MacOS
win32
:
True
if OS is Windows
linux
:
True
if OS is Linux
anaconda
:
True
if Anaconda Python used
debian_python
:
True
if Debian Python used
standalone
:
True
if standalone mode is activated
module_mode
:
True
if module mode is activated
before_python3
:
True
if Python 2 used
python3_or_higher
:
True
if Python 3 used
There are also more Python version specific ones. For each Python version supported by Nuitka there are the following:
python[major][minor]_or_higher
: e.g.
python310_or_higher
before_python[major][minor]
: e.g.
before_python310
The Anti-Bloat plugin provides you with additional variables. These are only available in anti-bloat.
use_setuptools
:
True
if
--noinclude-setuptools-mode
is not
set to
nofollow
or
error
use_pytest
:
True
if
--noinclude-pytest-mode
is not
set to
nofollow
or
error
use_unittest
:
True
if
--noinclude-unittest-mode
is not
set to
nofollow
or
error
use_ipython
:
True
if
--noinclude-IPython-mode
is not
set to
nofollow
or
error
use_dask
:
True
if
--noinclude-dask-mode
is not
set to
nofollow
or
error
All these are bools.
To check the version of a package there is the
version
function, which you simply pass the name to and you then get the version as a tuple. An example:
version('shapely') < (1, 8, 1)