Skip to content

Commit d6e6364

Browse files
committed
Example workflow for win - Restructuring for build
1 parent d323568 commit d6e6364

17 files changed

+79
-21
lines changed

.github/workflows/customized-win-shells.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
shell: bash -el {0}
2525
working-directory: ${{ github.workspace }}/source/MagTenseFortranCuda/cuda
2626
run: |
27-
nvcc -c MagTenseCudaBlas.cu -ccbin "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64" -o MagTenseCudaBlas.o
27+
nvcc -c MagTenseCudaBlas.cu -ccbin "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34438\bin\Hostx64\x64" -o MagTenseCudaBlas.o
2828
2929
- name: Run Developer PowerShell for VS 2022
3030
shell: pwsh -NoExit -ExecutionPolicy ByPass -File {0}

.github/workflows/linux-python-package-conda.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
defaults:
1212
run:
1313
shell: bash -el {0}
14+
env:
15+
build_file: python/.build/env-${{ matrix.py-version }}-linux.yml
1416

1517
steps:
1618
- name: Checkout repository
@@ -27,18 +29,15 @@ jobs:
2729
uses: actions/cache@v4
2830
env:
2931
# Increase this value to reset cache manually
30-
CACHE_NUMBER: 0
32+
cache_number: 0
3133
with:
3234
path: ${{ env.CONDA }}/envs
33-
key: conda-${{ runner.os }}-${{hashFiles('python/build_env_linux.yml') }}-${{ env.CACHE_NUMBER }}
35+
key: conda-${{ runner.os }}-${{ hashFiles(env.build_file) }}-${{ env.cache_number }}
3436
id: cache
3537

3638
- name: Update environment
37-
run: conda env update -n magtense-env -f python/build_env_linux.yml
39+
run: conda env update -n magtense-env -f ${{ env.build_file }}
3840
if: steps.cache.outputs.cache-hit != 'true'
39-
40-
- name: Install chrpath
41-
run: sudo apt install -y chrpath
4241

4342
- name: Create directory for wrappers of compiled Fortran source code
4443
run: |
@@ -57,7 +56,7 @@ jobs:
5756
5857
- name: Build pip-wheels
5958
working-directory: ${{ github.workspace }}/python/
60-
run: python scripts/dist_pypi.py
59+
run: python .build/dist_pypi.py
6160

6261
- name: cpu - Archive pip-wheel
6362
uses: actions/upload-artifact@v4

.github/workflows/matlab_package.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
uses: conda-incubator/setup-miniconda@v3
3535
with:
3636
activate-environment: magtense-env
37-
environment-file: python/environment_linux.yml
37+
environment-file: python/.build/environment_linux.yml
3838
python-version: 3.12
3939
auto-activate-base: false
4040

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Win - Python package using conda / pip
2+
3+
on: [push]
4+
5+
jobs:
6+
build-win:
7+
runs-on: windows-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Conda with Python 3.12
12+
uses: conda-incubator/setup-miniconda@v3
13+
with:
14+
activate-environment: magtense-env
15+
environment-file: python/environment_win.yml
16+
python-version: 3.12
17+
auto-activate-base: false
18+
19+
- name: Compile Fortran files in Developer PowerShell for VS 2022
20+
shell: pwsh -NoExit -ExecutionPolicy ByPass -File {0}
21+
run: |
22+
cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\"
23+
.\Launch-VsDevShell.ps1
24+
cd ${{ github.workspace }}/python/src/magtense/lib/
25+
make ps
26+
27+
- name: Compile with nvcc in x64 Native Tools Command Prompt for VS 2022
28+
shell: cmd /k "{0}" -arch=amd64 -host_arch=x64
29+
working-directory: ${{ github.workspace }}/source/MagTenseFortranCuda/cuda
30+
run: |
31+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
32+
nvcc -c MagTenseCudaBlas.cu -o MagTenseCudaBlas.o
33+
34+
- name: Link Cuda wrapper in Developer PowerShell for VS 2022
35+
shell: pwsh -NoExit -ExecutionPolicy ByPass -File {0}
36+
run: |
37+
cd "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\"
38+
.\Launch-VsDevShell.ps1
39+
cd ${{ github.workspace }}/source/MagTenseFortranCuda/cuda
40+
make wrap
41+
42+
- name: Build Python wrapper in Command Prompt
43+
shell: cmd /C CALL {0}
44+
working-directory: ${{ github.workspace }}/python/src/magtense/lib/
45+
run: >-
46+
make cmdx64
47+
48+
- name: Install local magtense package with pip
49+
run: python -m pip install -e ${{ github.workspace }}/python
50+
51+
- name: Test with pytest
52+
run: |
53+
conda install pytest
54+
pytest

