Platforms & build types플랫폼과 빌드 타입

Build one bundle per target and per build type.

타깃과 빌드 타입마다 번들을 하나씩 만듭니다.

Declare platforms플랫폼 선언

python {
    android("android") {
        androidSdk = 24                           // forwarded to pypackpack as minSdk
    }
    listOf(androidArm64(), androidX64())

    ios {
        iosSdk = 14
    }
    listOf(iosArm64(), iosSimulatorArm64())

    desktop()
    listOf(macosArm64(), linuxX64(), mingwX64())
}

Calling a variant function declares that variant; listOf(...) only groups the calls. A variant called without its platform block gets that platform with its defaults.

변형 함수를 부르는 것이 곧 그 변형을 선언하는 것이고, listOf(...) 는 호출을 묶어 보여 줄 뿐입니다. 플랫폼 블록 없이 부른 변형은 그 플랫폼의 기본값을 씁니다.

Variant변형pypackpack triplepypackpack 트리플Kotlin targetKotlin 타깃
androidArm64aarch64-linux-androidandroidNativeArm64
androidX64x86_64-linux-androidandroidNativeX64
iosArm64arm64-apple-iosiosArm64
iosX64x86_64-apple-ios-simulatoriosX64
iosSimulatorArm64arm64-apple-ios-simulatoriosSimulatorArm64
macosX64 · macosArm64x86_64-apple-darwin · aarch64-apple-darwinsame name같은 이름
linuxX64 · linuxArm64x86_64-unknown-linux-gnu · aarch64-unknown-linux-gnusame name같은 이름
mingwX64x86_64-pc-windows-msvcmingwX64

androidArm32() and androidX86() do not compile: Android follows CPython's official support (PEP 738), which is arm64 and x86_64 only. A declared variant whose Kotlin target your kotlin { } block does not enable produces a warning.

androidArm32() 와 androidX86() 은 컴파일되지 않습니다. 안드로이드는 CPython 공식 지원(PEP 738)을 따르며, 그 범위는 arm64 와 x86_64 뿐입니다. kotlin { } 블록에서 켜지 않은 Kotlin 타깃의 변형을 선언하면 경고가 납니다.

Build types빌드 타입

python {
    buildTypes {
        getByName("debug")   { compileLevel = "instant" }
        getByName("release") { compileLevel = "bytecode" }
    }
}

Only debug and release exist. useCodeMinifier, excludeMetaclass and enableCodePush are release-only: setting them on debug throws.

debug 와 release 만 있습니다. useCodeMinifier, excludeMetaclass, enableCodePush 는 release 전용이며 debug 에 설정하면 예외가 납니다.

compileLevelcompileLevelMeaning의미Today지금
instant (or blank)(또는 빈 값).py only.py 만implemented구현
bytecodedebug: .py + .pyc; release: .pyc onlydebug: .py + .pyc, release: .pyc 만implemented구현
nativenative code only네이티브 코드만planned (pypackpack#19)계획 (pypackpack#19)
mixedyour code as bytecode, libraries native내 코드는 바이트코드, 라이브러리는 네이티브planned (pypackpack#19)계획 (pypackpack#19)

bytecode compiles with the Python in a .venv at or above your package directory. installPythonDependencies leaves one there (uv add creates <package>/.venv) once you declare a dependency; otherwise run uv venv --python 3.14 in the package directory. Its minor version must match compileSdk, because a .pyc only loads on the CPython minor version that wrote it; a mismatch fails the variant. Without a declared compileSdk, or a pyvenv.cfg to read, the versions are not compared.

bytecode 는 패키지 디렉터리나 그 위의 .venv 에 있는 Python 으로 컴파일합니다. 의존성을 하나라도 선언하면 installPythonDependencies 가 그것을 만들어 둡니다(uv add 가 <package>/.venv 를 만듭니다). 그렇지 않으면 패키지 디렉터리에서 uv venv --python 3.14 를 실행하세요. 그 마이너 버전은 compileSdk 와 같아야 합니다. .pyc 는 그것을 쓴 CPython 마이너 버전에서만 로드되기 때문이며, 다르면 그 변형이 실패합니다. compileSdk 를 선언하지 않았거나 읽을 pyvenv.cfg 가 없으면 버전을 비교하지 않습니다.

A planned level fails only its own variant's buildPython… task, so ./gradlew packagePython --continue still builds every other variant.

계획 단계의 레벨은 그 변형의 buildPython… 태스크만 실패시키므로, ./gradlew packagePython --continue 는 나머지 변형을 모두 빌드합니다.

Project flavors프로젝트 플레이버

python {
    androidArm64()
    projectFlavors {
        create("free")
        create("paid")
    }
}
// → buildPythonAndroidArm64FreeDebug, buildPythonAndroidArm64PaidDebug, …

Each flavor is crossed with every platform variant and build type, as in Android's product flavors. Put a flavor's own dependencies in a <flavor>Main source set. Staging takes one flavor: -Ppython.flavor=paid, or the first declared. Flavors need at least one platform variant.

플레이버마다 모든 플랫폼 변형과 빌드 타입이 곱해집니다(Android 의 product flavor 와 같습니다). 플레이버 고유 의존성은 <flavor>Main 소스셋에 둡니다. 스테이징은 플레이버 하나를 씁니다: -Ppython.flavor=paid, 없으면 처음 선언한 것. 플레이버에는 플랫폼 변형이 하나 이상 있어야 합니다.

Choosing the active build type활성 빌드 타입 고르기

Without platforms there are no per-variant task names to ask for, so a project property picks the build type. It defaults to debug; a name you did not declare fails the build.

플랫폼이 없으면 고를 변형 태스크 이름이 없으므로 프로젝트 속성으로 빌드 타입을 정합니다. 기본값은 debug 이고, 선언하지 않은 이름은 빌드를 실패시킵니다.

./gradlew packagePython -Ppython.buildType=release

The same property decides which variant's bundle is staged into your app: see Into the app.

같은 속성이 앱에 스테이징될 변형도 정합니다: 앱 안으로를 보세요.