Skip to content

Commit e6f3ff6

Browse files
olszomalmtrojnar
authored andcommitted
Switch to venv on Windows
1 parent 09135aa commit e6f3ff6

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,33 +150,25 @@ jobs:
150150
python --version
151151
python -c "import cryptography; print(f'Python3 cryptography version {cryptography.__version__}')"
152152
153+
- name: Set up Python virtual environment (Windows)
154+
if: runner.os == 'Windows'
155+
run: |
156+
python.exe -m venv --system-site-packages --copies venv
157+
echo "VIRTUAL_ENV=${{github.workspace}}\venv" >> $GITHUB_ENV
158+
echo "${{github.workspace}}\venv\Scripts" >> $GITHUB_PATH
159+
160+
153161
- name: Install python3 cryptography module (Windows)
154162
if: runner.os == 'Windows'
155163
run: |
164+
.\venv\Scripts\Activate.ps1
156165
python.exe -m ensurepip
157166
python.exe -m pip install --upgrade pip
158167
python.exe -m pip install cryptography
159168
python.exe -c "import sys; print(sys.executable)"
160169
python.exe --version
161170
python.exe -c "import cryptography; print(f'Python3 cryptography version {cryptography.__version__}')"
162171
163-
- name: Find the latest version of Python (Windows)
164-
if: runner.os == 'Windows'
165-
run: |
166-
$pythonVersions = Get-ChildItem -Path "C:/hostedtoolcache/windows/Python/" -Directory | Where-Object { $_.Name -match '\d+\.\d+\.\d+' } | Sort-Object { [Version]($_.Name) } -Descending
167-
if ($pythonVersions.Count -gt 0) {
168-
$latestPythonVersion = $pythonVersions[0].Name
169-
$pythonPath = "C:/hostedtoolcache/windows/Python/$latestPythonVersion/x64"
170-
Write-Output "Latest Python version found: $latestPythonVersion"
171-
Write-Output "Python directory path: $pythonPath"
172-
$env:Path = "$pythonPath;" + $env:Path
173-
Write-Output "Updated PATH environment variable:"
174-
Write-Output $env:Path
175-
} else {
176-
Write-Error "No Python versions found in C:/hostedtoolcache/windows/Python/"
177-
exit 1
178-
}
179-
180172
- name: Configure CMake (macOS)
181173
if: runner.os == 'macOS'
182174
run: |
@@ -190,8 +182,21 @@ jobs:
190182
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/dist" \
191183
-DPython3_EXECUTABLE="${{ github.workspace }}/venv/bin/python"
192184
193-
- name: Configure CMake (non-macOS)
194-
if: runner.os != 'macOS'
185+
- name: Configure CMake (Windows)
186+
if: runner.os == 'Windows'
187+
run: |
188+
.\venv\Scripts\Activate.ps1
189+
cmake `
190+
-G "${{ matrix.generator }}" `
191+
-S "${{ github.workspace }}" `
192+
-B "${{ github.workspace }}/build" `
193+
-DCMAKE_OSX_ARCHITECTURES=arm64 `
194+
-DCMAKE_BUILD_TYPE="${{ env.BUILD_TYPE }}" `
195+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/dist" `
196+
-DPython3_EXECUTABLE="${{ github.workspace }}\venv\Scripts\python.exe"
197+
198+
- name: Configure CMake (Linux)
199+
if: runner.os == 'Linux'
195200
run: cmake
196201
-G "${{matrix.generator}}"
197202
-S ${{github.workspace}}
@@ -220,8 +225,15 @@ jobs:
220225
source ../venv/bin/activate
221226
ctest -C ${{env.BUILD_TYPE}}
222227
223-
- name: Test (non-macOS)
224-
if: runner.os != 'macOS'
228+
- name: Test (Windows)
229+
if: runner.os == 'Windows'
230+
working-directory: ${{github.workspace}}/build
231+
run: |
232+
..\venv\Scripts\Activate.ps1
233+
ctest -C ${{env.BUILD_TYPE}}
234+
235+
- name: Test (Linux)
236+
if: runner.os == 'Linux'
225237
working-directory: ${{github.workspace}}/build
226238
run: ctest -C ${{env.BUILD_TYPE}}
227239

0 commit comments

Comments
 (0)