Skip to content

Commit b7cd1fa

Browse files
committed
Link python libs manually on macos
1 parent 81269f7 commit b7cd1fa

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/build_pgo.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,19 @@ if [[ $arch == "arm64" ]]; then
2222
arch="aarch64"
2323
fi
2424

25+
# On macOS, manually link the python libraries
26+
if [[ `uname -s` == "Darwin" ]] ; then
27+
PYLIB=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
28+
PYNAME=$(find $PYLIB -maxdepth 1 -name "libpython*" | grep -oE "[^/]+$" | grep -oE "python[0-9]+\.[0-9]+" || echo "python")
29+
LDFLAGS="-L $PYLIB -l $PYNAME"
30+
else
31+
LDFLAGS=""
32+
fi
33+
2534
# Build with instrumentation
2635
pip install -U -c constraints.txt setuptools-rust wheel setuptools
27-
RUSTFLAGS="-Cprofile-generate=$work_dir" pip install --prefer-binary -c constraints.txt -r requirements-dev.txt -e .
28-
RUSTFLAGS="-Cprofile-generate=$work_dir" python setup.py build_rust --release --inplace
36+
RUSTFLAGS="-Cprofile-generate=$work_dir $LDFLAGS" pip install --prefer-binary -c constraints.txt -r requirements-dev.txt -e .
37+
RUSTFLAGS="-Cprofile-generate=$work_dir $LDFLAGS" python setup.py build_rust --release --inplace
2938
# Run profile data generation
3039

3140
QISKIT_PARALLEL=FALSE stestr run --abbreviate

0 commit comments

Comments
 (0)