PlatformIO Community

Question regarding platform.json

Hi team,
In platform.json we specify packages with version only.
what if I have a tool with two different versions for windows and linux system how do I specify in platform.json so that correct version loads based on system type
e.g. for windows my tool say tool-abc has version 3.2.0
and for linux or mac os tool version is 1.2.0

how do I specify this based on system type in platform.json file?
currently only one version can be specified.

alternatively, is there a way to check current system type in builder script, then maybe I can use different tool name for windows and linux/macos

There are multiple ways how to do this. See example

You can use from platformio import util -> util.get_systype() to get system type.

Thanks @ivankravets
Just to get some more clarity:
you’re suggesting not to mention tool name/version in platform.json, instead while loading the platform, I can check system type and load the tool accordingly. hope I am getting it correctly?
e.g. (pseudo code)

self.packages["tool-abc"]["version"] = get_systype() == "windows" ? "3.2.0" : "1.2.0";

Should be

self.packages["tool-abc"]["version"] = "3.2.0" if "windows" in util.get_systype() else "1.2.0"

Please note that you can also pass multiple version to package specification:

"version": "3.2.0,1.2.0"

PlatformIO will look for any version requirement declared using SemVer.

That solves most of my problems :slight_smile:
Can we also do this way?

 "version": "~3.2.0,~1.2.0"

Hi @ivankravets, I think ~ does not work when specifying two different versions. I maybe wrong but it did not work for me. I got error

Error: Could not find a version that satisfies the requirement '~1.3.0,~0.2.0' for your system 'linux_x86_64'

So I dropped the idea of having same tool name. I renamed the python based tool to tool-pysiwiflasher and windows remains as it is tool-siwiflasher.

so manifest.json looks like

"tool-pysiwiflasher": [
		"sha1": "6f3c7030b09859350cd0537088cfb331abfdc996",
		"system": "*",
		"url": "",
		"version": "0.2.0"

Now in platform.json

"tool-siwiflasher": {
		"type": "uploader",
		"optional": true,
		"version": "~1.3.0"
"tool-pysiwiflasher": {
		"type": "uploader",
		"optional": true,
		"version": "~0.2.0"

But package manager always try to install tool-siwiflasher, and fails.

PackageManager: Installing tool-siwiflasher @ ~1.3.0
Error: Could not find a version that satisfies the requirement '~1.3.0' for your system 'linux_x86_64'

It does not even try the other tool. why is that?

Looking at the issue here, I think it is best if platform.json also has system field for packages. So that right package gets installed for build system type.