Skip to content

Commit

Permalink
Build updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mauvilsa committed Oct 2, 2024
1 parent 6a873ac commit b64284d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 74 deletions.
31 changes: 7 additions & 24 deletions py-pagexml/docker/Dockerfile_build
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# 16.04-py35 18.04-py36 20.04-py38 22.04-py310
# ARG UBUNTU_TAG 16.04 18.04 20.04 22.04
# ARG PYTHON_VERSION 3 3 3 3

ARG UBUNTU_TAG
FROM ubuntu:$UBUNTU_TAG

Expand All @@ -13,20 +9,7 @@ ENV \
LANG=en_US.UTF-8 \
LC_ALL=C.UTF-8

ARG PYTHON_VERSION=3

RUN if ! test -n "$PYTHON_VERSION"; then \
echo "error: PYTHON_VERSION argument is required"; \
exit 1; \
fi \
&& . /etc/os-release \
&& if [ "$VERSION_ID" = "16.04" ] && [ "$PYTHON_VERSION" = "2" ]; then \
PYTHON_VERSION=; \
elif [ "$PYTHON_VERSION" != "3" ]; then \
echo "error: unsupported combination UBUNTU=$VERSION_ID PYTHON=$PYTHON_VERSION"; \
exit 1; \
fi \
&& apt-get update --fix-missing \
RUN apt-get update --fix-missing \
&& apt-get dist-upgrade -y \
&& apt-get install -y --no-install-recommends \
less \
Expand All @@ -40,12 +23,12 @@ RUN if ! test -n "$PYTHON_VERSION"; then \
unzip \
locales \
openssh-client \
python$PYTHON_VERSION \
python$PYTHON_VERSION-setuptools \
python$PYTHON_VERSION-pkgconfig \
python$PYTHON_VERSION-wheel \
python$PYTHON_VERSION-pip \
python$PYTHON_VERSION-dev \
python3 \
python3-setuptools \
python3-pkgconfig \
python3-wheel \
python3-pip \
python3-dev \
libxml2-dev \
libxslt1-dev \
libopencv-dev \
Expand Down
18 changes: 6 additions & 12 deletions py-pagexml/docker/Dockerfile_build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#!/usr/bin/env bash
set -e

docker build \
-f Dockerfile_build \
-t mauvilsa/pagexml:build-ubuntu16.04-py35 \
--build-arg UBUNTU_TAG=16.04 \
.

docker build \
-f Dockerfile_build \
-t mauvilsa/pagexml:build-ubuntu18.04-py36 \
--build-arg UBUNTU_TAG=18.04 \
.

docker build \
-f Dockerfile_build \
-t mauvilsa/pagexml:build-ubuntu20.04-py38 \
Expand All @@ -24,3 +12,9 @@ docker build \
-t mauvilsa/pagexml:build-ubuntu22.04-py310 \
--build-arg UBUNTU_TAG=22.04 \
.

docker build \
-f Dockerfile_build \
-t mauvilsa/pagexml:build-ubuntu24.04-py312 \
--build-arg UBUNTU_TAG=24.04 \
.
45 changes: 9 additions & 36 deletions py-pagexml/docker/Dockerfile_runtime
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# 16.04-py35 18.04-py36 20.04-py38 22.04-py310
# ARG UBUNTU_TAG 16.04 18.04 20.04 22.04
# ARG PYTHON_VERSION 3 3 3 3

ARG UBUNTU_TAG
FROM ubuntu:$UBUNTU_TAG

