Commit 6f2ef681 authored by Martin Weinelt's avatar Martin Weinelt Committed by Jörg Thalheim
Browse files
parent be1866d6
Loading
Loading
Loading
Loading
+34 −19
Original line number Diff line number Diff line
{ stdenv, lib, python3
{ lib
, python3Packages
, fetchFromGitHub
, fetchPypi
, fetchpatch
, git
, spdx-license-list-data
, substituteAll
}:

with python3.pkgs; buildPythonApplication rec {
  pname = "platformio";

  version = "6.1.6";
with python3Packages; buildPythonApplication rec {
  pname = "platformio";
  version = "6.1.11";
  pyproject = true;

  # pypi tarballs don't contain tests - https://github.com/platformio/platformio-core/issues/1964
  src = fetchFromGitHub {
    owner = "platformio";
    repo = "platformio-core";
    rev = "v${version}";
    sha256 = "sha256-BEeMfdmAWqFbQUu8YKKrookQVgmhfZBqXnzeb2gfhms=";
    hash = "sha256-NR4UyAt8q5sUGtz1Sy6E8Of7y9WrH9xpcAWzLBeDQmo=";
  };

  outputs = [ "out" "udev" ];

  patches = [
    ./fix-searchpath.patch
    ./use-local-spdx-license-list.patch
    (substituteAll {
      src = ./interpreter.patch;
      interpreter = (python3Packages.python.withPackages (_: propagatedBuildInputs)).interpreter;
    })
    (substituteAll {
      src = ./use-local-spdx-license-list.patch;
      spdx_license_list_data = spdx-license-list-data.json;
    })
    ./missing-udev-rules-nixos.patch
    (fetchpatch {
      # restore PYTHONPATH when calling scons
      # https://github.com/platformio/platformio-core/commit/097de2be98af533578671baa903a3ae825d90b94
      url = "https://github.com/platformio/platformio-core/commit/097de2be98af533578671baa903a3ae825d90b94.patch";
      hash = "sha256-yq+/QHCkhAkFND11MbKFiiWT3oF1cHhgWj5JkYjwuY0=";
      revert = true;
    })
  ];

  postPatch = ''
    substitute platformio/package/manifest/schema.py platformio/package/manifest/schema.py \
      --subst-var-by SPDX_LICENSE_LIST_DATA '${spdx-license-list-data.json}'
  nativeBuildInputs = [
    pythonRelaxDepsHook
    setuptools
  ];

    substituteInPlace setup.py \
      --replace 'aiofiles==%s" % ("0.8.0" if PY36 else "22.1.*")' 'aiofiles"' \
      --replace 'starlette==%s" % ("0.19.1" if PY36 else "0.23.*")' 'starlette"' \
      --replace 'uvicorn==%s" % ("0.16.0" if PY36 else "0.20.*")' 'uvicorn"' \
      --replace 'tabulate==%s" % ("0.8.10" if PY36 else "0.9.*")' 'tabulate>=0.8.10,<=0.9"' \
      --replace 'wsproto==%s" % ("1.0.0" if PY36 else "1.2.*")' 'wsproto"'
  '';
  pythonRelaxDeps = true;

  propagatedBuildInputs = [
    aiofiles
@@ -52,12 +63,14 @@ with python3.pkgs; buildPythonApplication rec {
    pyserial
    requests
    semantic-version
    setuptools
    spdx-license-list-data.json
    starlette
    tabulate
    uvicorn
    wsproto
    zeroconf

  ];

  preCheck = ''
@@ -163,11 +176,13 @@ with python3.pkgs; buildPythonApplication rec {
  ]);

  passthru = {
    python = python3;
    python = python3Packages.python;
  };

  meta = with lib; {
    changelog = "https://github.com/platformio/platformio-core/releases/tag/v${version}";
    description = "An open source ecosystem for IoT development";
    downloadPage = "https://github.com/platformio/platformio-core";
    homepage = "https://platformio.org";
    license = licenses.asl20;
    maintainers = with maintainers; [ mog makefu ];
+11 −2
Original line number Diff line number Diff line
diff --git a/platformio/proc.py b/platformio/proc.py
index 80e50201..15cee5a5 100644
index 707245a1..cae17a29 100644
--- a/platformio/proc.py
+++ b/platformio/proc.py
@@ -165,7 +165,7 @@ def is_container():
 
 
 def get_pythonexe_path():
-    return os.environ.get("PYTHONEXEPATH", os.path.normpath(sys.executable))
+    return "@interpreter@"
 
 
 def copy_pythonpath_to_osenv():
@@ -181,7 +181,7 @@ def copy_pythonpath_to_osenv():
             conditions.append(isdir(join(p, "click")) or isdir(join(p, "platformio")))
             )
         if all(conditions):
             _PYTHONPATH.append(p)
-    os.environ["PYTHONPATH"] = os.pathsep.join(_PYTHONPATH)
+5 −3
Original line number Diff line number Diff line
diff --git a/platformio/exception.py b/platformio/exception.py
index ef1d3bab..445174fc 100644
index 80ffb496..ea064f97 100644
--- a/platformio/exception.py
+++ b/platformio/exception.py
@@ -57,6 +57,7 @@ class MissedUdevRules(InvalidUdevRules):
@@ -49,6 +49,7 @@ class MissedUdevRules(InvalidUdevRules):
     MESSAGE = (
         "Warning! Please install `99-platformio-udev.rules`. \nMore details: "
         "https://docs.platformio.org/en/latest/core/installation/udev-rules.html"
+        "On NixOS add the platformio-core.udev package to services.udev.packages"
+        "On NixOS set `services.udev.packages = with pkgs; [ platformio-core.udev ];`."
     )
 
 
+6 −12
Original line number Diff line number Diff line
diff --git a/platformio/package/manifest/schema.py b/platformio/package/manifest/schema.py
index 1e5f935a..26d1ac6a 100644
index 95e08108..6c2cfaed 100644
--- a/platformio/package/manifest/schema.py
+++ b/platformio/package/manifest/schema.py
@@ -276,9 +276,12 @@ class ManifestSchema(BaseSchema):
@@ -276,9 +276,6 @@ class ManifestSchema(BaseSchema):
     @staticmethod
     @memoized(expire="1h")
     def load_spdx_licenses():
-        version = "3.19"
-        version = "3.21"
-        spdx_data_url = (
-            "https://raw.githubusercontent.com/spdx/license-list-data/"
-            "v%s/json/licenses.json" % version
-            f"v{version}/json/licenses.json"
-        )
-        return json.loads(fetch_remote_content(spdx_data_url))
+        # version = "3.19"
+        # spdx_data_url = (
+            # "https://raw.githubusercontent.com/spdx/license-list-data/"
+            # "v%s/json/licenses.json" % version
+        # )
+        # return json.loads(fetch_remote_content(spdx_data_url))
+        with open("@SPDX_LICENSE_LIST_DATA@/json/licenses.json") as f:
+            spdx = json.load(f)
+        with open("@spdx_license_list_data@/json/licenses.json") as fd:
+            spdx = json.load(fd)
+        return spdx