Commit 98687ba0 authored by Kirill Smelkov's avatar Kirill Smelkov

One name might refer to both an egg and a C library

This happens for real with msgpack egg / C-library.

-> Fix handling of such situation via using (name, kind) instead of only
name as BOM key. Without the fix added test breaks as

    def addbom(urlpath, kind, version=None):
        name, ver = namever(urlpath)
        if version is not None:
            assert ver is None
            ver = version
        ver = removeprefix(ver, name+'-')   # wendelin.core-2.0.alpha3-0-g6315384  -> 2.0.alpha3-0-g6315384
        if '//' in urlpath:
            url = urlpath
        else:
            if kind == 'egg':
                # XXX not strictly correct -> better retrieve the actual URL, but buildout does not save it in installed.cfg
                url = 'https://pypi.org/project/%s/%s/' % (name, ver)
            else:
                raise NotImplementedError('TODO url for kind %r  (urlpath: %r)' % (kind, urlpath))

        info = PkgInfo(name, ver, kind, url)
        if name in bom:
>           assert bom[name] == info,  (bom[name], info)
E           AssertionError: (PkgInfo(name='msgpack', version='0.5.4', kind='', url='http://downloads.sourceforge.net/project/msgpack/msgpack/cpp/msgpack-0.5.4.tar.gz'), PkgInfo(name='msgpack', version='0.6.2', kind='egg', url='https://pypi.org/project/msgpack/0.6.2/'))
parent 22de517e
...@@ -46,7 +46,7 @@ PkgInfo = namedtuple('PkgInfo', [ ...@@ -46,7 +46,7 @@ PkgInfo = namedtuple('PkgInfo', [
# bom_software retrieves BOM from .installed.cfg generated by buildout along the build. # bom_software retrieves BOM from .installed.cfg generated by buildout along the build.
def bom_software(installed_software_path): # -> {} name -> PkgInfo def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
bom = {} bom = {}
def addbom(urlpath, kind, version=None): def addbom(urlpath, kind, version=None):
name, ver = namever(urlpath) name, ver = namever(urlpath)
...@@ -65,10 +65,11 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo ...@@ -65,10 +65,11 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo
info = PkgInfo(name, ver, kind, url) info = PkgInfo(name, ver, kind, url)
if name in bom: bkey = (name, kind)
assert bom[name] == info, (bom[name], info) if bkey in bom:
assert bom[bkey] == info, (bom[bkey], info)
else: else:
bom[name] = info bom[bkey] = info
idb = configparser.ConfigParser() idb = configparser.ConfigParser()
......
...@@ -206,6 +206,25 @@ _e = /ROOT/eggs ...@@ -206,6 +206,25 @@ _e = /ROOT/eggs
selenium 3.141.0 https://pypi.org/project/selenium/3.141.0/ selenium 3.141.0 https://pypi.org/project/selenium/3.141.0/
""") """)
# msgpack as egg and as c library at the same time
case1("""
[messagepack]
recipe = slapos.recipe.cmmi
url = http://downloads.sourceforge.net/project/msgpack/msgpack/cpp/msgpack-0.5.4.tar.gz
[msgpack-python]
recipe = zc.recipe.egg:custom
__buildout_installed__ = /ROOT/develop-eggs/msgpack-0.6.2-py2.7-linux-x86_64.egg
_d = /ROOT/develop-eggs
_e = /ROOT/eggs
egg = msgpack
""", """\
msgpack 0.5.4 http://downloads.sourceforge.net/project/msgpack/msgpack/cpp/msgpack-0.5.4.tar.gz
>>> eggs:
msgpack 0.6.2 https://pypi.org/project/msgpack/0.6.2/
""")
# %20 in URL # %20 in URL
case1("""\ case1("""\
[zabbix-agent] [zabbix-agent]
......
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