Getting started시작하기

From an empty Kotlin Multiplatform module to a Python payload inside its artifacts, in five steps.

빈 Kotlin Multiplatform 모듈에서 산출물 안의 Python 페이로드까지, 다섯 단계.

1. Prerequisites1. 준비물

Need필요한 것Why이유
JDK 17+ and Gradle 8.9 (wrapper)JDK 17 이상, Gradle 8.9 (래퍼)The build itself.빌드 자체.
uv on PATHPATH 의 uvpypackpack installs dependencies with it.pypackpack 이 의존성 설치에 씁니다.
packpack:0.1.0 in Maven LocalMaven Local 의 packpack:0.1.0The plugin depends on pypackpack as a library.플러그인이 pypackpack 을 라이브러리로 씁니다.
Android SDK (ANDROID_HOME)Android SDK (ANDROID_HOME)Only if your module has an Android target.모듈에 Android 타깃이 있을 때만.
# in a pypackpack checkout
./gradlew :packpack:publishToMavenLocal

# in this repository
./gradlew :toolchain:publishToMavenLocal

The plugin is pre-release and resolved from mavenLocal(). Add mavenLocal() to pluginManagement.repositories in your settings.gradle.kts.

플러그인은 출시 전이며 mavenLocal() 에서 받습니다. settings.gradle.kts 의 pluginManagement.repositories 에 mavenLocal() 을 추가하세요.

2. A Python package2. Python 패키지

The plugin bundles a pypackpack package: a directory with a pyproject.toml and its code under src/main/. Platform-specific code can sit in src/android, src/ios and so on; the bundler overlays it.

플러그인이 번들링하는 것은 pypackpack 패키지입니다. pyproject.toml 이 있고 코드가 src/main/ 아래에 있는 디렉터리입니다. 플랫폼 전용 코드는 src/android, src/ios 등에 두면 번들러가 덮어씌웁니다.

sample/src/commonMain/python/
├── pyproject.toml
└── src/main/example_py/
    ├── __init__.py
    └── data/table.json      # data files travel with the modules

3. Apply the plugin3. 플러그인 적용

plugins {
    alias(libs.plugins.kotlin.multiplatform)
    alias(libs.plugins.android.application)
    id("org.thisisthepy.python.multiplatform") version "1.0.0-alpha"
}

python {
    compileSdk = "3.13"
    localLibraryPath = "src/commonMain/python"
    packaging {
        fileName = "sample"
    }
}

This is the repository's own sample/build.gradle.kts. Instead of localLibraryPath you can point sourceSets { commonMain { srcDirs(...) } } at the package.

이 저장소의 sample/build.gradle.kts 그대로입니다. localLibraryPath 대신 sourceSets { commonMain { srcDirs(...) } } 로 패키지를 가리켜도 됩니다.

4. Run it4. 실행

./gradlew -p sample packagePython            # installPythonDependencies → buildPython → zip
./gradlew -p sample stagePythonBundle        # copy python/ where each platform packages from
./gradlew -p sample tasks --group python     # everything the plugin registered

5. What you get5. 결과물

Path경로Contents내용
build/pythonBundle/python/ + resource-manifest.json, from pypackpackpypackpack 이 만든 python/ + resource-manifest.json
build/distributions/<fileName>.zipThe bundle, zipped번들의 zip
build/pythonStaging/desktop/python/Added to the desktop jar's resources데스크톱 jar 리소스에 추가됨
build/pythonStaging/android/python/Added to the APK's assets/APK 의 assets/ 에 추가됨
build/pythonStaging/ios/python/Staged; point an Xcode “Copy Bundle Resources” phase at it스테이징만 됨. Xcode “Copy Bundle Resources” 단계가 이곳을 가리키게 하세요

Next: give each target its own bundle in Platforms & build types.

다음: 플랫폼과 빌드 타입에서 타깃마다 번들을 따로 만드세요.