diff --git a/deplist_test.go b/deplist_test.go index 2b8f8a0..ad28982 100644 --- a/deplist_test.go +++ b/deplist_test.go @@ -234,6 +234,9 @@ func BuildWant() []Dependency { "cotyledon", "Flask", "kuryr-lib", + "docutils", + "python-dateutil", + "unittest2", "cryptography", } @@ -274,6 +277,9 @@ func BuildWant() []Dependency { deps = append(deps, d) } + end = len(deps) - 2 // get the cryptography ver + deps[end].Version = "0.5.1" + end = len(deps) - 1 // get the cryptography ver deps[end].Version = "2.3.0" diff --git a/internal/scan/python.go b/internal/scan/python.go index 433a779..0cf7318 100755 --- a/internal/scan/python.go +++ b/internal/scan/python.go @@ -31,14 +31,24 @@ func GetPythonDeps(path string) (map[string]string, error) { line := scanner.Text() // skip comments - if strings.HasPrefix(line, "#") || line == "" { + // and editable? https://github.com/pypa/pip/issues/4812 + if strings.HasPrefix(line, "#") || strings.HasPrefix(line, "-e") || line == "" { continue } // easy case, elasticsearch-curator==5.8.1 // record name and version, only for == - idx := strings.LastIndex(line, "==") + idx := strings.Index(line, "==") if idx > 0 { + // test if there's a ';', i.e. unittest2==0.5.1; python_version == '2.6' + colIdx := strings.Index(line, ";") + if colIdx > 0 { + if idx+2 >= colIdx { + continue + } + // truncate line + line = line[:colIdx] + } gathered[line[:idx]] = line[idx+2:] continue } diff --git a/test/testRepo/requirements.txt b/test/testRepo/requirements.txt index d116f28..fc2d6d7 100644 --- a/test/testRepo/requirements.txt +++ b/test/testRepo/requirements.txt @@ -5,4 +5,7 @@ cotyledon>=1.5.0 # Apache-2.0 Flask!=0.11,>=0.12.3 # BSD kuryr-lib>=0.5.0 # Apache-2.0 +unittest2==0.5.1; python_version == '2.6' +python-dateutil>=2.1,<3.0.0; python_version>="2.7" +docutils>=0.10 cryptography==2.3.0