build-exe-for-python-sdk-native-pty.ts 858 B

1234567891011121314151617181920212223
  1. /** Resolve the native node-pty input used by the Python SDK runtime builder. */
  2. import { existsSync } from 'node:fs'
  3. import { join } from 'node:path'
  4. /**
  5. * Prefer the workflow's manylinux build and fall back to node-pty's target prebuild.
  6. * @param packageDirectory - installed node-pty package directory.
  7. * @param arch - Linux target architecture.
  8. * @returns the existing addon path.
  9. */
  10. export function resolveLinuxNodePtyAddon(
  11. packageDirectory: string,
  12. arch: 'x64' | 'arm64',
  13. ): string {
  14. const built = join(packageDirectory, 'build', 'Release', 'pty.node')
  15. if (existsSync(built)) return built
  16. const prebuilt = join(packageDirectory, 'prebuilds', `linux-${arch}`, 'pty.node')
  17. if (existsSync(prebuilt)) return prebuilt
  18. throw new Error(
  19. `build-exe-for-python-sdk: node-pty addon is absent from both ${built} and ${prebuilt}.`,
  20. )
  21. }