action.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. author: MatteoH2O1999
  2. name: Build and Setup Python
  3. branding:
  4. icon: play-circle
  5. color: blue
  6. description: "Set up a specific version of Python (building from source if deprecated) and add the command-line tools to the PATH."
  7. inputs:
  8. python-version:
  9. description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset."
  10. python-version-file:
  11. description: "File containing the Python version to use. Example: .python-version"
  12. cache:
  13. description: "Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry."
  14. required: false
  15. architecture:
  16. description: "The target architecture (x86, x64) of the Python or PyPy interpreter."
  17. check-latest:
  18. description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
  19. default: false
  20. token:
  21. description: "The token used to authenticate when fetching Python distributions from https://github.com/actions/python-versions. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting."
  22. default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
  23. cache-dependency-path:
  24. description: "Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies."
  25. update-environment:
  26. description: "Set this option if you want the action to update environment variables."
  27. default: true
  28. cache-build:
  29. required: false
  30. description: Whether to cache the built Python distribution to speed up successive runs (true or false, defaults to false).
  31. default: false
  32. allow-build:
  33. required: false
  34. description: "Set the behavior of the action when actions/setup-python fails and has to be built from source. Supported values: allow, info, warn, error, force. Default: warn"
  35. default: warn
  36. allow-prereleases:
  37. description: "When 'true', a version range passed to 'python-version' input will match prerelease versions if no GA versions are found. Only 'x.y' version range is supported for CPython."
  38. default: false
  39. outputs:
  40. python-version:
  41. description: "The installed Python or PyPy version. Useful when given a version range as input."
  42. value: ${{ steps.setup.outputs.python-version }}
  43. cache-hit:
  44. description: "A boolean value to indicate a cache entry was found."
  45. value: ${{ steps.setup.outputs.cache-hit }}
  46. python-path:
  47. description: "The absolute path to the Python or PyPy executable."
  48. value: ${{ steps.setup.outputs.python-path }}
  49. env:
  50. # Temporary workaround for Python 3.5 failures - May 2024
  51. PIP_TRUSTED_HOST: "pypi.python.org pypi.org files.pythonhosted.org"
  52. runs:
  53. using: composite
  54. steps:
  55. - uses: MatteoH2O1999/build-and-install-python@004dc2989b38616af18eb8aba45fe49d5f813264
  56. id: build
  57. with:
  58. python-version: ${{ inputs.python-version }}
  59. python-version-file: ${{ inputs.python-version-file }}
  60. architecture: ${{ inputs.architecture }}
  61. check-latest: ${{ inputs.check-latest }}
  62. cache-build: ${{ inputs.cache-build }}
  63. allow-build: ${{ inputs.allow-build }}
  64. token: ${{ inputs.token }}
  65. allow-prereleases: ${{ inputs.allow-prereleases }}
  66. - uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0
  67. id: setup
  68. with:
  69. python-version: ${{ steps.build.outputs.python-version }}
  70. cache: ${{ inputs.cache }}
  71. architecture: ${{ steps.build.outputs.architecture }}
  72. check-latest: ${{ inputs.check-latest }}
  73. token: ${{ inputs.token }}
  74. cache-dependency-path: ${{ inputs.cache-dependency-path }}
  75. update-environment: ${{ inputs.update-environment }}
  76. - run: ${{ github.action_path }}/setup_pip.ps1
  77. shell: pwsh
  78. env:
  79. PYTHON_VERSION: ${{ steps.setup.outputs.python-version }}
  80. SETUP_PYTHON_PATH: ${{ steps.setup.outputs.python-path }}