generated from ni/github-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
37 lines (37 loc) · 1.44 KB
/
action.yml
File metadata and controls
37 lines (37 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Set up Python
description: Install Python with appropriate defaults for NI Python projects.
inputs:
python-version:
default: 3.11.9
outputs:
python-path:
value: ${{ steps.setup-python.outputs.python-path }}
python-version:
value: ${{ steps.get-python-version.outputs.python-version }}
runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
id: setup-python
with:
python-version: ${{ inputs.python-version }}
# Workaround for https://github.com/actions/setup-python/issues/1109 -
# Python-version output for PyPy isn't unique across different versions
- name: Get Python version
id: get-python-version
run: |
import os, platform, sys, sysconfig
if sys.implementation.name == "pypy":
version = f"pypy{platform.python_version()}-v{'.'.join(map(str,sys.implementation.version[:3]))}"
else:
version = platform.python_version()
# Also take free-threading into account
if sysconfig.get_config_var("Py_GIL_DISABLED"):
version += "t"
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
print(f"python-version={version}", file=output)
shell: python
- name: Add pythonVersion environment variable
run: echo "pythonVersion=${{ steps.get-python-version.outputs.python-version }}" >> "$GITHUB_ENV"
shell: bash