Skip to content

Commit

Permalink
Hopefully fix manylinux build
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanstraten committed Feb 23, 2021
1 parent 8e7b212 commit cdf47a4
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/manylinux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist/
!/build/
8 changes: 8 additions & 0 deletions python/manylinux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.PHONY: all
all:
cd build && ./build.sh

.PHONY: clean
clean:
rm -rf dist
18 changes: 18 additions & 0 deletions python/manylinux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This directory contains the build stuff needed to build and test manylinux2014
wheels for distribution through PyPI.

You need docker to do this, then you can just run `make` to build. The wheels
will end up in the `dist` folder, and will then be tested in a different
container (also based on manylinux) for all Python versions. Note that
qxelarator, libqasm, and qisa-assembler are NOT installed in the test
container, so a bunch of tests are skipped; this can't really be avoided until
they're appropriately built and published to PyPI as well. Otherwise we'd have
to replicate that entire process for just the test container, which is insane.

You need to `make clean` manually when any of the sources (other than tests)
change; there is no dependency detection.

manylinux2014 is used rather than the more compatible versions because OpenQL
refuses to build on manylinux2010, and I didn't bother trying manylinux1.
Apparently we're hitting some weird compiler bug on 2010 where two symbols just
go missing somewhere in the linking process.
16 changes: 16 additions & 0 deletions python/manylinux/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Manylinux version to use.
ARG MANYLINUX=2014
FROM quay.io/pypa/manylinux${MANYLINUX}_x86_64

# Max number of parallel processes to use.
ARG NPROCS=100
ENV NPROCS ${NPROCS}

# Install auditwheel.
ARG PYTHON_VERSION=38
ENV PYBIN /opt/python/cp${PYTHON_VERSION}-cp${PYTHON_VERSION}*/bin
RUN ${PYBIN}/pip3 install -U pip auditwheel

WORKDIR /src

ADD . .
7 changes: 7 additions & 0 deletions python/manylinux/build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

rm -rf ../dist
mkdir -p ../dist
docker build --pull -t gerbertools-manylinux ../../.. -f Dockerfile
docker run -v `pwd`/../dist:/io/dist gerbertools-manylinux python/manylinux/build/helper.sh
16 changes: 16 additions & 0 deletions python/manylinux/build/helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

if [[ -z "$AUDITWHEEL_PLAT" ]]; then
echo "This should only be run inside the container!"
exit 1
fi

set -u
set -x

for PYDIR in /opt/python/cp3*; do
rm -rf pybuild/cbuild/python pybuild/dist
"${PYDIR}/bin/python" setup.py bdist_wheel
${PYBIN}/python -m auditwheel repair -w /io/dist pybuild/dist/*.whl
done
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def run(self):
['-DCMAKE_INSTALL_PREFIX=' + prefix_dir]
['-DPYTHON_DIR=' + os.path.dirname(target)]
['-DPYTHON_EXT=' + os.path.basename(target)]
['-DPYTHON_EXECUTABLE=' + sys.executable]

# Build type can be set using an environment variable.
['-DCMAKE_BUILD_TYPE=' + build_type]
Expand Down

0 comments on commit cdf47a4

Please sign in to comment.