Skip to content

fixing issue with missing jsonschema for python#50

Open
ge0053 wants to merge 8 commits intonix-community:masterfrom
ge0053:master
Open

fixing issue with missing jsonschema for python#50
ge0053 wants to merge 8 commits intonix-community:masterfrom
ge0053:master

Conversation

@ge0053
Copy link
Contributor

@ge0053 ge0053 commented Jan 12, 2026

when building a project i get an error from python which cant find the module jsonschema:

west build -p always -b adi_eval_adin1110ebz zephyr/samples/basic/blinky

CMake Error at zephyr/cmake/modules/boards.cmake:191 (message):
  Error finding board: adi_eval_adin1110ebz

  Error message: Traceback (most recent call last):

    File "zephyr/scripts/list_boards.py", line 13, in <module>
      import jsonschema

  ModuleNotFoundError: No module named 'jsonschema'

it would also be possible to specify that it is a necessary package in the flake file.
Tested with the example flake with these additions:

      packages=[
    zephyr-nix.packages.x86_64-linux.sdkFull-0_16
    zephyr.pythonEnv
    zephyr.hosttools
    pkgs.cmake
    pkgs.ninja
    #pkgs.python3Packages.jsonschema

      ];

pythonEnv = callPackage ./python.nix {
inherit zephyr-src;
inherit pyproject-nix;
extraPackages=_ps : [python3Packages.jsonschema];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extraPackages = ps: [ ps.west ] ++ extraPackages ps;
is the proper place for you to make this change. I would not mind making this change, but it needs to be done there, not where you did. Also, you need to rebase your codebase so you can send this against the current codebase.

@yao-yun
Copy link

yao-yun commented Mar 15, 2026

Same issue here. The dependency jsonschema is included in zephyr's requirements.txt: https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/requirements-base.txt#L15, which should be handled by pyproject-nix's parser.

However, after some poking (as is shown below), it seems that only jsonschema is left out when pyproject-nix parses the requirements.txt , which is quite strange.

Nix 2.34.0
Type :? for help.
nix-repl> :lf .
Added 15 variables.
_type, checks, githubActions, inputs, lastModified, lastModifiedDate, narHash, outPath, outputs, packages, rev, revCount, shortRev, sourceInfo, submodules

nix-repl> zephyr = builtins.fetchGit {  url = "https://github.com/zephyrproject-rtos/zephyr";  ref = "refs/tags/v4.1.0";};       

nix-repl> project = inputs.pyproject-nix.lib.project.loadRequirementsTxt { requirements = zephyr + "/scripts/requirements.txt";}

nix-repl> lib = inputs.nixpkgs.lib                                              

nix-repl> :p lib.filter (item: item.name == "canopen") project.dependencies.depe[
  {
    conditions = [ ];
    extras = [ ];
    markers = null;
    name = "canopen";
    url = null;
  }
]

nix-repl> :p lib.filter (item: item.name == "jsonschema") project.dependencies.d[ ]

nix-repl> :p lib.filter (item: item.name == "patool") project.dependencies.depen[
  {
    conditions = [ ];
    extras = [ ];
    markers = null;
    name = "patool";
    url = null;
  }
]

nix-repl> builtins.catAttrs "name" project.dependencies.dependencies            
[
  "pyelftools"
  "pyyaml"
  "pykwalify"
  "canopen"
  "packaging"
  "progress"
  "patool"
  "psutil"
  "pylink-square"
  "pyserial"
  "requests"
  "semver"
  "tqdm"
  "anytree"
  "intelhex"
  "west"
  "windows-curses"
  "colorama"
  "ply"
  "gcovr"
  "coverage"
  "pytest"
  "mypy"
  "mock"
  "junitparser"
  "pyocd"
  "tabulate"
  "natsort"
  "cbor"
  "psutil"
  "python-can"
  "anytree"
  "gitpython"
  "gitlint"
  "junit2html"
  "lpc-checksum"
  "pillow"
  "pygithub"
  "graphviz"
  "clang-format"
  "gitlint"
  "junitparser"
  "lxml"
  "pykwalify"
  "pylint"
  "python-magic-bin"
  "python-magic"
  "ruff"
  "sphinx-lint"
  "unidiff"
  "yamllint"
]  

And updating pyproject-nix 's flake rev from 02e9418f to latest 02e9418f does not address the issue, so if it is an upsteam bug, it's not fixed yet.

--

I was looking at the wrong rev, it should be https://github.com/zephyrproject-rtos/zephyr/tree/v4.1.0 and jsonschema wasn't a dep back then. In my case the error was because $WEST_WORKSPACE/zephyr and the zephyr-src tracked in flake have mismatched version. West calls a python script in the former (which depends on newly introduced jsonschema), in the environment that zephyr-nix created tracking the latter (which does not have jsonschema). @ge0053 Please check if this is also the root cause for you. If so this PR would be unnecessary...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants