<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15312</bug_id>
          
          <creation_ts>2023-12-07 22:40:04 +0000</creation_ts>
          <short_desc>python3-maturin: Add &apos;maturin&apos; PEP-517 backend support</short_desc>
          <delta_ts>2023-12-17 20:15:47 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>5.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>5.0 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Orling">tim.orling</reporter>
          <assigned_to name="Tim Orling">tim.orling</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>pascal.bach</cc>
    
    <cc>ross.burton</cc>
    
    <cc>warthog9</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>97450</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2023-12-07 22:40:04 +0000</bug_when>
    <thetext>We are increasingly seeing Rust extensions for Python added in the
ecosystem. The current best practices approach has moved from using
&apos;setuptools-rust&apos; to using &apos;maturin&apos; [1].

We absolutely need to make sure this makes it into the future LTS release (5.0 &quot;scarthgap&quot;).

* python3-pydantic now requires python3-pydantic-core which is built with &apos;maturin&apos; [2]
* python3-orjson [3] is now commonly being used for JSON support
* python3-ruff [4] is a (very fast) Python linter and is increasingly being used

[1] https://pypi.org/project/maturin/
[2] https://pypi.org/project/pydantic-core/
[3] https://pypi.org/project/orjson/
[4] https://pypi.org/project/ruff/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97451</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2023-12-07 22:41:18 +0000</bug_when>
    <thetext>WIP:
https://git.yoctoproject.org/poky-contrib/log/?h=timo/maturin_1.3.2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97454</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2023-12-07 23:29:47 +0000</bug_when>
    <thetext>https://patchwork.yoctoproject.org/project/oe-core/patch/cover.1701989368.git.tim.orling@konsulko.com/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97455</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2023-12-07 23:32:47 +0000</bug_when>
    <thetext>An additional (much deeper) functional test is at the tip of:
https://git.yoctoproject.org/poky-contrib/log/?h=timo/maturin_wip

https://git.yoctoproject.org/poky-contrib/commit/?h=timo/maturin_wip&amp;id=395521b21afc2be8298ab16ca2c2ad3a75c28864

But that is currently failing for Rust _reasons_, not related to the
test case most likely. Put that test case on a back burner for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97534</commentid>
    <comment_count>4</comment_count>
    <who name="Pascal Bach">pascal.bach</who>
    <bug_when>2023-12-12 08:16:55 +0000</bug_when>
    <thetext>I was able to build https://github.com/eclipse-zenoh/zenoh-python using the https://git.yoctoproject.org/poky-contrib/log/?h=timo/maturin_1.4.0 branch.

I had to run `bitbake python3-maturin-native -c update_crates` as the crate list seems to have been out of date. Everything else worked.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97551</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2023-12-12 18:36:00 +0000</bug_when>
    <thetext>@Pascal:
Thank you for reminding me of the &quot;obvious&quot;. I was just banging my head on the fetch failure...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97604</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2023-12-17 20:15:47 +0000</bug_when>
    <thetext>https://lore.kernel.org/openembedded-core/cover.1702791173.git.tim.orling@konsulko.com/T/#t

https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/6341
(failures were completely unrelated to maturin)

Merged as of commit:
https://git.yoctoproject.org/poky/commit/?id=7d881f0214f9761990e52595d33246700c4da15c


From the prior series, the main issue was the bzip2-sys crate needed a debug path mapping from CARGO_HOME (used TARGET_DBGSRC_DIR/cargo_home/ as the mapped path) in order to not inject TMPDIR into DW_AT_dir in /usr/bin/.debug/maturin (which also had the side effect of causing reordering). This resulted in a non-reproducible build.

The solution that actually worked was to set the path mapping in CFLAGS (both a patch to build.rs in bzip2-sys and higher level RUST_DEBUG_REMAP were also attempted).
CFLAGS:append = &quot;-fdebug-prefix-map=${CARGO_HOME}=${TARGET_DBGSRC_DIR}/cargo_home&quot;

The second issue was figuring out how to get the &apos;maturin develop&apos; testsdk case to not be skipped, which requires a full Rust environment in the SDK. This turned out to be two things in addition to TOOLCHAIN_HOST_TASK (which are set on the AB):
TOOLCHAIN_HOST_TASK:append = &quot; nativesdk-python3-maturin&quot;
SDK_INCLUDE_TOOLCHAIN = &apos;1&apos;
SDK_TOOLCHAIN_LANGS += &apos;rust&apos;

testimage and testsdk were tested on qemux86-64 and qemuarm64.
rust.RustCompileTest.test_cargo_build and
maturin.MaturinDevelopTest.test_maturin_develop failed on qemuarm64 (SDKMACHINE x86_64 and i686).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>