public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Gyorgy Sarvari <skandigraun@gmail.com>
To: Tom Geelen <t.f.g.geelen@gmail.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] How to have multiple rust cargo vendors
Date: Fri, 3 Oct 2025 14:39:44 +0200	[thread overview]
Message-ID: <6db7fc77-9c35-4f5a-90c4-b0f3c9e983ba@gmail.com> (raw)
In-Reply-To: <CAJo0Az40OEnqyuzU_G3uvyf_+bB=+TRd-tsoHDUoGs9xduJ78A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3594 bytes --]

On 10/2/25 22:39, Tom Geelen wrote:
> Ah that would be great. Actually I had seen the firefox recipes and
> did notice something which looked like something what I would be
> needing. So if you could send an RFC that would be awesome.

I found it my patch... but for some reason it doesn't work with your
recipe :D
I think that my change does what I intended it to do, but maturin still
tries to fetch the workspace crate from the network, just like without
my patch. Going look into this a bit deeper, if I can... will get back.

> On Thu, Oct 2, 2025 at 10:33 PM Gyorgy Sarvari <skandigraun@gmail.com> wrote:
>> On 10/2/25 22:17, Gyorgy Sarvari via lists.openembedded.org wrote:
>>> You can add those in the SRC_URI, as regular git repos, with +=. Make
>>> sure to set the "name" parameter to the crate name, and set the
>>> "destsuffix" to ensure the sources won't mix. After do_configure step
>>> one of the cargo/rust classes will go through the SRC_URI content, and
>>> add these git-crates to the cargo config as local patches.
>> Oh, now I see that this is a workspace - sorry for not looking closer
>> before.
>>
>> At this time cargo_common doesn't support workspaces from git crates...
>>
>> I find it interesting on a personal level, because I just implemented
>> workspace support like 2 weeks ago, but couldn't find any project using
>> workspace crates from git beside Firefox, and didn't want to submit it
>> only for that. (And since Firefox recipe switched away too)
>>
>> If I find my implementation again, will submit it tomorrow as an RFC.
>>
>>> On 10/2/25 21:40, Tom Geelen via lists.openembedded.org wrote:
>>>> I'm trying to create a recipe for uv (https://docs.astral.sh/uv/) to
>>>> be added to meta-python.
>>>> Problem I currently cannot seem to resolve is that I need multiple
>>>> cargo vendor support.
>>>>
>>>> I have created the draft recipe and added the inc file with the crates
>>>> using the update-crates command.
>>>> However it missed several crates as they are not from crates.io but
>>>> via git (see below).
>>>>
>>>> How would I add this to the recipe below?
>>>>
>>>> SUMMARY = "An extremely fast Python package and project manager,
>>>> written in Rust."
>>>> HOMEPAGE = "https://pypi.org/project/uv/"
>>>> LICENSE = "Apache-2.0 & BSD-2-Clause & MIT"
>>>> LIC_FILES_CHKSUM = "file://LICENSE-APACHE;md5=86d3f3a95c324c9479bd8986968f4327 \
>>>>                     file://LICENSE-MIT;md5=45674e482567aa99fe883d3270b11184"
>>>> RECIPE_MAINTAINER = "Tom Geelen <t.f.g.geelen@gmail.com>"
>>>>
>>>> SRC_URI[sha256sum] =
>>>> "e6e1289c411d43e0ca245f46e76457f3807de646d90b656591b6cf46348bed5c"
>>>>
>>>> inherit pypi python_maturin cargo-update-recipe-crates
>>>>
>>>> require ${BPN}-crates.inc
>>>>
>>>> SRCREV = "d8efd77673c9a90792da9da31b6c0da7ea8a324b"
>>>>
>>>> PYPI_PACKAGE = "uv"
>>>>
>>>>
>>>> [[package]]
>>>> name = "version-ranges"
>>>> version = "0.1.1"
>>>> source = "git+https://github.com/astral-sh/pubgrub?rev=d8efd77673c9a90792da9da31b6c0da7ea8a324b#d8efd77673c9a90792da9da31b6c0da7ea8a324b"
>>>> dependencies = [
>>>>  "smallvec",
>>>> ]
>>>>
>>>> Regards,
>>>>
>>>> Tom
>>>>
>>>>
>>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>> View/Reply Online (#224380): https://lists.openembedded.org/g/openembedded-core/message/224380
>>> Mute This Topic: https://lists.openembedded.org/mt/115558933/6084445
>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [skandigraun@gmail.com]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>

[-- Attachment #2: 0001-cargo_common-add-workspace-support.patch --]
[-- Type: text/x-patch, Size: 3233 bytes --]

From 32ccddbd097f2bb7480df692ae386c304dd456f0 Mon Sep 17 00:00:00 2001
From: Gyorgy Sarvari <skandigraun@gmail.com>
Date: Fri, 3 Oct 2025 14:29:48 +0200
Subject: [PATCH] cargo_common: add workspace support

WIP

---
 meta/classes-recipe/cargo_common.bbclass | 41 +++++++++++++++++++-----
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git a/meta/classes-recipe/cargo_common.bbclass b/meta/classes-recipe/cargo_common.bbclass
index c9eb2d09a5..a69b962dba 100644
--- a/meta/classes-recipe/cargo_common.bbclass
+++ b/meta/classes-recipe/cargo_common.bbclass
@@ -129,6 +129,20 @@ cargo_common_do_configure () {
 python cargo_common_do_patch_paths() {
     import shutil
 
+    def load_cargo_toml(cargo_toml_path):
+        import tomllib
+        with open(cargo_toml_path, "rb") as f:
+            cargo_toml = tomllib.load(f)
+        return cargo_toml
+
+    def add_to_patches(patches, ud, name, path):
+        if ud.user:
+            repo = '%s://%s@%s%s' % (ud.proto, ud.user, ud.host, ud.path)
+        else:
+            repo = '%s://%s%s' % (ud.proto, ud.host, ud.path)
+        path = '%s = { path = "%s" }' % (name, path)
+        patches.setdefault(repo, []).append(path)
+
     cargo_config = os.path.join(d.getVar("CARGO_HOME"), "config.toml")
     if not os.path.exists(cargo_config):
         return
@@ -143,15 +157,26 @@ python cargo_common_do_patch_paths() {
     for url in fetcher.urls:
         ud = fetcher.ud[url]
         if ud.type == 'git' or ud.type == 'gitsm':
-            name = ud.parm.get('name')
             destsuffix = ud.parm.get('destsuffix')
-            if name is not None and destsuffix is not None:
-                if ud.user:
-                    repo = '%s://%s@%s%s' % (ud.proto, ud.user, ud.host, ud.path)
-                else:
-                    repo = '%s://%s%s' % (ud.proto, ud.host, ud.path)
-                path = '%s = { path = "%s" }' % (name, os.path.join(workdir, destsuffix))
-                patches.setdefault(repo, []).append(path)
+            if destsuffix is None:
+                continue
+
+            top_cargo_toml_path = os.path.join(workdir, destsuffix, 'Cargo.toml')
+            if os.path.exists(top_cargo_toml_path):
+                cargo_toml = load_cargo_toml(top_cargo_toml_path)
+                if 'workspace' in cargo_toml:
+                    ws_members = cargo_toml['workspace']['members']
+                    for ws_member in ws_members:
+                        member_crate_folder = os.path.join(workdir, destsuffix, ws_member)
+                        member_cargo_toml_path = os.path.join(member_crate_folder, 'Cargo.toml')
+                        member_cargo_toml = load_cargo_toml(member_cargo_toml_path)
+                        member_crate_name = member_cargo_toml['package']['name']
+                        add_to_patches(patches, ud, member_crate_name, member_crate_folder)
+
+                if 'package' in cargo_toml:
+                    crate_name = cargo_toml['package']['name']
+                    crate_folder = os.path.join(workdir, destsuffix)
+                    add_to_patches(patches, ud, crate_name, crate_folder)
 
     with open(cargo_config, "a+") as config:
         for k, v in patches.items():

  reply	other threads:[~2025-10-03 12:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02 19:40 How to have multiple rust cargo vendors Tom Geelen
2025-10-02 20:17 ` [OE-core] " Gyorgy Sarvari
     [not found] ` <186AC5F2410FD5FD.16131@lists.openembedded.org>
2025-10-02 20:33   ` Gyorgy Sarvari
2025-10-02 20:39     ` Tom Geelen
2025-10-03 12:39       ` Gyorgy Sarvari [this message]
2025-10-03 19:38         ` Tom Geelen
2025-10-03 21:40           ` Gyorgy Sarvari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6db7fc77-9c35-4f5a-90c4-b0f3c9e983ba@gmail.com \
    --to=skandigraun@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=t.f.g.geelen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox