| 331 | } |
| 332 | |
| 333 | export async function downloadFilesInWorkPath({ |
| 334 | entrypoint, |
| 335 | workPath, |
| 336 | files, |
| 337 | meta = {}, |
| 338 | }: Pick<BuildOptions, 'workPath' | 'files' | 'meta'> & { |
| 339 | entrypoint: string | undefined; |
| 340 | }) { |
| 341 | debug('Downloading user files...'); |
| 342 | let downloadedFiles = await download(files, workPath, meta); |
| 343 | if (meta.isDev && entrypoint) { |
| 344 | const normalizedEntrypoint = entrypoint.endsWith('.py') |
| 345 | ? entrypoint |
| 346 | : `${entrypoint}.py`; |
| 347 | if ( |
| 348 | !hasProp(downloadedFiles, entrypoint) && |
| 349 | !hasProp(downloadedFiles, normalizedEntrypoint) |
| 350 | ) { |
| 351 | throw new NowBuildError({ |
| 352 | code: 'PYTHON_ENTRYPOINT_NOT_FOUND', |
| 353 | message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`, |
| 354 | link: PYTHON_ENTRYPOINT_DOCS_URL, |
| 355 | action: 'Learn More', |
| 356 | }); |
| 357 | } |
| 358 | |
| 359 | // Old versions of the CLI don't assign this property |
| 360 | const { devCacheDir = join(workPath, '.now', 'cache') } = meta; |
| 361 | // Replace dots in the entrypoint basename with underscores so the cache |
| 362 | // directory name doesn't collide with the entrypoint file itself. |
| 363 | const cacheKey = basename(entrypoint).replace(/\./g, '_'); |
| 364 | const destCache = join(devCacheDir, cacheKey); |
| 365 | await download(downloadedFiles, destCache); |
| 366 | downloadedFiles = await glob('**', destCache); |
| 367 | workPath = destCache; |
| 368 | } |
| 369 | return workPath; |
| 370 | } |
| 371 | |
| 372 | interface TargetPlatform { |
| 373 | /** uv-compatible platform triple, or undefined to use the host. */ |