Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 6adf76e

Browse files
committed
Used env vars to search for packages in PYTHONPATH
1 parent caee6e4 commit 6adf76e

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

differs/pipDiff.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ func (d PipDiffer) Diff(image1, image2 utils.Image) (utils.DiffResult, error) {
2121
return diff, err
2222
}
2323

24-
func getPythonVersion(pathToLayer string) ([]string, error) {
24+
func getPythonVersion(pathToImage string) ([]string, error) {
2525
matches := []string{}
26-
libPath := filepath.Join(pathToLayer, "usr/local/lib")
26+
libPath := filepath.Join(pathToImage, "usr/local/lib")
2727
libContents, err := ioutil.ReadDir(libPath)
2828
if err != nil {
2929
return matches, err
@@ -59,9 +59,7 @@ func (d PipDiffer) getPackages(image utils.Image) (map[string]map[string]utils.P
5959
pythonPaths := []string{}
6060
if !reflect.DeepEqual(utils.ConfigSchema{}, image.Config) {
6161
paths := getPythonPaths(image.Config.Config.Env)
62-
for _, p := range paths {
63-
pythonPaths = append(pythonPaths, p)
64-
}
62+
pythonPaths = append(pythonPaths, paths...)
6563
}
6664
pythonVersions, err := getPythonVersion(path)
6765
if err != nil {
@@ -77,7 +75,7 @@ func (d PipDiffer) getPackages(image utils.Image) (map[string]map[string]utils.P
7775
for _, pythonPath := range pythonPaths {
7876
contents, err := ioutil.ReadDir(pythonPath)
7977
if err != nil {
80-
// python version folder doesn't have a site-packages folder
78+
// python version folder doesn't have a site-packages folder or PYTHONPATH doesn't exist
8179
continue
8280
}
8381

tests/multi_diff_expected.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,6 @@
101101
}
102102
},
103103
"InfoDiff": [
104-
{
105-
"Package": "wheel",
106-
"Info1": [
107-
{
108-
"Version": "0.29.0",
109-
"Size": "103509"
110-
}
111-
],
112-
"Info2": [
113-
{
114-
"Version": "0.29.0",
115-
"Size": "137451"
116-
}
117-
]
118-
},
119104
{
120105
"Package": "mock",
121106
"Info1": [
@@ -145,6 +130,21 @@
145130
"Size": "1157078"
146131
}
147132
]
133+
},
134+
{
135+
"Package": "wheel",
136+
"Info1": [
137+
{
138+
"Version": "0.29.0",
139+
"Size": "103509"
140+
}
141+
],
142+
"Info2": [
143+
{
144+
"Version": "0.29.0",
145+
"Size": "137451"
146+
}
147+
]
148148
}
149149
]
150150
}

0 commit comments

Comments
 (0)