Guide가이드

Set up each platform플랫폼별 준비

CPython reads its standard library from the file system. Each platform gets one there differently.CPython 은 표준 라이브러리를 파일 시스템에서 읽는다. 플랫폼마다 그것을 두는 방법이 다르다.

01Desktop데스크톱

Apply the Gradle plugin. Its stagePythonHome task downloads the matching CPython, verifies it against the release's SHA256SUMS, caches it for the whole machine, and sets PYTHONHOME on run and test. A PYTHONHOME you set yourself is never touched.Gradle 플러그인을 적용한다. stagePythonHome 태스크가 맞는 CPython 을 내려받아 릴리스의 SHA256SUMS 로 검증하고, 기기 전체용 캐시에 두고, run 과 test 에 PYTHONHOME 을 설정한다. 직접 설정한 PYTHONHOME 은 건드리지 않는다.

pythonBindings { stagePythonHome.set(false) }   // opt out

02AndroidAndroid

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        PythonBootstrap.initialize(this)
    }
}

The stdlib ships inside the APK and is unpacked to app-private storage on first launch (237–480 ms measured on API 26–36), then skipped by a stamp check (4–28 ms). The stamp is written last, so an interrupted copy is never mistaken for a complete one.stdlib 는 APK 안에 들어 있고 첫 실행에 앱 전용 저장소로 풀린다 (API 26–36 에서 237–480 ms 측정). 이후에는 스탬프 확인으로 건너뛴다 (4–28 ms). 스탬프를 마지막에 쓰므로 중단된 복사를 완료된 것으로 착각하지 않는다.

03iOSiOS

The CPython framework carries no stdlib, so PYTHONHOME must point at one. Simulator tests receive environment variables through the SIMCTL_CHILD_ prefix. Building requires macOS with Xcode.CPython 프레임워크에는 stdlib 가 없으므로 PYTHONHOME 이 stdlib 를 가리켜야 한다. 시뮬레이터 테스트는 SIMCTL_CHILD_ 접두사로 환경 변수를 받는다. 빌드에는 Xcode 가 있는 macOS 가 필요하다.

04Web (experimental)웹 (실험적)

The wasmJs target runs an Emscripten build of CPython in Node and the browser. There are no threads, so suspend upcalls are not available there.wasmJs 타깃은 Emscripten 으로 빌드한 CPython 을 Node 와 브라우저에서 돌린다. 스레드가 없으므로 그곳에서는 suspend 업콜을 쓸 수 없다.