Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/python/supply/supply.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,14 @@ func (s *Supplier) InstallCommonBuildDependencies() error {
if err := s.Installer.InstallOnlyVersion("pip", tempPath); err != nil {
return err
}
if err := s.Installer.InstallOnlyVersion("flit-core", tempPath); err != nil {
return err
}

s.Log.Info("Installing build-time dependency flit-core (bootstrap)")
args := []string{tempPath, "--no-build-isolation"}
if err := s.runPipInstall(args...); err != nil {
return fmt.Errorf("could not bootstrap-install flit-core: %v", err)
for _, dep := range []string{"flit-core", "poetry-core"} {
if err := s.Installer.InstallOnlyVersion(dep, tempPath); err != nil {
return fmt.Errorf("could not prepare build-time dependency %s: %v", dep, err)
}
s.Log.Info("Installing build-time dependency %s (bootstrap)", dep)
if err := s.runPipInstall(tempPath, "--no-build-isolation"); err != nil {
return fmt.Errorf("could not bootstrap-install %s: %v", dep, err)
}
}

for _, dep := range []string{"wheel", "setuptools"} {
Expand All @@ -764,6 +764,8 @@ func (s *Supplier) InstallCommonBuildDependencies() error {
return fmt.Errorf("could not install build-time dependency %s: %v", dep, err)
}
}


return nil
}

Expand Down
41 changes: 33 additions & 8 deletions src/python/supply/supply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,31 +633,56 @@ MarkupSafe==2.0.1

Describe("InstallCommonBuildDependencies", func() {
Context("successful installation", func() {
It("bootstraps flit-core, wheel and setuptools", func() {
It("bootstraps flit-core, poetry-core, wheel and setuptools", func() {
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
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")
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")

Expect(supplier.InstallCommonBuildDependencies()).To(Succeed())
})
})

Context("flit-core bootstrap fails", func() {
It("returns a useful error message", func() {
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("bootstrap-error"))
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install flit-core: bootstrap-error"))
Context("flit-core bootstrap fails", func() {
It("returns a useful error message", func() {
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("bootstrap-error"))
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install flit-core: bootstrap-error"))
})
})

Context("poetry-core preparation fails", func() {
It("returns a useful error message", func() {
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps").Return(fmt.Errorf("prepare-error"))
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not prepare build-time dependency poetry-core: prepare-error"))
})
})

Context("poetry-core bootstrap fails", func() {
It("returns a useful error message", func() {
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("poetry-error"))
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install poetry-core: poetry-error"))
})
})
})

Context("wheel installation fails", func() {
It("returns a useful error message", func() {
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps")
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
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"))
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not install build-time dependency wheel: some-pip-error"))
})
Expand Down
Loading