PlatformIO Community

Incremental Build issue - always builds due to mismatched checksum

Hi all,

I’m new to PlatformIO and Python so be gentle with me.

I have an issue with an Arduino project whereby every build does a full build. I’ve tracked it down to:
with .platformio/penv/lib/python3.5/site-packages/platformio/…

  • commands/run.py calls clean_build_dir(build_dir, config)
  • run/helpers.py:clean_build_dir calculates and stores a checksum in buld/project.checksum. The checksum is calculated from the platformio version, the current config and the project source files. Unfortunately this is giving me a different checksum for every incremental build on my system - this is despite the fact that none of those things have changed.

The issue appears to be with project/helpers.py:compute_project_checksum and for the checksum of the config. It uses
checksum.update(hashlib_encode_data(config.to_json()))

Unfortunately, config.to_json is non-deterministic in that the order of the config sections appears to be random.

This appears to be due to project/config.py:ProjectConfig:as_dict which uses
return {s: self.items(s, as_dict=True) for s in self.sections()}
This iteration order appears to be undefined and I’m new to Python so cannot figure out how to fix it.

I did find, though, in [https://docs.python.org/3/howto/functional.html] :

Note that starting with Python 3.7, dictionary iteration order is guaranteed to be the same as the insertion order. In earlier versions, the behaviour was unspecified and could vary between implementations.

Given that I’m on 3.5.3 of Python I guess that is my problem. Can anyone recommend a code fix other than upgrading to the later python.

Many Thanks,
TonyJ

I’m using:
OS: Debian 9
Code: 1.39.2
platformio 4.1.0b4
Python 3.5.3

This is a bug and was fixed in the latest PIO Core 4.1 RC. The final release is coming today.

1 Like

Thank you. Its fantastic that PlatormIO is so well supported.