Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
python/rust ebuild with maturin - GIT_CRATES issue [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
xiwi
n00b
n00b


Joined: 21 Aug 2024
Posts: 2

PostPosted: Wed Aug 21, 2024 10:55 am    Post subject: python/rust ebuild with maturin - GIT_CRATES issue [SOLVED] Reply with quote

Hello,

I've been trying to make an up-to-date ebuild for mitmproxy (the current package in the gentoo repo is unmaintained and out of date), and I'm running into an issue for a dependency mitmproxy_rs (which replaces mitmproxy_wireguard). It uses "Maturin" as it's build back-end, but I don't understand how it has to work with a GIT_CRATES declaration.

mitmproxy_rs ebuild
build.log
emerge --info output


So it seems to me that Maturin is trying to get the git dependency itself rather than using the one provided by portage? I looked at the documentation of Maturin, but it did not make me any wiser.

Thanks!


Last edited by xiwi on Sat Aug 24, 2024 5:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
salahx
Guru
Guru


Joined: 12 Mar 2005
Posts: 556

PostPosted: Wed Aug 21, 2024 4:50 pm    Post subject: Reply with quote

The problem is this construction in Cargo.toml:

[patch.crates-io]
# tokio = { path = "../tokio/tokio" }
smoltcp = { git = 'https://github.com/smoltcp-rs/smoltcp', rev = 'ef67e7b46cabf49783053cbf68d8671ed97ff8d4' }
boringtun = { git = 'https://github.com/cloudflare/boringtun', rev = 'e3252d9c4f4c8fc628995330f45369effd4660a1' }

What this does is it tells cargo to patch the upstream frozen sources with unreleased git sources, which is cannot do offline. You need to patch Cargo.toml in src_prepare with sed.

See the dev-python/uv ebuild and https://github.com/robert7k/gentoo-overlay/blob/master/app-editors/zed/zed-0.149.3.ebuild for some idea how to patch around this.
Back to top
View user's profile Send private message
salahx
Guru
Guru


Joined: 12 Mar 2005
Posts: 556

PostPosted: Wed Aug 21, 2024 11:26 pm    Post subject: Reply with quote

This was my solution I used in an old ebuild:

Code:
src_prepare() {
   local crate commit mypath _uri sedexpr
   local -a sedexpr
   for crate in "${!GIT_CRATES[@]}"; do
      IFS=";" read -r _uri commit mypath <<< "${GIT_CRATES[${crate}]}"
      if [ -z "${mypath}" ]; then
         mypath="${crate}-%commit%"
      fi
      sedexpr+=(
         "s@^(${crate}[[:space:]]*=[[:space:]]*[{].*)([[:space:]]*git[[:space:]]*=[[:space:]]*\"[[:graph:]]+\"[[:space:]]*)(.*[}])@\1path = \"${WORKDIR}/${mypath//%commit%/${commit}}\"\3@ ;"
         "s@^(${crate}[[:space:]]*=[[:space:]]*[{].*)([[:space:]]*git[[:space:]]*=[[:space:]]*'[[:graph:]]+'[[:space:]]*)(.*[}])@\1path = '${WORKDIR}/${mypath//%commit%/${commit}}'\3@ ;"
         "s@^(${crate}[[:space:]]*=[[:space:]]*[{].*)([,][[:space:]]*rev[[:space:]]*=[[:space:]]*\"[[:graph:]]+\"[[:space:]]*)(.*[}])@\1\3@ ;"
      )
   done
   sed -r -i "${sedexpr[*]}" "${S}/Cargo.toml" || die

        default
}
Back to top
View user's profile Send private message
xiwi
n00b
n00b


Joined: 21 Aug 2024
Posts: 2

PostPosted: Sat Aug 24, 2024 5:00 pm    Post subject: Reply with quote

Thanks, I got it working with
Code:

src_prepare() {
   local COMMIT="ef67e7b46cabf49783053cbf68d8671ed97ff8d4"
   sed -i -e "/^\[patch/,\$s@^\(smoltcp = \).*@\1 { path = \"${WORKDIR}/smoltcp-${COMMIT}/\" }@" Cargo.toml || die
   default

}


I got the rest working but i need to clean the ebuild up a bit :roll:
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2849

PostPosted: Sat Aug 24, 2024 5:08 pm    Post subject: Reply with quote

Yeah upstreams using [patch] with a git crate been becoming more common, unfortunately eclass doesn't have a clean solution to deal with that at the moment so a sed/patch is the best one can do.

Thankfully [patch] tend to be temporary and may be able to drop the hack on a future bump.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum