python_wot_plugin.py 965 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. import snapcraft
  3. import snapcraft.plugins.v2 as plugins
  4. from typing import Any, Dict, List, Set
  5. """
  6. See snapcraft.plugins.v2.python.PythonPlugin
  7. Plugin forces removal of 'typing' package
  8. after setup, as 'typing' is causing problems
  9. for python >= 3.7, see:
  10. - https://github.com/pypa/pip/issues/8272
  11. """
  12. class PluginImpl(plugins.python.PythonPlugin):
  13. def get_build_commands(self) -> List[str]:
  14. cmds = super().get_build_commands()
  15. # cmds.insert(1, 'pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip')
  16. for idx, cmd in enumerate(cmds):
  17. # Find position where to inject pip uninstall
  18. if cmd.strip().startswith('[ -f setup.py ]'):
  19. xcmds = cmd.split("&&", 1)
  20. # Inject and force removal
  21. cmds[idx] = f"{xcmds[0]} && pip uninstall -y typing uuid && {xcmds[1]}"
  22. return cmds