Using the library라이브러리로 쓰기

The same work, called from Kotlin: how toolchain and any JVM build use pypackpack.

같은 작업을 Kotlin 에서 호출하기: toolchain 과 모든 JVM 빌드가 pypackpack 을 쓰는 방법.

Depend on it의존성 추가

Published to Maven Local only for now. Publish it from a checkout, then depend on it:

지금은 Maven Local 에만 배포됩니다. 체크아웃에서 배포한 뒤 의존하세요.

./gradlew :packpack:publishToMavenLocal
repositories { mavenLocal() }
dependencies { implementation("org.thisisthepy.python.multiplatform:packpack:0.1.0") }

It needs a Java 21 runtime and is compiled with Kotlin apiVersion 1.9, so a Gradle 8.9+ build (Kotlin 1.9 stdlib) can load it.

Java 21 런타임이 필요하며, Kotlin apiVersion 1.9 로 컴파일되어 Gradle 8.9 이상 (Kotlin 1.9 stdlib) 빌드에서 읽힙니다.

Bundle a package패키지 번들링

This is the call toolchain makes for every variant:

toolchain 이 변형마다 하는 호출입니다.

val result = BundlerInterface.create(BundleType.RESOURCE).bundle(
    BundleRequest(
        packageDir = packageDir,            // pyproject.toml + src/main/…
        target = "aarch64-linux-android",
        buildType = "release",
        buildLevel = "bytecode",            // instant | bytecode
        outputDir = outputDir,
        overwrite = true,
        minSdk = 24,
        metaDirs = metaDirs,                // overlaid after src/<family>
        libDirs = libDirs,                  // e.g. build/crossenv/<triple>
        versionName = "1.0", versionCode = 1,
    )
)
val bundle = result.getOrElse { throw it }   // bundle.outputDir, bundle.manifestFile, bundle.fileCount

Install dependencies for a target타깃용 의존성 설치

BackendInterface.create(BackendType.UV).installDependenciesToTarget(
    targetDir = "build/crossenv/arm64-apple-ios",
    pythonPlatform = "arm64-apple-ios",
    extraArgs = mapOf("python-version" to "3.14"),
    workingDir = projectDir,
    requirements = listOf("pillow>=11", "six"),   // null: -r pyproject.toml
)

With requirements, the specifiers go to uv as arguments and workingDir needs no pyproject.toml. An empty list is a successful no-op.

requirements 를 주면 지정자가 uv 인자로 넘어가고, workingDir 에 pyproject.toml 이 없어도 됩니다. 빈 목록은 성공하는 no-op 입니다.

Two rules the API keepsAPI 가 지키는 두 규칙

Rule규칙Why이유
Backend calls take an explicit workingDir or installDir.백엔드 호출은 workingDir 나 installDir 를 명시적으로 받습니다.A Gradle daemon's user.dir is not your project.Gradle 데몬의 user.dir 는 내 프로젝트가 아닙니다.
Anything unimplemented returns a failed Result.구현되지 않은 것은 실패한 Result 를 돌려줍니다.A caller can tell "not yet" from "done" without reading logs.호출자가 로그를 읽지 않고도 "아직" 과 "완료" 를 구분합니다.