Expand All @@ -21,17 +17,7 @@ RUN if ! test -n "$PYTHON_VERSION"; then \
exit 1; \
fi \
&& . /etc/os-release \
&& if [ "$VERSION_ID" = "16.04" ] && [ "$PYTHON_VERSION" = "2" ]; then \
CV_VERSION=2.4v5; \
GDAL_VERSION=1i; \
PYTHON_VERSION=; \
elif [ "$VERSION_ID" = "16.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
CV_VERSION=2.4v5; \
GDAL_VERSION=1i; \
elif [ "$VERSION_ID" = "18.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
CV_VERSION=3.2; \
GDAL_VERSION=20; \
elif [ "$VERSION_ID" = "20.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
&& if [ "$VERSION_ID" = "20.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
CV_VERSION=4.2; \
GDAL_VERSION=26; \
elif [ "$VERSION_ID" = "22.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
Expand All @@ -55,12 +41,6 @@ RUN if ! test -n "$PYTHON_VERSION"; then \
libopencv-imgcodecs$CV_VERSION \
libopencv-core$CV_VERSION \
libgdal$GDAL_VERSION \
&& if [ "$VERSION_ID" != "16.04" ]; then \
apt-get install -y --no-install-recommends \
python$PYTHON_VERSION-distutils \
libopencv-highgui$CV_VERSION \
libsm6; \
fi \
&& pip3 install --upgrade pip setuptools wheel \
&& apt-get purge -y \
python$PYTHON_VERSION-pip \
Expand All @@ -76,20 +56,13 @@ RUN if ! test -n "$PAGEXML_VERSION"; then \
echo "error: PAGEXML_VERSION argument is required"; \
exit 1; \
fi \
&& . /etc/os-release \
&& if [ "$VERSION_ID" = "16.04" ] && [ "$PYTHON_VERSION" = "2" ]; then \
PAGEXML_RELEASE=$PAGEXML_VERSION/pagexml-${PAGEXML_VERSION//.0/.}-cp27-cp27m; \
elif [ "$VERSION_ID" = "16.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
PAGEXML_RELEASE=$PAGEXML_VERSION/pagexml-${PAGEXML_VERSION//.0/.}-cp35-cp35m; \
elif [ "$VERSION_ID" = "18.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
PAGEXML_RELEASE=$PAGEXML_VERSION/pagexml-${PAGEXML_VERSION//.0/.}-cp36-cp36m; \
elif [ "$VERSION_ID" = "20.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
PAGEXML_RELEASE=$PAGEXML_VERSION/pagexml-${PAGEXML_VERSION//.0/.}-cp38-cp38; \
elif [ "$VERSION_ID" = "22.04" ] && [ "$PYTHON_VERSION" = "3" ]; then \
PAGEXML_RELEASE=$PAGEXML_VERSION/pagexml-${PAGEXML_VERSION//.0/.}-cp310-cp310; \
fi \
&& PAGEXML_WHEEL=/tmp/${PAGEXML_RELEASE##*/}-linux_x86_64.whl \
&& curl -L -o $PAGEXML_WHEEL https://github.com/omni-us/pagexml/releases/download/$PAGEXML_RELEASE-linux_x86_64.whl \
&& pip3 install $PAGEXML_WHEEL[all] \
&& pip3 install \
--no-cache-dir \
--root-user-action=ignore \
--progress-bar=off \
--index-url=https://pypi.omnius.com \
--trusted-host=pypi.omnius.com \
--extra-index-url=https://pypi.org/simple \
pagexml[all]==$PAGEXML_VERSION \
&& python3 -m pagexml_tests \
&& rm -rf /tmp/*
5 changes: 3 additions & 2 deletions py-textfeat/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class Distribution(_Distribution):

def textfeat_Extension(magick=False):
import pkgconfig
libs = ['opencv','libxml-2.0','Magick++']
opencv = 'opencv' if sys.version_info[:2] == (3, 6) else 'opencv4'
libs = [opencv,'libxml-2.0','Magick++']
compile_args = ['-std=c++11']
link_args = []
for lib in libs:
Expand All @@ -71,7 +72,7 @@ def textfeat_Extension(magick=False):
#compile_args += pkgconfig.cflags('opencv').split()
#cvre = re.compile('^-L|^-lopencv_core|^-lopencv_imgproc|^-lopencv_imgcodecs|^-lopencv_flann')
#link_args += [x for x in pkgconfig.libs('opencv').split() if cvre.match(x)]
cvinc = pkgconfig.cflags('opencv').split()[0].rsplit('/opencv',1)[0]
cvinc = pkgconfig.cflags(opencv).split()[0]
defimage = '__PAGEXML_IMG_MAGICK__' if magick else '__PAGEXML_IMG_CV__'
pageimage = 'Magick::Image' if magick else 'cv::Mat'
define_macros = [(defimage,''),('__PAGEXML_MAGICK__','')]
Expand Down

0 comments on commit b64284d

Please sign in to comment.