Skip to content

Build zlib from the source on Linux with the latest version (#715) #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .github/workflows/build_wheels_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ jobs:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
REPO_DIR: .
BUILD_COMMIT: ${{ github.ref }}
PROJECT_SPEC: opencv-python
MB_PYTHON_VERSION: ${{ matrix.python-version }}
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
MB_ML_VER: 2014
TRAVIS_BUILD_DIR: ${{ github.workspace }}
CONFIG_PATH: travis_config.sh
DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64:20220628
DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64:20220824
USE_CCACHE: 0
UNICODE_WIDTH: 32
PLAT: x86_64
Expand All @@ -55,9 +54,6 @@ jobs:
working-directory: ${{ github.workspace }}
- name: Setup environment
run: |
if [[ "${{ github.event.pull_request }}" == "true" ]]; then
echo "BUILD_COMMIT=${{ github.base_ref }}" >> $GITHUB_ENV
fi
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
fi
Expand Down Expand Up @@ -135,7 +131,6 @@ jobs:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
REPO_DIR: .
BUILD_COMMIT: ${{ github.ref }}
PROJECT_SPEC: opencv-python
PLAT: x86_64
MB_PYTHON_VERSION: ${{ matrix.python-version }}
Expand All @@ -156,9 +151,6 @@ jobs:
working-directory: ${{ github.workspace }}
- name: Setup environment
run: |
if [[ "${{ github.event.pull_request }}" == "true" ]]; then
echo "BUILD_COMMIT=${{ github.base_ref }}" >> $GITHUB_ENV
fi
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
fi
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/build_wheels_linux_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ jobs:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
REPO_DIR: .
BUILD_COMMIT: ${{ github.ref }}
PROJECT_SPEC: opencv-python
MB_PYTHON_VERSION: ${{ matrix.python-version }}
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
PLAT: aarch64
MB_ML_VER: 2014
TRAVIS_BUILD_DIR: ${{ github.workspace }}
CONFIG_PATH: travis_config.sh
DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64:20220628
DOCKER_IMAGE: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64:20220824
USE_CCACHE: 0
UNICODE_WIDTH: 32
SDIST: ${{ matrix.build_sdist || 0 }}
Expand All @@ -55,9 +54,6 @@ jobs:
working-directory: ${{ github.workspace }}
- name: Setup environment
run: |
if [[ "${{ github.event.pull_request }}" == "true" ]]; then
echo "BUILD_COMMIT=${{ github.base_ref }}" >> $GITHUB_ENV
fi
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
fi
Expand Down Expand Up @@ -97,7 +93,6 @@ jobs:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
MB_PYTHON_VERSION: ${{ matrix.python-version }}
PLAT: aarch64
BUILD_COMMIT: ${{ github.ref }}
NP_TEST_DEP: numpy==1.19.4
NP_TEST_DEP_LATEST: numpy==1.21.4
CONFIG_PATH: travis_config.sh
Expand All @@ -107,11 +102,6 @@ jobs:
- name: Cleanup
run: find . -mindepth 1 -delete
working-directory: ${{ github.workspace }}
- name: Setup environment
run: |
if [[ "${{ github.event.pull_request }}" == "true" ]]; then
echo "BUILD_COMMIT=${{ github.base_ref }}" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/build_wheels_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
REPO_DIR: .
BUILD_COMMIT: ${{ github.ref }}
PROJECT_SPEC: opencv-python
MB_PYTHON_VERSION: ${{ matrix.python-version }}
TRAVIS_PYTHON_VERSION: ${{ matrix.python-version }}
Expand All @@ -57,9 +56,6 @@ jobs:
working-directory: ${{ github.workspace }}
- name: Setup environment
run: |
if [[ "${{ github.event.pull_request }}" == "true" ]]; then
echo "BUILD_COMMIT=${{ github.base_ref }}" >> $GITHUB_ENV
fi
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
fi
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/build_wheels_macos_m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
without_gui: [0, 1]
build_sdist: [0]
env:
BUILD_COMMIT: ${{ github.ref }}
CI_BUILD: 1
SDIST: ${{ matrix.build_sdist || 0 }}
ENABLE_HEADLESS: ${{ matrix.without_gui }}
Expand All @@ -41,9 +40,6 @@ jobs:
working-directory: ${{ github.workspace }}
- name: Setup environment
run: |
if [[ "${{ github.event.pull_request }}" == "true" ]]; then
echo "BUILD_COMMIT=${{ github.base_ref }}" >> $GITHUB_ENV
fi
if [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "ENABLE_ROLLING=1" >> $GITHUB_ENV
fi
Expand Down Expand Up @@ -84,18 +80,12 @@ jobs:
without_gui: [0, 1]
build_sdist: [0]
env:
BUILD_COMMIT: ${{ github.ref }}
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}/opencv_extra/testdata
PYLINT_TEST_FILE: ${{ github.workspace }}/opencv/samples/python/squares.py
steps:
- name: Cleanup
run: find . -mindepth 1 -delete
working-directory: ${{ github.workspace }}
- name: Setup environment
run: |
if [[ "${{ github.event.pull_request }}" == "true" ]]; then
echo "BUILD_COMMIT=${{ github.base_ref }}" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
29 changes: 20 additions & 9 deletions docker/manylinux2014/Dockerfile_aarch64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version: 20220628
# Version: 20220824
# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-aarch64

FROM quay.io/pypa/manylinux2014_aarch64:latest
Expand All @@ -11,16 +11,28 @@ ARG NASM_VERSION=2.15.04
ARG OPENSSL_VERSION=1_1_1o
ARG QT_VERSION=5.15.0
ARG YASM_VERSION=1.3.0
ARG ZLIB_VERSION=1.2.12

ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH

# epel-release need for aarch64 to get openblas packages
RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \
RUN yum install bzip2-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \
yum install openblas-devel -y && \
cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \
# libpng will be built from source
yum remove libpng -y
yum remove libpng zlib-devel bzip2-devel -y

RUN mkdir ~/zlib_sources && \
cd ~/zlib_sources && \
curl -O -L https://www.zlib.net/zlib-${ZLIB_VERSION}.tar.gz && \
tar -xf zlib-${ZLIB_VERSION}.tar.gz && \
cd zlib-${ZLIB_VERSION} && \
./configure --prefix=/usr/local && \
make && \
make install && \
cd .. && \
rm -rf ~/zlib_sources

RUN mkdir ~/libpng_sources && \
cd ~/libpng_sources && \
Expand Down Expand Up @@ -71,8 +83,8 @@ RUN mkdir ~/openssl_sources && \

RUN mkdir ~/nasm_sources && \
cd ~/nasm_sources && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.gz && \
tar -xf nasm-${NASM_VERSION}.tar.gz && cd nasm-${NASM_VERSION} && ./autogen.sh && \
./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
Expand Down Expand Up @@ -102,17 +114,16 @@ RUN mkdir ~/libvpx_sources && \

RUN mkdir ~/ffmpeg_sources && \
cd ~/ffmpeg_sources && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
tar -xf ffmpeg-${FFMPEG_VERSION}.tar.gz && \
cd ffmpeg-${FFMPEG_VERSION} && \
PATH=~/bin:$PATH && \
PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
ldconfig && \
rm -rf ~/ffmpeg_sources && \
yum remove bzip2-devel -y
rm -rf ~/ffmpeg_sources

RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
Expand Down
29 changes: 20 additions & 9 deletions docker/manylinux2014/Dockerfile_x86_64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version: 20220628
# Version: 20220824
# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64

FROM quay.io/pypa/manylinux2014_x86_64:latest
Expand All @@ -11,16 +11,28 @@ ARG NASM_VERSION=2.15.04
ARG OPENSSL_VERSION=1_1_1o
ARG QT_VERSION=5.15.0
ARG YASM_VERSION=1.3.0
ARG ZLIB_VERSION=1.2.12

ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH

# epel-release need for aarch64 to get openblas packages
RUN yum install bzip2-devel curl-devel zlib-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \
RUN yum install bzip2-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel epel-release -y && \
yum install openblas-devel -y && \
cp /usr/include/lapacke/lapacke*.h /usr/include/ && \
curl https://raw.githubusercontent.com/xianyi/OpenBLAS/v0.3.3/cblas.h -o /usr/include/cblas.h && \
# libpng will be built from source
yum remove libpng -y
yum remove libpng zlib-devel bzip2-devel -y

RUN mkdir ~/zlib_sources && \
cd ~/zlib_sources && \
curl -O -L https://www.zlib.net/zlib-${ZLIB_VERSION}.tar.gz && \
tar -xf zlib-${ZLIB_VERSION}.tar.gz && \
cd zlib-${ZLIB_VERSION} && \
./configure --prefix=/usr/local && \
make && \
make install && \
cd .. && \
rm -rf ~/zlib_sources

RUN mkdir ~/libpng_sources && \
cd ~/libpng_sources && \
Expand Down Expand Up @@ -71,8 +83,8 @@ RUN mkdir ~/openssl_sources && \

RUN mkdir ~/nasm_sources && \
cd ~/nasm_sources && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.bz2 && \
tar -xf nasm-${NASM_VERSION}.tar.bz2 && cd nasm-${NASM_VERSION} && ./autogen.sh && \
curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.gz && \
tar -xf nasm-${NASM_VERSION}.tar.gz && cd nasm-${NASM_VERSION} && ./autogen.sh && \
./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
Expand Down Expand Up @@ -102,17 +114,16 @@ RUN mkdir ~/libvpx_sources && \

RUN mkdir ~/ffmpeg_sources && \
cd ~/ffmpeg_sources && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
tar -xf ffmpeg-${FFMPEG_VERSION}.tar.bz2 && \
curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
tar -xf ffmpeg-${FFMPEG_VERSION}.tar.gz && \
cd ffmpeg-${FFMPEG_VERSION} && \
PATH=~/bin:$PATH && \
PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \
make -j$(getconf _NPROCESSORS_ONLN) && \
make install && \
echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \
ldconfig && \
rm -rf ~/ffmpeg_sources && \
yum remove bzip2-devel -y
rm -rf ~/ffmpeg_sources

RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \
tar -xf ccache-${CCACHE_VERSION}.tar.gz && \
Expand Down
40 changes: 33 additions & 7 deletions patch_auditwheel_whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,39 @@

from auditwheel import policy

policies = None

with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json")) as f:
policies = json.load(f)
def add_zlib_versions():
with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json"), 'r') as manylinux_policy:
manylinux_policy_lines = manylinux_policy.readlines()

for p in policies:
p["lib_whitelist"].append("libxcb.so.1")
manylinux_policy_data = ""
for line in manylinux_policy_lines:
if "ZLIB" in line:
if len(line) > 22:
updated_line = line[:-2] + ', "1.2.9", "1.2.12"]'
else:
updated_line = line[:-2] + '"1.2.9", "1.2.12"]'
manylinux_policy_replacement = line.replace(line, updated_line)
else:
manylinux_policy_replacement = line
manylinux_policy_data = manylinux_policy_data + manylinux_policy_replacement

with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json"), "w") as f:
f.write(json.dumps(policies))
with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json"), 'w') as manylinux_final_policy:
manylinux_final_policy.write(manylinux_policy_data)

def add_whitelisted_libs():
policies = None

with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json")) as f:
policies = json.load(f)

for p in policies:
p["lib_whitelist"].append("libxcb.so.1")

with open(join(dirname(abspath(policy.__file__)), "manylinux-policy.json"), "w") as f:
f.write(json.dumps(policies))


if __name__ == '__main__':
add_zlib_versions()
add_whitelisted_libs()