View previous topic :: View next topic |
Author |
Message |
xiwi n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 21 Aug 2024 Posts: 2
|
Posted: Wed Aug 21, 2024 10:55 am Post subject: python/rust ebuild with maturin - GIT_CRATES issue [SOLVED] |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
salahx Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 12 Mar 2005 Posts: 556
|
Posted: Wed Aug 21, 2024 4:50 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
salahx Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
Joined: 12 Mar 2005 Posts: 556
|
Posted: Wed Aug 21, 2024 11:26 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
xiwi n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 21 Aug 2024 Posts: 2
|
Posted: Sat Aug 24, 2024 5:00 pm Post subject: |
|
|
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 ![Rolling Eyes :roll:](images/smiles/icon_rolleyes.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Ionen Developer
![Developer Developer](/images/ranks/rank-dev.gif)
![](images/avatars/12407261860db424480089.png)
Joined: 06 Dec 2018 Posts: 2772
|
Posted: Sat Aug 24, 2024 5:08 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|