python_wot_plugin.py 891 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. 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. for idx, cmd in enumerate(cmds):
  17. if cmd.strip().startswith('pip install -c') and "requirements_all" in cmd:
  18. cmds[idx] = f"{cmd.strip()} --use-deprecated=legacy-resolver"
  19. elif "[ -f setup.py ]" in cmd:
  20. # Use cfg instead of py
  21. cmds[idx] = cmd.replace('[ -f setup.py ]', '"${SNAPCRAFT_PYTHON_INTERPRETER}" -m build')
  22. return cmds