Commit 64514152 authored by Kirill Smelkov's avatar Kirill Smelkov

Name(egg) != Directory(egg) on the filesystem

For example an egg might be refered to as 'cython' and placed on the
filesystem as 'Cython' (titled). And for cython-zstd it is placed on the
filesytem as cython_zstd ('-' -> '_'). Try to account for that.

Without the fix nxdbom breaks as

	ValueError: egg cython-zstd not found
parent da338904
......@@ -185,7 +185,7 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
installed_eggs = [basename(_) for _ in (glob('%s/*.egg' % eggdir) +
glob('%s/*.egg' % eggdev))]
eggv = [_ for _ in installed_eggs if _.startswith('%s-' % eggname)]
eggv = [_ for _ in installed_eggs if _.lower().startswith('%s-' % eggcanon(eggname))]
if len(eggv) == 0:
raise ValueError('egg %s not found' % eggname)
if len(eggv) > 1:
......@@ -224,6 +224,11 @@ def geturl(part, default=_missing):
_egg_re = re.compile(r'^(?P<name>[\w\-\.]+)(\[.*\])?$')
# eggcanon returns canonical name for an egg.
# e.g. Cython-Zstd -> cython_zstd
def eggcanon(eggname):
return eggname.lower().replace('-', '_')
def bom_node(XXX):
1/0
......
......@@ -294,6 +294,32 @@ readline 8.1 http://ftp.gnu.org/gnu/readline/readline
readline5 5.2 http://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
""")
# egg directoty on the filesystem might have different case and _ instead of -
case1("""\
[cython-zstd]
recipe = zc.recipe.egg:custom
egg = cython-zstd
__buildout_installed__ = /ROOT/develop-eggs/cython_zstd-0.2-py2.7-linux-x86_64.egg
[cython]
recipe = zc.recipe.egg:custom
egg = cython
__buildout_installed__ = /Root/develop-eggs/Cython-0.29.24-py2.7-linux-x86_64.egg
[neoppod]
recipe = zc.recipe.egg
_d = /ROOT/develop-eggs
_e = /ROOT/eggs
eggs = cython-zstd
cython
-- /ROOT/develop-eggs/cython_zstd-0.2-py2.7-linux-x86_64.egg/x --
-- /ROOT/develop-eggs/Cython-0.29.24-py2.7-linux-x86_64.egg/x --
""", """
>>> eggs:
Cython 0.29.24 https://pypi.org/project/Cython/0.29.24/
cython_zstd 0.2 https://pypi.org/project/cython_zstd/0.2/
""")
@pytest.mark.parametrize('build,bomok', testv)
def test_bom_software(tmpdir, build, bomok):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment