From ac7abcaee4ca0e495cc8ccca00a2aa57a6225861 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 3 Feb 2021 22:41:02 -0500 Subject: [PATCH 1/3] build-helper/rust: define HOST_CC and HOST_CFLAGS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cc-rs crate will try to guess the host compiler and use default flags these are not specifically set. The default behavior is wrong in Void cross-compilation environments. Explicitly define HOST_CC=gcc and use innocuous HOST_CFLAGS=-O2 just to thwart the bad defaults. Co-authored-by: Érico Rolim Co-authored-by: Andrew J. Hesford --- common/build-helper/rust.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/build-helper/rust.sh b/common/build-helper/rust.sh index 6fcd3bd7d9e..431cb5f0fd4 100644 --- a/common/build-helper/rust.sh +++ b/common/build-helper/rust.sh @@ -17,6 +17,12 @@ if [ "$CROSS_BUILD" ]; then # [build] # target = ${RUST_TARGET} export CARGO_BUILD_TARGET="$RUST_TARGET" + + # If cc-rs needs to build host binaries, it guesses the compiler and + # uses default (wrong) flags unless they are specified explicitly; + # innocuous flags are used here just to disable its defaults + export HOST_CC="gcc" + export HOST_CFLAGS="-O2" else unset CARGO_BUILD_TARGET fi From b6d6a406d3129d042492674493572cbed1bb94c4 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Mon, 1 Feb 2021 11:13:44 +0300 Subject: [PATCH 2/3] New package: maturin-0.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Érico Rolim Co-authored-by: Andrew J. Hesford --- srcpkgs/maturin/template | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 srcpkgs/maturin/template diff --git a/srcpkgs/maturin/template b/srcpkgs/maturin/template new file mode 100644 index 00000000000..cce53cf58cc --- /dev/null +++ b/srcpkgs/maturin/template @@ -0,0 +1,36 @@ +# Template file for 'maturin' +pkgname=maturin +version=0.9.0 +revision=1 +build_style=cargo +# Disable the 'rustls' feature, which leads to bad platform compatibility +# The list of enabled features should be reconciled with each new release +configure_args="--no-default-features --features auditwheel,log,upload,human-panic" +hostmakedepends="python3-setuptools python3-toml" +makedepends="libressl-devel" +depends="python3-toml" +short_desc="Build and publish crates as python packages" +maintainer="Andrew J. Hesford " +license="Apache-2.0, MIT" +homepage="https://github.com/PyO3/maturin" +distfiles="${homepage}/archive/v${version}.tar.gz" +checksum=22e8082a743e1dc11f5909b596f9053deb7dc1a56336003677381ba02cf67da8 + +post_patch() { + # setup.py is broken, just use it for the pure python part + vsed -e 's/cmdclass.*/packages=["maturin"],/' -i setup.py +} + +post_build() { + # python package is pure; the cross environment is not relevant + python3 setup.py build +} + +do_check() { + echo "Tests use unstable features and fail to build; skipping" +} + +post_install() { + vlicense license-mit LICENSE-MIT + python3 setup.py install --prefix=/usr --root=${DESTDIR} +} From 709def161ba041e70c58a93395a92b3587a90b40 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Mon, 1 Feb 2021 13:50:32 +0300 Subject: [PATCH 3/3] New package: python3-adblock-0.4.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Érico Rolim Co-authored-by: Andrew J. Hesford --- srcpkgs/python3-adblock/template | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 srcpkgs/python3-adblock/template diff --git a/srcpkgs/python3-adblock/template b/srcpkgs/python3-adblock/template new file mode 100644 index 00000000000..c1200f89027 --- /dev/null +++ b/srcpkgs/python3-adblock/template @@ -0,0 +1,46 @@ +# Template file for 'python3-adblock' +pkgname=python3-adblock +version=0.4.2 +revision=1 +wrksrc="${pkgname/python3/python}-${version}" +build_style=python3-pep517 +build_helper="rust" +hostmakedepends="maturin pkg-config cargo libressl-devel" +makedepends="libressl-devel python3-devel" +depends="python3" +checkdepends="python3-pytest" +short_desc="Brave's adblock library in Python" +maintainer="Andrew J. Hesford " +license="Apache-2.0, MIT" +homepage="https://github.com/ArniDagur/python-adblock" +distfiles="${homepage}/archive/${version}.tar.gz" +checksum=06de6074e6cfe889fc0383cc929a5a2306570251c14e51abbfcedd328b83e0e9 + +case "$XBPS_TARGET_MACHINE" in + i686*) broken="compiler throws SIGABRT on the psl crate" ;; +esac + +if [ "$CROSS_BUILD" ]; then + makedepends+=" rust-std" + export PYO3_CROSS_LIB_DIR="${XBPS_CROSS_BASE}/usr/lib" + export PYO3_CROSS_INCLUDE_DIR="${XBPS_CROSS_BASE}/usr/include" +fi + +do_build() { + maturin build -o . --release --target "${RUST_TARGET}" --manylinux off + + # Drop platform specifiers from the wheel; pip will refuse to install, + # e.g., an armv7l wheel on an aarch64 system even if the masterdir is + # armv7l. The wheel is correct; no need for name compatibility checks. + mv adblock-${version}-*.whl adblock-${version}-py3-none-any.whl +} + +pre_check() { + # Tests require the compiled extension + cp target/${RUST_TARGET}/release/libadblock.so adblock/adblock.so +} + +post_install() { + vlicense LICENSE-MIT + chmod 755 ${DESTDIR}/${py3_sitelib}/adblock/*.so +}