| 509 | } |
| 510 | |
| 511 | func (p *Port) InstallFromSource(options InstallOptions) error { |
| 512 | // Reset at top-level entry. |
| 513 | if p.Parent == "" { |
| 514 | visitedPorts = map[string]bool{} |
| 515 | } |
| 516 | |
| 517 | // Clone or download source of all repos. |
| 518 | if err := p.cloneAllRepos(); err != nil { |
| 519 | return err |
| 520 | } |
| 521 | |
| 522 | // Check tools for all ports. |
| 523 | if err := p.checkAllTools(); err != nil { |
| 524 | return err |
| 525 | } |
| 526 | |
| 527 | // Check if cpython version conflicts with venv version defined in celer.toml |
| 528 | if p.Parent == "" { |
| 529 | if err := p.checkCPythonVersionConflict(); err != nil { |
| 530 | return err |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | // Pre-warm meta cache: compute GenPortTomlString for all transitive deps |
| 535 | // in parallel, so the serial buildMeta recursion hits cache on every port. |
| 536 | if err := p.preWarmMetaCache(); err != nil { |
| 537 | return err |
| 538 | } |
| 539 | |
| 540 | // Setup platform. |
| 541 | if err := p.ctx.Platform().Setup(); err != nil { |
| 542 | return err |
| 543 | } |
| 544 | |
| 545 | // Install all dependencies for current port. |
| 546 | if err := p.installAllDependencies(options); err != nil { |
| 547 | return err |
| 548 | } |
| 549 | |
| 550 | // Prepare dependencies to tmp/deps before build it, below are conditions: |
| 551 | // 1. It's a dependency project and it has its own dependencies. |
| 552 | // 2. It's a top project, build with --force, and it has its own dependencies. |
| 553 | // 3. It's a top project, it has its own dependencies but is not configured yet, even not build with --force. |
| 554 | haveDependencies := len(p.MatchedConfig.Dependencies) > 0 || len(p.MatchedConfig.DevDependencies) > 0 |
| 555 | isTopProject := p.Parent == "" |
| 556 | if haveDependencies && (!isTopProject || (isTopProject && (options.Force || !p.MatchedConfig.Configured()))) { |
| 557 | color.Printf(color.Title, "\n[prepare dependencies: %s]\n", p.NameVersion()) |
| 558 | preparedTmpDeps = map[string]bool{} |
| 559 | if err := p.prepareTmpDeps(); err != nil { |
| 560 | return err |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | // Firstly, install to package dir. |
| 565 | if err := p.doInstallFromSource(); err != nil { |
| 566 | return err |
| 567 | } |
| 568 | |