python_wot_plugin.py 1.3 KB

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