|
9 | 9 |
|
10 | 10 | steps: |
11 | 11 | - name: Checkout code |
12 | | - uses: actions/checkout@v3 |
13 | | - |
14 | | - - name: Install Python (if not already installed) |
15 | | - shell: powershell |
16 | | - run: | |
17 | | - # Check if Python is already installed |
18 | | - if (-not (Get-Command python -ErrorAction SilentlyContinue)) { |
19 | | - Write-Host "Python not found, installing..." |
20 | | - # Download and Install Python |
21 | | - $pythonInstallerUrl = "https://www.python.org/ftp/python/3.13.0/python-3.13.0.exe" |
22 | | - $installerPath = "$env:temp\python-installer.exe" |
23 | | - Invoke-WebRequest -Uri $pythonInstallerUrl -OutFile $installerPath |
24 | | - # Install Python and make sure it's added to the PATH |
25 | | - Start-Process -FilePath $installerPath -ArgumentList "/quiet", "InstallAllUsers=1", "PrependPath=1" -Wait |
26 | | - Write-Host "Python installed" |
27 | | - } else { |
28 | | - Write-Host "Python already installed" |
29 | | - } |
30 | | -
|
31 | | - # Refresh the environment to pick up the new PATH |
32 | | - $env:PATH = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::Machine) |
33 | | - |
34 | | - # Verify if Python is installed and accessible |
35 | | - $pythonPath = Get-Command python -ErrorAction SilentlyContinue |
36 | | - if ($pythonPath) { |
37 | | - Write-Host "Python found at $pythonPath" |
38 | | - } else { |
39 | | - Write-Host "Python installation failed. Exiting." |
40 | | - exit 1 |
41 | | - } |
42 | | -
|
43 | | - - name: Install pip (if not already installed) |
44 | | - shell: powershell |
45 | | - run: | |
46 | | - # Check if pip is already installed |
47 | | - if (-not (Get-Command pip -ErrorAction SilentlyContinue)) { |
48 | | - Write-Host "pip not found, installing..." |
49 | | - # Install pip using Python |
50 | | - python -m ensurepip --upgrade |
51 | | - python -m pip install --upgrade pip |
52 | | - Write-Host "pip installed" |
53 | | - } else { |
54 | | - Write-Host "pip already installed" |
55 | | - } |
| 12 | + uses: actions/checkout@v4 |
56 | 13 |
|
57 | 14 | - name: Set up Python |
58 | | - uses: actions/setup-python@v5 |
| 15 | + uses: gowridurgad/setup-python@v5 |
59 | 16 | with: |
60 | 17 | python-version: '3.13' |
61 | 18 | cache: 'pip' |
62 | 19 | cache-dependency-path: 'requirements.txt' |
63 | 20 | update-environment: false # Do not update environment |
64 | 21 |
|
65 | | - - name: Install dependencies |
66 | | - run: | |
67 | | - pip install -r requirements.txt |
0 commit comments