Skip to content

Commit

Permalink
MacOS wheels: attempt to use cross-files to find pcap-config
Browse files Browse the repository at this point in the history
  • Loading branch information
bmerry committed Aug 30, 2023
1 parent fc96451 commit 4d03cb9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .ci/before_all_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ pcap_version=1.10.4
# TODO: pin specific versions
brew install boost libdivide

# Install pkgconfig from source twice - once for x86_64 and once for arm64.
# Install pkgconfig from source - once for each architecture in CIBW_ARCHS
cd /tmp
wget --progress=dot:mega https://www.tcpdump.org/release/libpcap-${pcap_version}.tar.gz
tar -zxf /tmp/libpcap-${pcap_version}.tar.gz
cd libpcap-${pcap_version}/
for arch in x86_64 arm64; do
for arch in $CIBW_ARCHS; do
mkdir build-$arch
cd build-$arch
if [ "$arch" == "x86_64" ]; then # TODO: use `arch` to auto-detect cross-compilation
Expand All @@ -30,5 +30,6 @@ for arch in x86_64 arm64; do
cd ..
done

# TODO: this is debugging
echo $PATH
pcap-config --cflags --libs
14 changes: 14 additions & 0 deletions .ci/before_build_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e -u

project="$1"

# Set up meson cross file to pick up pcap-config. Meson refuses to use the one
# in $PATH when cross-compiling.
cat > "$project/pcap-cross.ini" <<EOF
[binaries]
pcap-config = /tmp/cibuildwheel/$CIBW_ARCHS/bin/pcap-config
EOF

# TODO this is debugging
cat "$project/pcap-cross.ini"
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ before-all = ".ci/before_all_linux.sh"
setup-args = [
"-Dpcap=enabled",
"-Db_lto=true",
"--cross-file=pcap-cross.ini",
]

[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"]
before-all = ".ci/before_all_macos.sh"
before-build = ".ci/before_build_macos.sh"
# To ensure that the brew-installed libpcap gets picked up
environment = { PKG_CONFIG_PATH="/usr/local/opt/libpcap/lib/pkgconfig" }

Expand Down

0 comments on commit 4d03cb9

Please sign in to comment.