Class PythonEmbedExtension

java.lang.Object
io.github.howtis.pythonembed.gradle.PythonEmbedExtension

public abstract class PythonEmbedExtension extends Object
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 Details

    • PythonEmbedExtension

      public PythonEmbedExtension()
  • Method Details

    • getPythonVersion

      public abstract org.gradle.api.provider.Property<String> getPythonVersion()
      Python version to use (default: "3.12").
    • getPackages

      public abstract org.gradle.api.provider.ListProperty<String> getPackages()
      List of pip packages to install (default: empty).
    • getPipIndexUrl

      public abstract org.gradle.api.provider.Property<String> getPipIndexUrl()
      Optional pip index URL (e.g., PyTorch CUDA index).
    • getPipExtraArgs

      public abstract org.gradle.api.provider.ListProperty<String> 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-venv and 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

      public abstract org.gradle.api.provider.Property<String> getRequirementsFile()
      Optional path to requirements.txt (relative to project root).
    • getPyprojectTomlFile

      public abstract org.gradle.api.provider.Property<String> getPyprojectTomlFile()
      Optional path to pyproject.toml (relative to project root).