diff --git a/ci/build.py b/ci/build.py index 7de4e1156..de9eb9d84 100755 --- a/ci/build.py +++ b/ci/build.py @@ -10,6 +10,8 @@ import sys import contextlib +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[1].as_posix()) from ci.lib.runner import ArgparseActionList, TestConfig, matrix_product diff --git a/ci/examples/blk.py b/ci/examples/blk.py index 830741687..7df91eeaf 100755 --- a/ci/examples/blk.py +++ b/ci/examples/blk.py @@ -10,6 +10,8 @@ import tempfile import types +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[2].as_posix()) from ci.lib.backends import * diff --git a/ci/examples/echo_server.py b/ci/examples/echo_server.py index 517a27a8a..1d9e860ed 100755 --- a/ci/examples/echo_server.py +++ b/ci/examples/echo_server.py @@ -7,6 +7,8 @@ from pathlib import Path import sys +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[2].as_posix()) from ci.lib.backends import * diff --git a/ci/examples/i2c.py b/ci/examples/i2c.py index d794f8922..a0daeb308 100755 --- a/ci/examples/i2c.py +++ b/ci/examples/i2c.py @@ -6,6 +6,8 @@ from pathlib import Path import sys +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[2].as_posix()) from ci.lib.backends import * diff --git a/ci/examples/i2c_bus_scan.py b/ci/examples/i2c_bus_scan.py index 59ac23b23..0b0295d5f 100755 --- a/ci/examples/i2c_bus_scan.py +++ b/ci/examples/i2c_bus_scan.py @@ -6,6 +6,8 @@ from pathlib import Path import sys +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[2].as_posix()) from ci.lib.backends import * diff --git a/ci/examples/serial.py b/ci/examples/serial.py index 7253bb6ac..e6fbe7e6d 100755 --- a/ci/examples/serial.py +++ b/ci/examples/serial.py @@ -6,6 +6,8 @@ from pathlib import Path import sys +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[2].as_posix()) from ci.lib.backends import * diff --git a/ci/examples/timer.py b/ci/examples/timer.py index cbd1ed97e..f2b0de161 100755 --- a/ci/examples/timer.py +++ b/ci/examples/timer.py @@ -6,6 +6,8 @@ from pathlib import Path import sys +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[2].as_posix()) from ci.lib.backends import * diff --git a/ci/run.py b/ci/run.py index ba8621cb1..4f554a182 100755 --- a/ci/run.py +++ b/ci/run.py @@ -7,6 +7,8 @@ from pathlib import Path import sys +assert list(map(int, sys.version.split(" ")[0].split("."))) > [3, 9, 0] + sys.path.insert(1, Path(__file__).parents[1].as_posix()) from ci.common import TestConfig, backend_fn diff --git a/flake.lock b/flake.lock index 622eca798..cd5a2fb38 100644 --- a/flake.lock +++ b/flake.lock @@ -100,9 +100,26 @@ "type": "github" } }, + "python39": { + "locked": { + "lastModified": 1742943473, + "narHash": "sha256-u7+CYuAuCiJH3scDvMV9oj3p22ygnFhTXUefXUgd/LI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c5dd43934613ae0f8ff37c59f61c507c2e8f980d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c5dd43934613ae0f8ff37c59f61c507c2e8f980d", + "type": "github" + } + }, "root": { "inputs": { "nixpkgs": "nixpkgs", + "python39": "python39", "sdfgen": "sdfgen", "zig-overlay": "zig-overlay_2" } diff --git a/flake.nix b/flake.nix index 946372f22..b5133006e 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,8 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + # Python 3.9 is not in the official repo anymore + python39.url = "github:NixOS/nixpkgs/c5dd43934613ae0f8ff37c59f61c507c2e8f980d"; zig-overlay.url = "github:mitchellh/zig-overlay"; zig-overlay.inputs.nixpkgs.follows = "nixpkgs"; sdfgen.url = "github:au-ts/microkit_sdf_gen/0.28.1"; @@ -16,6 +18,7 @@ outputs = { nixpkgs, + python39, zig-overlay, sdfgen, ... @@ -39,13 +42,16 @@ pkgs = import nixpkgs { inherit system; }; + pkgs39 = import python39 { + inherit system; + }; llvm = pkgs.llvmPackages_18; zig = zig-overlay.packages.${system}."0.15.1"; pysdfgen = sdfgen.packages.${system}.pysdfgen.override { zig = zig; - pythonPackages = pkgs.python312Packages; + pythonPackages = pkgs39.python39Packages; }; clang-complete = (pkgs.symlinkJoin { @@ -73,9 +79,16 @@ genmc = pkgs.callPackage ./ci/genmc/nix/package.nix { inherit clang-complete; llvm = pkgs.llvmPackages_20.llvm; }; - pythonTool = pkgs.python312.withPackages (ps: [ + pythonTool = pkgs39.python39.withPackages (ps: [ pysdfgen ]); + ## Fixup python and python3 resolving + pythonShim = pkgs.writeShellScriptBin "python" '' + exec ${pythonTool}/bin/python3 "$@" + ''; + python3Shim = pkgs.writeShellScriptBin "python3" '' + exec ${pythonTool}/bin/python3 "$@" + ''; in { genmc = pkgs.mkShell rec { @@ -131,6 +144,8 @@ llvm.libllvm dtc pythonTool + pythonShim + python3Shim ]; # To avoid Nix adding compiler flags that are not available on a freestanding