Skip to content

Commit 43ddf3e

Browse files
committed
feat: Add poetry-core support
1 parent c911845 commit 43ddf3e

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/python/supply/supply.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,15 @@ func (s *Supplier) InstallCommonBuildDependencies() error {
756756
return fmt.Errorf("could not install build-time dependency %s: %v", dep, err)
757757
}
758758
}
759+
760+
if err := s.Installer.InstallOnlyVersion("poetry-core", tempPath); err != nil {
761+
return fmt.Errorf("could not prepare build-time dependency poetry-core: %v", err)
762+
}
763+
s.Log.Info("Installing build-time dependency poetry-core (bootstrap)")
764+
if err := s.runPipInstall(tempPath, "--no-build-isolation"); err != nil {
765+
return fmt.Errorf("could not bootstrap-install poetry-core: %v", err)
766+
}
767+
759768
return nil
760769
}
761770

src/python/supply/supply_test.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,12 @@ MarkupSafe==2.0.1
633633

634634
Describe("InstallCommonBuildDependencies", func() {
635635
Context("successful installation", func() {
636-
It("runs command to install wheel and setuptools", func() {
636+
It("runs command to install wheel, setuptools and poetry-core", func() {
637637
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
638638
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")
639639
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")
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

641643
Expect(supplier.InstallCommonBuildDependencies()).To(Succeed())
642644
})
@@ -652,6 +654,27 @@ MarkupSafe==2.0.1
652654
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not install build-time dependency wheel: some-pip-error"))
653655
})
654656
})
657+
658+
Context("poetry-core preparation fails", func() {
659+
It("returns a useful error message", func() {
660+
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
661+
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")
662+
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")
663+
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps").Return(fmt.Errorf("prepare-error"))
664+
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not prepare build-time dependency poetry-core: prepare-error"))
665+
})
666+
})
667+
668+
Context("poetry-core bootstrap fails", func() {
669+
It("returns a useful error message", func() {
670+
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
671+
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")
672+
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")
673+
mockInstaller.EXPECT().InstallOnlyVersion("poetry-core", "/tmp/common_build_deps")
674+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation").Return(fmt.Errorf("poetry-error"))
675+
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not bootstrap-install poetry-core: poetry-error"))
676+
})
677+
})
655678
})
656679

657680
Describe("CreateDefaultEnv", func() {

0 commit comments

Comments
 (0)