Exemple #1
0
 def add_requirements(self, metadata_path):
     """transform platform-dependent requirements"""
     pkg_info = read_pkg_info(metadata_path)
     # pkg_info is an email.Message object (?!)
     # we have to remove the unconditional 'readline' and/or 'pyreadline' entries
     # and transform them to conditionals
     requires = pkg_info.get_all('Requires-Dist')
     del pkg_info['Requires-Dist']
     def _remove_startswith(lis, prefix):
         """like list.remove, but with startswith instead of =="""
         found = False
         for idx, item in enumerate(lis):
             if item.startswith(prefix):
                 found = True
                 break
         if found:
             lis.pop(idx)
     
     for pkg in ("gnureadline", "pyreadline", "mock"):
         _remove_startswith(requires, pkg)
     requires.append("gnureadline; sys.platform == 'darwin' and platform.python_implementation == 'CPython'")
     requires.append("pyreadline (>=2.0); sys.platform == 'win32' and platform.python_implementation == 'CPython'")
     requires.append("mock; extra == 'test' and python_version < '3.3'")
     for r in requires:
         pkg_info['Requires-Dist'] = r
     write_pkg_info(metadata_path, pkg_info)
Exemple #2
0
            def add_requirements(self, metadata_path):
                """transform platform-dependent requirements"""
                pkg_info = read_pkg_info(metadata_path)
                # pkg_info is an email.Message object (?!)
                # we have to remove the unconditional 'readline' and/or 'pyreadline' entries
                # and transform them to conditionals
                requires = pkg_info.get_all('Requires-Dist')
                del pkg_info['Requires-Dist']

                def _remove_startswith(lis, prefix):
                    """like list.remove, but with startswith instead of =="""
                    found = False
                    for idx, item in enumerate(lis):
                        if item.startswith(prefix):
                            found = True
                            break
                    if found:
                        lis.pop(idx)

                for pkg in ("gnureadline", "pyreadline", "mock"):
                    _remove_startswith(requires, pkg)
                requires.append(
                    "gnureadline; sys.platform == 'darwin' and platform.python_implementation == 'CPython'"
                )
                requires.append(
                    "pyreadline (>=2.0); extra == 'terminal' and sys.platform == 'win32' and platform.python_implementation == 'CPython'"
                )
                requires.append(
                    "pyreadline (>=2.0); extra == 'all' and sys.platform == 'win32' and platform.python_implementation == 'CPython'"
                )
                requires.append(
                    "mock; extra == 'test' and python_version < '3.3'")
                for r in requires:
                    pkg_info['Requires-Dist'] = r
                write_pkg_info(metadata_path, pkg_info)