Skip to content

Commit 0666762

Browse files
committed
feat: Bundle the flit-core and poetry-core installation
1 parent b16b486 commit 0666762

2 files changed

Lines changed: 30 additions & 33 deletions

File tree

src/python/supply/supply.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -747,14 +747,14 @@ func (s *Supplier) InstallCommonBuildDependencies() error {
747747
if err := s.Installer.InstallOnlyVersion("pip", tempPath); err != nil {
748748
return err
749749
}
750-
if err := s.Installer.InstallOnlyVersion("flit-core", tempPath); err != nil {
751-
return err
752-
}
753-
754-
s.Log.Info("Installing build-time dependency flit-core (bootstrap)")
755-
args := []string{tempPath, "--no-build-isolation"}
756-
if err := s.runPipInstall(args...); err != nil {
757-
return fmt.Errorf("could not bootstrap-install flit-core: %v", err)
750+
for _, dep := range []string{"flit-core", "poetry-core"} {
751+
if err := s.Installer.InstallOnlyVersion(dep, tempPath); err != nil {
752+
return fmt.Errorf("could not prepare build-time dependency %s: %v", dep, err)
753+
}
754+
s.Log.Info("Installing build-time dependency %s (bootstrap)", dep)
755+
if err := s.runPipInstall(tempPath, "--no-build-isolation"); err != nil {
756+
return fmt.Errorf("could not bootstrap-install %s: %v", dep, err)
757+
}
758758
}
759759

760760
for _, dep := range []string{"wheel", "setuptools"} {
@@ -765,13 +765,6 @@ func (s *Supplier) InstallCommonBuildDependencies() error {
765765
}
766766
}
767767

768-
if err := s.Installer.InstallOnlyVersion("poetry-core", tempPath); err != nil {
769-
return fmt.Errorf("could not prepare build-time dependency poetry-core: %v", err)
770-
}
771-
s.Log.Info("Installing build-time dependency poetry-core (bootstrap)")
772-
if err := s.runPipInstall(tempPath, "--no-build-isolation"); err != nil {
773-
return fmt.Errorf("could not bootstrap-install poetry-core: %v", err)
774-
}
775768

776769
return nil
777770
}

src/python/supply/supply_test.go

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -633,41 +633,33 @@ MarkupSafe==2.0.1
633633

634634
Describe("InstallCommonBuildDependencies", func() {
635635
Context("successful installation", func() {
636-
It("bootstraps flit-core, wheel and setuptools", func() {
636+
It("bootstraps flit-core, poetry-core, wheel and setuptools", func() {
637637
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
638638
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
639639
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
640+
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps")
641+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
640642
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps")
641643
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "setuptools", "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps")
642644

643645
Expect(supplier.InstallCommonBuildDependencies()).To(Succeed())
644646
})
645647
})
646648

647-
Context("flit-core bootstrap fails", func() {
648-
It("returns a useful error message", func() {
649-
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
650-
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
651-
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("bootstrap-error"))
652-
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install flit-core: bootstrap-error"))
653-
})
654-
})
655-
656-
Context("wheel installation fails", func() {
649+
Context("flit-core bootstrap fails", func() {
657650
It("returns a useful error message", func() {
658651
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
659652
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
660-
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
661-
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps").Return(fmt.Errorf("some-pip-error"))
662-
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not install build-time dependency wheel: some-pip-error"))
653+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("bootstrap-error"))
654+
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install flit-core: bootstrap-error"))
663655
})
664656
})
665657

666658
Context("poetry-core preparation fails", func() {
667659
It("returns a useful error message", func() {
668660
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
669-
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps")
670-
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "setuptools", "--no-index", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps")
661+
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
662+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
671663
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps").Return(fmt.Errorf("prepare-error"))
672664
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not prepare build-time dependency poetry-core: prepare-error"))
673665
})
@@ -676,13 +668,25 @@ MarkupSafe==2.0.1
676668
Context("poetry-core bootstrap fails", func() {
677669
It("returns a useful error message", func() {
678670
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
679-
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps")
680-
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "setuptools", "--no-index", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps")
671+
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
672+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
681673
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps")
682674
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("poetry-error"))
683675
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install poetry-core: poetry-error"))
684676
})
685677
})
678+
679+
Context("wheel installation fails", func() {
680+
It("returns a useful error message", func() {
681+
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
682+
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
683+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
684+
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps")
685+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
686+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "wheel", "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", "--find-links=/tmp/common_build_deps").Return(fmt.Errorf("some-pip-error"))
687+
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not install build-time dependency wheel: some-pip-error"))
688+
})
689+
})
686690
})
687691

688692
Describe("CreateDefaultEnv", func() {

0 commit comments

Comments
 (0)