Skip to content

Commit a25df37

Browse files
authored
refactor: add pixi support to vscode tasks (#1884)
* rearrange pixi.toml tasks an add builddir function
1 parent d9f4c25 commit a25df37

File tree

5 files changed

+308
-14
lines changed

5 files changed

+308
-14
lines changed

.vscode/build_vscode.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
parser = argparse.ArgumentParser()
99
parser.add_argument("--compiler", type=str)
1010
parser.add_argument("--buildtype", type=str)
11+
parser.add_argument("--pixi", action="store_true")
1112
parser.add_argument("action")
1213
args = parser.parse_args()
1314

1415
os.environ["FC"] = args.compiler
15-
builddir = f"builddir_{platform.system()}_{args.compiler}_{args.buildtype}"
16+
builddir = f"_builddir_{platform.system()}_{args.compiler}_{args.buildtype}"
1617

1718
arg_parallel = "-Dparallel=false"
1819
if os.getenv("BUILD_PARALLEL_MF6") is not None:
@@ -28,9 +29,18 @@
2829
setup_flag = ["-Ddebug=true", "-Doptimization=0"]
2930

3031
if not os.path.isdir(builddir):
31-
command = [
32-
"meson",
33-
"setup",
32+
if args.pixi:
33+
command = [
34+
"pixi",
35+
"run",
36+
"setup",
37+
]
38+
else:
39+
command = [
40+
"meson",
41+
"setup",
42+
]
43+
command += [
3444
builddir,
3545
"--prefix",
3646
os.getcwd(),
@@ -52,6 +62,10 @@
5262
if os.path.isfile(path):
5363
os.remove(path)
5464

55-
command = ["meson", "install", "-C", builddir]
65+
if args.pixi:
66+
command = ["pixi", "run", "build",]
67+
else:
68+
command = ["meson", "install", "-C"]
69+
command += [builddir]
5670
print("Run:", shlex.join(command))
5771
subprocess.run(command, check=True)

.vscode/run_python.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ if "%3" == "ifort" (
77
call conda activate modflow6
88

99
rem run python script
10-
python %1 %2 %3 %4 %5 %6
10+
python %1 %2 %3 %4 %5 %6 %7

.vscode/run_python.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ eval "$(conda shell.bash hook)"
99
conda activate modflow6
1010

1111
# run python script
12-
python $1 $2 $3 $4 $5 $6
12+
python $1 $2 $3 $4 $5 $6 $7

.vscode/tasks.json

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,5 +303,265 @@
303303
},
304304
"problemMatcher": []
305305
},
306+
{
307+
"label": "Pixi - Rebuild MF6 (gfortran, release)",
308+
"command": "${workspaceFolder}/.vscode/run_python.sh",
309+
"windows": {
310+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
311+
"args": [
312+
"${workspaceFolder}/.vscode/build_vscode.py",
313+
"--compiler",
314+
"gfortran",
315+
"--buildtype",
316+
"release",
317+
"--pixi",
318+
"rebuild",
319+
],
320+
},
321+
"args": [
322+
"${workspaceFolder}/.vscode/build_vscode.py",
323+
"--compiler",
324+
"gfortran",
325+
"--buildtype",
326+
"release",
327+
"--pixi",
328+
"rebuild",
329+
],
330+
"group": {
331+
"kind": "build",
332+
"isDefault": true
333+
},
334+
"presentation": {
335+
"clear": true
336+
}
337+
},
338+
{
339+
"label": "Pixi - Build MF6 (gfortran, release)",
340+
"command": "${workspaceFolder}/.vscode/run_python.sh",
341+
"windows": {
342+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
343+
"args": [
344+
"${workspaceFolder}/.vscode/build_vscode.py",
345+
"--compiler",
346+
"gfortran",
347+
"--buildtype",
348+
"release",
349+
"--pixi",
350+
"build",
351+
],
352+
"problemMatcher": "$msCompile"
353+
},
354+
"args": [
355+
"${workspaceFolder}/.vscode/build_vscode.py",
356+
"--compiler",
357+
"gfortran",
358+
"--buildtype",
359+
"release",
360+
"--pixi",
361+
"build",
362+
],
363+
"group": {
364+
"kind": "build",
365+
"isDefault": true
366+
},
367+
"presentation": {
368+
"clear": true
369+
}
370+
},
371+
{
372+
"label": "Pixi - Build MF6 (gfortran, debug)",
373+
"command": "${workspaceFolder}/.vscode/run_python.sh",
374+
"windows": {
375+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
376+
"args": [
377+
"${workspaceFolder}/.vscode/build_vscode.py",
378+
"--compiler",
379+
"gfortran",
380+
"--buildtype",
381+
"debug",
382+
"--pixi",
383+
"build",
384+
],
385+
"problemMatcher": "$msCompile"
386+
},
387+
"args": [
388+
"${workspaceFolder}/.vscode/build_vscode.py",
389+
"--compiler",
390+
"gfortran",
391+
"--buildtype",
392+
"debug",
393+
"--pixi",
394+
"build",
395+
],
396+
"group": {
397+
"kind": "build",
398+
"isDefault": true
399+
},
400+
"presentation": {
401+
"clear": true
402+
}
403+
},
404+
{
405+
"label": "Pixi - Rebuild MF6 (gfortran, debug)",
406+
"command": "${workspaceFolder}/.vscode/run_python.sh",
407+
"windows": {
408+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
409+
"args": [
410+
"${workspaceFolder}/.vscode/build_vscode.py",
411+
"--compiler",
412+
"gfortran",
413+
"--buildtype",
414+
"debug",
415+
"--pixi",
416+
"rebuild",
417+
],
418+
},
419+
"args": [
420+
"${workspaceFolder}/.vscode/build_vscode.py",
421+
"--compiler",
422+
"gfortran",
423+
"--buildtype",
424+
"debug",
425+
"--pixi",
426+
"rebuild",
427+
],
428+
"group": {
429+
"kind": "build",
430+
"isDefault": true
431+
},
432+
"presentation": {
433+
"clear": true
434+
}
435+
},
436+
{
437+
"label": "Pixi - Build MF6 (ifort, release)",
438+
"command": "${workspaceFolder}/.vscode/run_python.sh",
439+
"windows": {
440+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
441+
"args": [
442+
"${workspaceFolder}/.vscode/build_vscode.py",
443+
"--compiler",
444+
"ifort",
445+
"--buildtype",
446+
"release",
447+
"--pixi",
448+
"build",
449+
],
450+
"problemMatcher": "$msCompile"
451+
},
452+
"args": [
453+
"${workspaceFolder}/.vscode/build_vscode.py",
454+
"--compiler",
455+
"ifort",
456+
"--buildtype",
457+
"release",
458+
"--pixi",
459+
"build",
460+
],
461+
"group": {
462+
"kind": "build",
463+
"isDefault": true
464+
},
465+
"presentation": {
466+
"clear": true
467+
}
468+
},
469+
{
470+
"label": "Pixi - Rebuild MF6 (ifort, release)",
471+
"command": "${workspaceFolder}/.vscode/run_python.sh",
472+
"windows": {
473+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
474+
"args": [
475+
"${workspaceFolder}/.vscode/build_vscode.py",
476+
"--compiler",
477+
"ifort",
478+
"--buildtype",
479+
"release",
480+
"--pixi",
481+
"rebuild",
482+
],
483+
},
484+
"args": [
485+
"${workspaceFolder}/.vscode/build_vscode.py",
486+
"--compiler",
487+
"ifort",
488+
"--buildtype",
489+
"release",
490+
"--pixi"
491+
"rebuild",
492+
],
493+
"group": {
494+
"kind": "build",
495+
"isDefault": true
496+
},
497+
"presentation": {
498+
"clear": true
499+
}
500+
},
501+
{
502+
"label": "Pixi - Build MF6 (ifort, debug)",
503+
"command": "${workspaceFolder}/.vscode/run_python.sh",
504+
"windows": {
505+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
506+
"args": [
507+
"${workspaceFolder}/.vscode/build_vscode.py",
508+
"--compiler",
509+
"ifort",
510+
"--buildtype",
511+
"debug",
512+
"--pixi",
513+
"build",
514+
],
515+
"problemMatcher": "$msCompile"
516+
},
517+
"args": [
518+
"${workspaceFolder}/.vscode/build_vscode.py",
519+
"--compiler",
520+
"ifort",
521+
"--buildtype",
522+
"debug",
523+
"--pixi",
524+
"build",
525+
],
526+
"group": {
527+
"kind": "build",
528+
"isDefault": true
529+
},
530+
"presentation": {
531+
"clear": true
532+
}
533+
},
534+
{
535+
"label": "Pixi - Rebuild MF6 (ifort, debug)",
536+
"command": "${workspaceFolder}/.vscode/run_python.sh",
537+
"windows": {
538+
"command": "${workspaceFolder}/.vscode/run_python.cmd",
539+
"args": [
540+
"${workspaceFolder}/.vscode/build_vscode.py",
541+
"--compiler",
542+
"ifort",
543+
"--buildtype",
544+
"debug",
545+
"--pixi",
546+
"rebuild",
547+
],
548+
},
549+
"args": [
550+
"${workspaceFolder}/.vscode/build_vscode.py",
551+
"--compiler",
552+
"ifort",
553+
"--buildtype",
554+
"debug",
555+
"--pixi",
556+
"rebuild",
557+
],
558+
"group": {
559+
"kind": "build",
560+
"isDefault": true
561+
},
562+
"presentation": {
563+
"clear": true
564+
}
565+
},
306566
]
307567
}