.gitignore

+6-7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ ipch/
5959
*.sdf
6060
*.cachefile
6161

62+
# Visual Studio
63+
.vs/MagTense/v17/
64+
.vs/MagTense/CopilotIndices/
65+
*.vsidx
66+
6267
# Visual Studio profiler
6368
*.psess
6469
*.vsp
@@ -187,17 +192,11 @@ docs/source/_build
187192
*.vtuneproj
188193
*.prj
189194

190-
*.vsidx
195+
*.msg
191196
*.lock
192197

193198
# Notebooks
194199
nbs/
195200

196201
# Virtual environment
197202
.venv*/
198-
199-
.vs/MagTense/v17/
200-
201-
.vs/MagTense/CopilotIndices/
202-
203-
*.msg
File renamed without changes.

python/scripts/dist_pypi.py python/.build/dist_pypi.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def main(py_versions):
6262
subprocess.run(
6363
[
6464
"patchelf",
65+
"--force-rpath",
6566
"--set-rpath",
6667
"$ORIGIN/../../../../../lib",
6768
lib_path,
@@ -71,12 +72,15 @@ def main(py_versions):
7172
subprocess.run(
7273
[
7374
"patchelf",
75+
"--force-rpath",
7476
"--set-rpath",
7577
"$ORIGIN/../../../../../lib:$ORIGIN/../../nvidia/cublas/lib/:$ORIGIN/../../nvidia/cuda_runtime/lib/:$ORIGIN/../../nvidia/cusparse/lib/",
7678
lib_path,
7779
]
7880
)
79-
subprocess.run(["cp", f"requirements-{cuda}.txt", "requirements.txt"])
81+
subprocess.run(
82+
["cp", f".build/requirement-{py}-{cuda}.txt", "requirements.txt"]
83+
)
8084
subprocess.run(["python3", "-m", "build", "--wheel"])
8185
subprocess.run(
8286
[
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

python/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ __pycache__/
99
# Distribution / packaging
1010
.Python
1111
build/
12+
cpu_libs/
13+
cu12_libs/
1214
develop-eggs/
1315
dist/
1416
downloads/

python/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Libraries have to be pre-build for now, and should be located in `MagTense/pytho
176176
python3 -m pip install build
177177
178178
cd python/
179-
python scripts/dist_pypi.py
179+
python .build/dist_pypi.py
180180
181181
# Upload to pypi.org
182182
python3 -m pip install twine
@@ -202,12 +202,12 @@ conda config --env --append channels https://software.repos.intel.com/python/con
202202
conda config --env --append channels conda-forge
203203
204204
# Quick fix for now
205-
# Copy pre-compiled Python extension to MagTense/python/src/magtense/lib
205+
# Copy pre-compiled Python extension to python/src/magtense/lib
206206
# Build conda seperately for each version
207207
208208
# Version numbers have to be set in advance in pyproject.toml
209-
cd MagTense/python/
210-
python scripts/dist_conda.py
209+
cd python/
210+
python .build/dist_conda.py
211211
```
212212
213213
## Read-in customized M-H-curve
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)