Skip to content

Commit 028a7b6

Browse files
author
Ryan Moran
committed
Adds CFLAGS when building
1 parent 2963ca9 commit 028a7b6

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/python/supply/supply.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,12 @@ func (s *Supplier) InstallPython() error {
304304
if err := os.Setenv("PATH", fmt.Sprintf("%s:%s", filepath.Join(s.Stager.DepDir(), "bin"), os.Getenv("PATH"))); err != nil {
305305
return err
306306
}
307-
if err := os.Setenv("PYTHONPATH", filepath.Join(s.Stager.DepDir())); err != nil {
307+
if err := os.Setenv("PYTHONPATH", s.Stager.DepDir()); err != nil {
308+
return err
309+
}
310+
311+
version := regexp.MustCompile(`\d+\.\d+`).FindString(dep.Version)
312+
if err := os.Setenv("CFLAGS", fmt.Sprintf("-I%s", filepath.Join(s.Stager.DepDir(), "python", "include", fmt.Sprintf("python%s", version)))); err != nil {
308313
return err
309314
}
310315

src/python/supply/supply_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ var _ = Describe("Supply", func() {
112112
mockStager.EXPECT().LinkDirectoryInDepDir(filepath.Join(pythonInstallDir, "lib"), "lib")
113113
Expect(supplier.InstallPython()).To(Succeed())
114114
Expect(os.Getenv("PATH")).To(Equal(fmt.Sprintf("%s:%s", filepath.Join(depDir, "bin"), originalPath)))
115-
Expect(os.Getenv("PYTHONPATH")).To(Equal(filepath.Join(depDir)))
115+
Expect(os.Getenv("PYTHONPATH")).To(Equal(depDir))
116+
Expect(os.Getenv("CFLAGS")).To(Equal(fmt.Sprintf("-I%s", filepath.Join(depDir, "python", "include", "python3.4"))))
116117
})
117118
})
118119

@@ -122,13 +123,14 @@ var _ = Describe("Supply", func() {
122123
})
123124

124125
It("installs the default Python version", func() {
125-
mockManifest.EXPECT().DefaultVersion("python").Return(libbuildpack.Dependency{Name: "python", Version: "some-default-version"}, nil)
126-
mockInstaller.EXPECT().InstallDependency(libbuildpack.Dependency{Name: "python", Version: "some-default-version"}, pythonInstallDir)
126+
mockManifest.EXPECT().DefaultVersion("python").Return(libbuildpack.Dependency{Name: "python", Version: "some-default-version-3.2"}, nil)
127+
mockInstaller.EXPECT().InstallDependency(libbuildpack.Dependency{Name: "python", Version: "some-default-version-3.2"}, pythonInstallDir)
127128
mockStager.EXPECT().LinkDirectoryInDepDir(filepath.Join(pythonInstallDir, "bin"), "bin")
128129
mockStager.EXPECT().LinkDirectoryInDepDir(filepath.Join(pythonInstallDir, "lib"), "lib")
129130
Expect(supplier.InstallPython()).To(Succeed())
130131
Expect(os.Getenv("PATH")).To(Equal(fmt.Sprintf("%s:%s", filepath.Join(depDir, "bin"), originalPath)))
131132
Expect(os.Getenv("PYTHONPATH")).To(Equal(filepath.Join(depDir)))
133+
Expect(os.Getenv("CFLAGS")).To(Equal(fmt.Sprintf("-I%s", filepath.Join(depDir, "python", "include", "python3.2"))))
132134
})
133135
})
134136
})

0 commit comments

Comments
 (0)