From patchwork Wed Jun 4 12:32:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4116 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2E9883F14C for ; Wed, 4 Jun 2025 14:32:50 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-607142010bcsf145871a12.0 for ; Wed, 04 Jun 2025 05:32:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1749040370; cv=pass; d=google.com; s=arc-20240605; b=SMTjEmIBlzB2Q1jcP2emq1gpJL1py+BhogVrqTBT9301HrgMhnFpZ+Ybh2+EAjc/kz snliGlVONL5ircXT/o91jGMnF8s2+qVpzapuSuyM0KRJwmK3YLFqll58anrCk/CJQPpI tSLiCPHnfbVFY1yXLSpMBnidPv17mjmsMP1Dsf7ypK0MyECCIhvoOe5IaGxs/2uAK7Oa fz2ORIdcu/GEVFQ1/DkfaNVPm19zX6utgyWHTyJzwck3vTarAxFnQ43T9haBhH4e9zV2 H20stFk34UfmoHfm2MvX/34kDpDGeHbjy1gVZELWctDRvm8pZG246mOe3xBWFqILrTNx ZpRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6EvNp7cChaa8YZ1EJTNxUYtG4eD7DDRsrQQLHS+8tJ8=; fh=Ij4wbAdis9t0s9mq6Rwy4gNdVOYuUGlRBP15Jf5ezJQ=; b=Ku48TyCQdlVlDY2fR/RXUL5rfuVU1Jc+tfFObaAkZfydeEbmZQZjAvTXW4lFgNKf1h vlg3XMg5eJeyOmBeKORIlWLRUoKCD6RqGhtoodh1SG5EP4tG3XFfIKb6zHYwULg8ft+Q F7fYrMhC20MMddq/SfOz7u1Q4yZM28/Jucy57Jy8ZaMI+fKtCZBwBqQLfeLx0GrVk/oj b2CfV7Y8SWEoTHolflCwKssHG3PKcd7YeDKF3oDqq/DaJkXTqQSPP/dCdsU4q/BIh1e7 3/NvgZbWbw0sEA7gIXSzO2I4b6skud33c+uuj70sbFfGp/XBq+L4xDJnGTa7oLuibgUx UkKQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ga72Gezm; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1749040370; x=1749645170; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:content-transfer-encoding:mime-version:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6EvNp7cChaa8YZ1EJTNxUYtG4eD7DDRsrQQLHS+8tJ8=; b=eZYuN/9pxMLrahRBGHt3UYAoXWcqEJJolT724W1hZnOdrucrRDJWuiP1goGPd+pH+s bUeog5M4gBs002aSFYOLVP2gTTMSvHNMCHjhMV8yiZTwNX+ORQoGYmZ8HgDJbxqo0vVc FnJQkaa8lhjzhHARxTXXT4S3f/ZI7iDveD47g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749040370; x=1749645170; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6EvNp7cChaa8YZ1EJTNxUYtG4eD7DDRsrQQLHS+8tJ8=; b=F6E0OehdwOjjTPTtWKXFUMNpLQMSPffbDBBEpHVTdHsi8XKkBmGXttyRQCLuszIdVm fIQdsuwWLGypDFnJFh/+Ckub4NWs12H6l36z8/g/KI8DDBgeTKrYxHSZosLpqGavuKIl /A65ITC0h9/a/1YZt9ucZB905DmgldRwNeUEbC3pj8cf80912sDFdwvEyazFMnYRIYFn Bq0QZCvMeyeuGus0jYY5s402jsdu5oCqIVEpb84/WpSqE+yZs+tXZM2e7UaTrw9l1RRt 1XKwdQckDc5FI83hwJ/sSCQcSepUJLvLRt7Btt5xXOIpXYPiFU5P8mUcRAa7FN1mSwN2 5DvQ== X-Forwarded-Encrypted: i=2; AJvYcCXLS/A05bJY1qYYbkJIa+CSyOGBvDlsVK1p8/4awTRS/teaqCpc0eoENMcgHPGYktmenBBAfvwQKTBBNV9I@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzdTrjAjPtNWf7ZGBh4liTAl3uLXqDaamlWeO9+NczR/4xTWir9 mLdavDBxkZtblLw601390tj8DtuiF16QLFPSAd2Xjl7Cd5XZSWeqRPvvBrvdWs15NndIww== X-Google-Smtp-Source: AGHT+IHT6b4qoA2rYCK0x+R8S70NHNNRH+ck3x4o6jeFihHvh5+kAnl/uFXChiuNUhMYH/GUXModeQ== X-Received: by 2002:a05:6402:363:b0:606:d25c:c779 with SMTP id 4fb4d7f45d1cf-606ea3a3729mr2268434a12.34.1749040369581; Wed, 04 Jun 2025 05:32:49 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h=AZMbMZcKAPOQnsYFR9vyGgD4e2zodvu9dTUWIW1//a2qRJbVdg== Received: by 2002:a05:6402:50cb:b0:606:d4d3:54e9 with SMTP id 4fb4d7f45d1cf-606d4d37717ls1189087a12.0.-pod-prod-07-eu; Wed, 04 Jun 2025 05:32:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV1BBVhHhAKRdZ3LpvGqwNdX+fsejy+HpyJKu3QsmeBDe8RyDYREDIALKVl0PLIoVlK+EsJKgKkpLEuhh3/@amarulasolutions.com X-Received: by 2002:a17:906:dc93:b0:ad2:43b6:dd75 with SMTP id a640c23a62f3a-addf8c9b356mr236991766b.10.1749040367369; Wed, 04 Jun 2025 05:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1749040367; cv=none; d=google.com; s=arc-20240605; b=W7S7EeQzIDKZ7YDajGtjoUrCr4iSV6pggyfaPDTvZb5ZatrrrObXbBgbQ51m8HhE6r fTTbjRhangI+HlMucqUa9evhhTEA/4Tql8UKBdpjX9XZrESwCyXgP7+4XCVTruaK80A2 tEHrMcHfONI8MKIfy79GGUiQ9r1qntkKblwXwyTNscfzWkaOWeqqdf3KshvUXMgnTnxJ JBhTuUdUN08SGi3CeB5ePHeMS73hV9WK1OZ2GpJnxnatiya1ghHPRNMwp4xQigNe6iB2 UMzaKySreIZEoDcNLeijkSDHqiAFgUNhIZyyNtm+6zGuV4t+OZDFomckfwnJCaU9Eo/5 ReOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=o/jLhADVMD+wMwINBmr92BrEF0szp1c97gficDDqSAc=; fh=2qbdPGO8lOmv2L1NFjckfC2vWW+C3LSl6sw0NMyl7Y0=; b=ThZ2WMIAqstZm87Rn/RwDFEHEWT38D4vTvP0ctHUmJW30Ld5vcS2oO58rQjnttfXNB 7EaTrsbZidm/JEqHH5gC82s+eQddGO/gGSc2WWjoEQyjWuPJtOXGbsb1HR8AUom3G0Za Qc2/Cs8zUWAIpmiy/xh2i+btgiQbsXxSpPdPPnFCEGb6J3F0Ora6HxYO4unljL8BDD5W u3TZnso3Udm4OUXuN18VcX91DNUSK87KQweB+L/kQfetAxwuQ6DGpXHHTJJlJQ+B/kZ8 uMWKtHP8mUQW0neOu1onnYEYUBuaBaHoIat4tUOt6cHrWEdNIBcErXW4SAI5bsU4qYwc Rcdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ga72Gezm; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a640c23a62f3a-adde529569dsor196747866b.5.2025.06.04.05.32.47 for (Google Transport Security); Wed, 04 Jun 2025 05:32:47 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCU3oGTS5MD+N/4iwRiGXLVL18wKixQvm1hmdMFxX6eEtncW2hz8+D6TBzRbssdamWIUL9Y6u4cTK1xAYbB8@amarulasolutions.com X-Gm-Gg: ASbGncufhBJRKC2UZSa/t1DeB9oQkiJy3tWM8xKLOubjViBEDkol4hCR77u9OCMwL8C t81K19IdEOVSbiLNxn5XruK0npWkpQCqqOyZ3oQzjHkj9pgwkronQt3a86DfF45hPXPVKTAvSgB LtHe+n+GxSOo1ttGhoHNuK4q/us4CITdnWrPXmYKSTc7PcGFiNmLyMifL6CU8y9ocpb4FZbCpaF +aevnnaqV+4FB1HlunrXVXJecmWN4ETP730Wip7CjH59iBIrltsWhEc005k66/k7R1/zXkT3JJz jzjJVHNkkJOqq/r9mygUoHwhD8rcSFRC9/nzmqFGKpCY6oeqU9+eLg8LRFjb+26yrBDqBB1jrTP B9PC2A+nW9E5Uo1mZHCIVpdePzQ== X-Received: by 2002:a17:907:c13:b0:ad8:9ab7:a270 with SMTP id a640c23a62f3a-addf8e986e3mr239123166b.38.1749040366863; Wed, 04 Jun 2025 05:32:46 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.41.46]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ada5d7fed8bsm1097095666b.28.2025.06.04.05.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jun 2025 05:32:46 -0700 (PDT) From: Dario Binacchi To: buildroot@buildroot.org Cc: Dario Binacchi , linux-amarula@amarulasolutions.com Subject: [PATCH v3 1/2] package/pocketpy: new package Date: Wed, 4 Jun 2025 14:32:40 +0200 Message-ID: <20250604123243.420711-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ga72Gezm; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , It is a portable Python 3.x interpreter, written in C11. It has no dependencies other than the C standard library, which can be easily integrated into your C/C++ project Signed-off-by: Dario Binacchi --- Changes v2 -> v3: - Add package/pocketpy/0001-Fix-getchar-helper.patch. - Add depends on !BR2_STATIC_LIBS for dlfcn.h Changes v1 -> v2: - mv staging commands under POCKETPY_INSTALL_STAGING_CMDS hook. DEVELOPERS | 1 + package/Config.in | 1 + .../pocketpy/0001-Fix-getchar-helper.patch | 91 +++++++++++++++++++ package/pocketpy/Config.in | 9 ++ package/pocketpy/pocketpy.hash | 3 + package/pocketpy/pocketpy.mk | 25 +++++ 6 files changed, 130 insertions(+) create mode 100644 package/pocketpy/0001-Fix-getchar-helper.patch create mode 100644 package/pocketpy/Config.in create mode 100644 package/pocketpy/pocketpy.hash create mode 100644 package/pocketpy/pocketpy.mk diff --git a/DEVELOPERS b/DEVELOPERS index a7bb3bd83460..46d24afceb71 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -811,6 +811,7 @@ F: package/armadillo/ F: package/babeld/ F: package/iana-assignments/ F: package/inih/ +F: package/pocketpy/ F: package/sscep/ F: package/tinyinit/ F: package/ufs-utils/ diff --git a/package/Config.in b/package/Config.in index 579b5ffc87d5..9aad65488a6c 100644 --- a/package/Config.in +++ b/package/Config.in @@ -968,6 +968,7 @@ if BR2_STATIC_LIBS comment "External PHP extensions need a toolchain w/ dynamic library" endif endif + source "package/pocketpy/Config.in" source "package/python3/Config.in" if BR2_PACKAGE_PYTHON3 menu "External python modules" diff --git a/package/pocketpy/0001-Fix-getchar-helper.patch b/package/pocketpy/0001-Fix-getchar-helper.patch new file mode 100644 index 000000000000..4247c0590b6d --- /dev/null +++ b/package/pocketpy/0001-Fix-getchar-helper.patch @@ -0,0 +1,91 @@ +From 3a35bd3285936c99875da3f57c44de3ef85e3022 Mon Sep 17 00:00:00 2001 +From: Dario Binacchi +Date: Wed, 4 Jun 2025 12:19:22 +0200 +Subject: [PATCH] Fix getchar() helper +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The getchar() function is defined as a macro in uClibc, raising the +next following errors: + +>>> pocketpy 2.0.8 Building +GIT_DIR=. PATH="/builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/host/bin:/builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" /usr/bin/cmake --build /builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/ -j3 -- +[ 50%] Building C object CMakeFiles/pocketpy.dir/Unity/unity_pocketpy_c.c.o +In file included from /builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/host/arc-buildroot-linux-uclibc/sysroot/usr/include/stdio.h:71, + from /builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/include/pocketpy/common/utils.h:3, + from /builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/include/pocketpy/common/str.h:4, + from /builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/include/pocketpy/common/smallmap.h:4, + from /builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/src/common/smallmap.c:1, + from /builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/CMakeFiles/pocketpy.dir/Unity/unity_pocketpy_c.c:9: +/builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/src/interpreter/vm.c: In function ‘py_replinput’: +/builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/src/interpreter/vm.c:813:42: error: expected identifier before ‘(’ token + 813 | int c = pk_current_vm->callbacks.getchar(); + | ^~~~~~~ +/builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/src/interpreter/vm.c:813:42: error: expected statement before ‘)’ token + 813 | int c = pk_current_vm->callbacks.getchar(); + | ^~~~~~~ +/builds/jolivain/buildroot/br-test-pkg/bootlin-arcle-hs38-uclibc/build/pocketpy-2.0.8/src/interpreter/vm.c:813:42: error: expected statement before ‘)’ token + 813 | int c = pk_current_vm->callbacks.getchar(); + +Link: https://gitlab.com/jolivain/buildroot/-/pipelines/1847795347 +Link: https://gitlab.com/jolivain/buildroot/-/jobs/10217736977 +Signed-off-by: Dario Binacchi +Upstream: backport from https://github.com/pocketpy/pocketpy/pull/371 +--- + include/pocketpy/pocketpy.h | 2 +- + src/interpreter/vm.c | 4 ++-- + src/public/modules.c | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h +index a44faa41a922..2d6d2ff4aad7 100644 +--- a/include/pocketpy/pocketpy.h ++++ b/include/pocketpy/pocketpy.h +@@ -69,7 +69,7 @@ typedef struct py_Callbacks { + /// Used by `print` to output a string. + void (*print)(const char*); + /// Used by `input` to get a character. +- int (*getchar)(); ++ int (*getch)(); + } py_Callbacks; + + /// Native function signature. +diff --git a/src/interpreter/vm.c b/src/interpreter/vm.c +index 2bae82740ac7..1a69d9dffd11 100644 +--- a/src/interpreter/vm.c ++++ b/src/interpreter/vm.c +@@ -67,7 +67,7 @@ void VM__ctor(VM* self) { + + self->callbacks.importfile = pk_default_importfile; + self->callbacks.print = pk_default_print; +- self->callbacks.getchar = getchar; ++ self->callbacks.getch = getchar; + + self->last_retval = *py_NIL(); + self->curr_exception = *py_NIL(); +@@ -810,7 +810,7 @@ int py_replinput(char* buf, int max_size) { + printf(">>> "); + + while(true) { +- int c = pk_current_vm->callbacks.getchar(); ++ int c = pk_current_vm->callbacks.getch(); + if(c == EOF) return -1; + + if(c == '\n') { +diff --git a/src/public/modules.c b/src/public/modules.c +index 3efb362701e2..257726b7c539 100644 +--- a/src/public/modules.c ++++ b/src/public/modules.c +@@ -205,7 +205,7 @@ static bool builtins_input(int argc, py_Ref argv) { + c11_sbuf buf; + c11_sbuf__ctor(&buf); + while(true) { +- int c = pk_current_vm->callbacks.getchar(); ++ int c = pk_current_vm->callbacks.getch(); + if(c == '\n' || c == '\r') break; + if(c == EOF) break; + c11_sbuf__write_char(&buf, c); +-- +2.43.0 + diff --git a/package/pocketpy/Config.in b/package/pocketpy/Config.in new file mode 100644 index 000000000000..b0bd0cafe008 --- /dev/null +++ b/package/pocketpy/Config.in @@ -0,0 +1,9 @@ +config BR2_PACKAGE_POCKETPY + bool "pocketpy" + depends on BR2_INSTALL_LIBSTDCPP + depends on !BR2_STATIC_LIBS # dlfcn.h + help + pocketpy is a portable Python 3.x interpreter, + written in C11. + + https://github.com/pocketpy/pocketpy diff --git a/package/pocketpy/pocketpy.hash b/package/pocketpy/pocketpy.hash new file mode 100644 index 000000000000..aabd5f077a2b --- /dev/null +++ b/package/pocketpy/pocketpy.hash @@ -0,0 +1,3 @@ +# locally computed +sha256 5e07994d66311a6b5ac032cc5243aaabe3ab318946971e7fa1cd0614934efc81 pocketpy-2.0.8.tar.gz +sha256 d3a2bf8ca609a75941e980e62c13cf5a21aeaa4a2502822934d282fe7de5d319 LICENSE diff --git a/package/pocketpy/pocketpy.mk b/package/pocketpy/pocketpy.mk new file mode 100644 index 000000000000..20a8e9ad1e20 --- /dev/null +++ b/package/pocketpy/pocketpy.mk @@ -0,0 +1,25 @@ +################################################################################ +# +# pocketpy +# +################################################################################ + +POCKETPY_VERSION = 2.0.8 +POCKETPY_SITE = $(call github,pocketpy,pocketpy,v$(POCKETPY_VERSION)) +POCKETPY_LICENSE = MIT +POCKETPY_LICENSE_FILES = LICENSE +POCKETPY_INSTALL_STAGING = YES + +POCKETPY_CONF_OPTS = -DPK_BUILD_SHARED_LIB=ON + +define POCKETPY_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/libpocketpy.so* $(TARGET_DIR)/usr/lib +endef + +define POCKETPY_INSTALL_STAGING_CMDS + $(INSTALL) -D -m 0755 $(@D)/libpocketpy.so* $(STAGING_DIR)/usr/lib + $(INSTALL) -m 755 -d $(STAGING_DIR)/usr/include/pocketpy + cp -r $(@D)/include/* $(STAGING_DIR)/usr/include/pocketpy +endef + +$(eval $(cmake-package))