Class PythonEmbedExtension
java.lang.Object
io.github.howtis.pythonembed.gradle.PythonEmbedExtension
Configuration extension for the pythonEmbed plugin.
pythonEmbed {
pythonVersion = '3.12'
packages = ['numpy==1.26.4', 'torch==2.4.0']
pipIndexUrl = 'https://download.pytorch.org/whl/cu118'
pipExtraArgs = ['--extra-index-url', 'https://example.com/simple']
venvOutputDir = layout.buildDirectory.dir('my-venv')
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.ListProperty<String>List of pip packages to install (default: empty).abstract org.gradle.api.provider.ListProperty<String>Optional extra pip install arguments (e.g., --extra-index-url, -f).abstract org.gradle.api.provider.Property<String>Optional pip index URL (e.g., PyTorch CUDA index).abstract org.gradle.api.provider.Property<String>Optional path to pyproject.toml (relative to project root).abstract org.gradle.api.provider.Property<String>Python version to use (default: "3.12").abstract org.gradle.api.provider.Property<String>Optional path to requirements.txt (relative to project root).abstract org.gradle.api.provider.Property<String>Target OS for cross-compilation.abstract org.gradle.api.file.DirectoryPropertyOutput directory for the Python virtual environment.
-
Constructor Details
-
PythonEmbedExtension
public PythonEmbedExtension()
-
-
Method Details
-
getPythonVersion
Python version to use (default: "3.12"). -
getPackages
List of pip packages to install (default: empty). -
getPipIndexUrl
Optional pip index URL (e.g., PyTorch CUDA index). -
getPipExtraArgs
Optional extra pip install arguments (e.g., --extra-index-url, -f). -
getVenvOutputDir
public abstract org.gradle.api.file.DirectoryProperty getVenvOutputDir()Output directory for the Python virtual environment.If not set, defaults to
build/python-venvand the venv is embedded in the JAR as a classpath resource. If set to a path outside the build directory, the venv is kept external and referenced via a generated properties file at runtime. -
getRequirementsFile
Optional path to requirements.txt (relative to project root). -
getPyprojectTomlFile
Optional path to pyproject.toml (relative to project root). -
getTargetOs
Target OS for cross-compilation. When set, the plugin downloads the python-build-standalone archive for the specified OS instead of the build OS. This only affects the bundled Python path (system Python always uses the build OS).Valid values:
"windows","linux","macos"(case-insensitive). When not set, the build OS is auto-detected.
-