pixi.toml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,44 @@ check-vfproj = "python .github/common/check_vfproj.py"
5353
check-spelling = "python .github/common/check_spelling.py"
5454
fix-style = { cmd = "pixi run check-format --write-changes; pixi run check-spelling --write-changes" }
5555

56-
# build/test
57-
setup = "meson setup --prefix=$(pwd) --libdir=bin"
56+
# meson build/test
57+
builddir = "echo _builddir"
58+
setup = "meson setup --prefix=$(pwd) --libdir=bin --bindir=bin"
5859
build = "meson install -C"
5960
test = "meson test --verbose --no-rebuild -C"
60-
update-flopy = { cmd = "python update_flopy.py", cwd = "autotest" }
61+
62+
# pytest tasks
6163
get-exes = { cmd = "pytest -v --durations 0 get_exes.py", cwd = "autotest" }
6264
autotest = { cmd = "pytest -v -n auto --durations 0 --keep-failed .failed", cwd = "autotest" }
6365

66+
# common developer tasks
67+
update-flopy = { cmd = "python update_flopy.py", cwd = "autotest" }
68+
build-makefiles = { cmd = "python build_makefiles.py", cwd = "distribution" }
69+
run-mf6ivar = { cmd = "python mf6ivar.py", cwd = "doc/mf6io/mf6ivar" }
70+
prepare-pull-request = {depends_on = ["fix-style", "build-makefiles", "run-mf6ivar"]}
71+
6472
# dist/docs
6573
benchmark = { cmd = "python benchmark.py", cwd = "distribution" }
66-
run-mf6ivar = { cmd = "python mf6ivar.py", cwd = "doc/mf6io/mf6ivar" }
6774
build-docs = { cmd = "python build_docs.py", cwd = "distribution" }
6875
build-dist = { cmd = "python build_dist.py", cwd = "distribution" }
69-
build-makefiles = { cmd = "python build_makefiles.py", cwd = "distribution" }
7076
test-dist-scripts = { cmd = "pytest -v --durations 0", cwd = "distribution" }
7177
update-version = { cmd = "python update_version.py", cwd = "distribution" }
7278
deprecations = { cmd = "python deprecations.py", cwd = "doc/mf6io/mf6ivar" }
7379
sphinx = { cmd = "make html", cwd = ".build_rtd_docs" }
7480

75-
# prepare for PR
76-
prepare-pull-request = {depends_on = ["fix-style", "build-makefiles", "run-mf6ivar"]}
81+
# os-specific tasks
82+
[target.linux-64.tasks]
83+
builddir = "echo _builddir_linux-64"
84+
85+
[target.linux-aarch64.tasks]
86+
builddir = "echo _builddir_linux-aarch64"
87+
88+
[target.osx-64.tasks]
89+
builddir = "echo _builddir_osx-64"
90+
91+
[target.osx-arm64.tasks]
92+
builddir = "echo _builddir_osx-arm64"
93+
94+
[target.win-64.tasks]
95+
builddir = "echo _builddir_win-64"
96+

0 commit comments

Comments
 (0)