Skip to content

Commit d39ec59

Browse files
committed
feat: Add flit-core support
Signed-off-by: Pascal Zimmermann <pascal.zimmermann@theiotstudio.com>
1 parent c911845 commit d39ec59

4 files changed

Lines changed: 45 additions & 13 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
All pull request authors must have a Contributor License Agreement (CLA) on-file with us. Please sign the Contributor License Agreements for Cloud Foundry ([Individual or Corporate](https://www.cloudfoundry.org/community/cla/)) via the EasyCLA application when you submit your first Pull Request.
66

7-
When sending signed CLA please provide your github username in case of individual CLA or the list of github usernames that can make pull requests on behalf of your organization.
7+
When sending signed CLA please provide your Github username in case of individual CLA or the list of Github usernames that can make pull requests on behalf of your organization.
88

99
If you are confident that you're covered under a Corporate CLA, please make sure you've publicized your membership in the appropriate Github Org, per these instructions.
1010

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ This buildpack supports running Django and Flask apps.
1010

1111
Official buildpack documentation can be found at [python buildpack docs](http://docs.cloudfoundry.org/buildpacks/python/index.html).
1212

13+
## Adding new dependencies
14+
15+
If you want to add a new dependency to the buildpack, please add it to the [config.yml](https://github.com/cloudfoundry/buildpacks-ci/blob/5a63d13df09f83d5dff7c71d0a12c3e2dc798d39/pipelines/dependency-builds/config.yml#L272) file. For example, if you want to add a new version of Python, add an entry like the following:
16+
17+
```yaml
18+
python:
19+
lines:
20+
- line: 3.14.X
21+
deprecation_date: 2030-10-07
22+
link: https://peps.python.org/pep-0745/
23+
```
24+
25+
The new dependency will be automatically added to the buildpack [manifest.yml](manifest.yml) file.
26+
1327
### Building the Buildpack
1428
1529
To build this buildpack, run the following commands from the buildpack's directory:
@@ -24,7 +38,7 @@ To build this buildpack, run the following commands from the buildpack's directo
2438
1. Install buildpack-packager
2539

2640
```bash
27-
go install github.com/cloudfoundry/libbuildpack/packager/buildpack-packager
41+
go install github.com/cloudfoundry/libbuildpack/packager/buildpack-packager@latest
2842
```
2943

3044
1. Build the buildpack

src/python/supply/supply.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,15 +743,23 @@ func (s *Supplier) RunPipVendored() error {
743743
// dependencies - wheel and setuptools. These are packaged by the dependency
744744
// pipeline within the "pip" dependency.
745745
func (s *Supplier) InstallCommonBuildDependencies() error {
746-
var commonDeps = []string{"wheel", "setuptools"}
747746
tempPath := filepath.Join("/tmp", "common_build_deps")
748747
if err := s.Installer.InstallOnlyVersion("pip", tempPath); err != nil {
749748
return err
750749
}
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)
758+
}
751759

752-
for _, dep := range commonDeps {
760+
for _, dep := range []string{"wheel", "setuptools"} {
753761
s.Log.Info("Installing build-time dependency %s", dep)
754-
args := []string{dep, "--no-index", "--upgrade-strategy=only-if-needed", fmt.Sprintf("--find-links=%s", tempPath)}
762+
args := []string{dep, "--no-index", "--no-build-isolation", "--upgrade-strategy=only-if-needed", fmt.Sprintf("--find-links=%s", tempPath)}
755763
if err := s.runPipInstall(args...); err != nil {
756764
return fmt.Errorf("could not install build-time dependency %s: %v", dep, err)
757765
}

src/python/supply/supply_test.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -633,22 +633,32 @@ 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("bootstraps flit-core, wheel and setuptools", func() {
637637
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
638-
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")
639-
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")
638+
mockInstaller.EXPECT().InstallOnlyVersion("flit-core", "/tmp/common_build_deps")
639+
mockCommand.EXPECT().Execute(buildDir, gomock.Any(), gomock.Any(), "python", "-m", "pip", "install", "/tmp/common_build_deps", "--no-build-isolation")
640+
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")
641+
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")
640642

641643
Expect(supplier.InstallCommonBuildDependencies()).To(Succeed())
642644
})
643645
})
644646

645-
Context("installation fails", func() {
646-
BeforeEach(func() {
647-
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").Return(fmt.Errorf("some-pip-error"))
648-
})
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+
})
649655

656+
Context("wheel installation fails", func() {
650657
It("returns a useful error message", func() {
651-
mockInstaller.EXPECT().InstallOnlyVersion(gomock.Any(), gomock.Any()).Times(1)
658+
mockInstaller.EXPECT().InstallOnlyVersion("pip", "/tmp/common_build_deps")
659+
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"))
652662
Expect(supplier.InstallCommonBuildDependencies()).To(MatchError("could not install build-time dependency wheel: some-pip-error"))
653663
})
654664
})

0 commit comments

Comments
 (0)