diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-01-05 12:14:52 +0000 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-01-05 17:33:07 +0000 |
commit | 954df6a8fba515baab7940c617eb919c28fdd2f2 (patch) | |
tree | f8ac5c892e545047fa61396ba8fcb1ae669c7efa /baserockimport/exts/python.find_deps | |
parent | 764531201f99bf1d9c6dd451a212b741bfb6715e (diff) | |
download | import-954df6a8fba515baab7940c617eb919c28fdd2f2.tar.gz |
Treat hyphens and underscores equivalently
There isn't yet an official spec for distribution names in python,
however there is a draft at http://legacy.python.org/dev/peps/pep-0426/#name
In particular,
"All comparisons of distribution names MUST be case insensitive,
and MUST consider hyphens and underscores to be equivalent."
pkg_resource.parse_requirements will replace any underscores in the
package name as hyphens, so when we search pypi we need to look for
the package name with underscores as well as with hyphens.
Diffstat (limited to 'baserockimport/exts/python.find_deps')
-rwxr-xr-x | baserockimport/exts/python.find_deps | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/baserockimport/exts/python.find_deps b/baserockimport/exts/python.find_deps index cca0947..2b6b618 100755 --- a/baserockimport/exts/python.find_deps +++ b/baserockimport/exts/python.find_deps @@ -301,8 +301,12 @@ def find_runtime_deps(source, name, version=None, use_requirements_file=False): logging.debug("Resolved specs for %s: %s" % (name, ss)) logging.debug("Removing root package from specs") + # filter out "root" package - specsets = {k: v for (k, v) in ss.iteritems() if k != name} + # hyphens and underscores are treated as equivalents + # in distribution names + specsets = {k: v for (k, v) in ss.iteritems() + if k not in [name, name.replace('_', '-')]} versions = resolve_versions(specsets) logging.debug('Resolved versions: %s' % versions) |