From b04520a8035bd60e9146978a1d799aca5beec27d Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 14 Sep 2020 16:39:55 -0400 Subject: [PATCH 1/4] Get SIP in the Docker build --- Dockerfile | 25 +++++++++++++++++++++++++ PyQt5-stubs/sip.pyi | 26 +++++++++++++++++--------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7e372a8f..0fea890a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,9 @@ ARG ARCH_VERSION="20200407" ARG BUILD_DATE="2020/04/22" +ARG SIP_VERSION="5.2.0" +# Also the major.minor of PyQt5-sip +ARG SIP_ABI_VERSION="12.7" ARG PYQT_VERSION="5.14.2" ARG PYQT_3D_VERSION="5.14.0" ARG PYQT_CHART_VERSION="5.14.0" @@ -27,6 +30,8 @@ RUN echo "Server=https://archive.archlinux.org/repos/${BUILD_DATE}/\$repo/os/\$a RUN pacman --noconfirm -S \ # Build stuff base-devel wget \ + # Python stuff + python-pip \ # PyQt stuff pyqt-builder python-sip sip5 \ # Used to build other PyQt modules in later build stages @@ -95,6 +100,25 @@ RUN sip-install \ WORKDIR /output/ RUN find /upstream/ -name \*.pyi -exec cp {} . \; +################################################################################ +# PyQt5-SIP stubs +################################################################################ + +FROM build-dep AS sip + +# Reuse arguments from previous build scope +ARG SIP_VERSION +ARG SIP_ABI_VERSION + +# Install SIP including stubs +# TODO: Find way to build only stubs. This takes way too long +WORKDIR /upstream/ +RUN pip install --no-deps --target build sip==${SIP_VERSION} + +# Copy all .pyi files to output dir +WORKDIR /output/ +RUN find /upstream/ -wholename \*/${SIP_ABI_VERSION}/\*.pyi -exec cp {} . \; + ################################################################################ # PyQt3D ################################################################################ @@ -264,6 +288,7 @@ FROM scratch AS output # Get all the outputs from the build layers WORKDIR /output/ COPY --from=pyqt5 /output/* ./ +COPY --from=sip /output/* ./ COPY --from=pyqt-3d /output/* ./ COPY --from=pyqt-chart /output/* ./ COPY --from=pyqt-data-visualization /output/* ./ diff --git a/PyQt5-stubs/sip.pyi b/PyQt5-stubs/sip.pyi index 7fc0579a..062d543f 100644 --- a/PyQt5-stubs/sip.pyi +++ b/PyQt5-stubs/sip.pyi @@ -1,8 +1,5 @@ -# This file is the Python type hints stub file for the sip extension module. -# -# Copyright (c) 2016 Riverbank Computing Limited -# -# This file is part of SIP. +# Copyright (c) 2019, Riverbank Computing Limited +# All rights reserved. # # This copy of SIP is licensed for use under the terms of the SIP License # Agreement. See the file LICENSE for more details. @@ -11,8 +8,17 @@ # License v2 or v3 as published by the Free Software Foundation which can be # found in the files LICENSE-GPL2 and LICENSE-GPL3 included in this package. # -# SIP is supplied WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. from typing import overload, Sequence, Union @@ -35,7 +41,7 @@ Buffer = Union['array', 'voidptr', str, bytes, bytearray] # The array type. -array = Sequence +class array(Sequence): ... # The voidptr type. @@ -70,14 +76,16 @@ class voidptr: def setsize(self, size: int) -> None: ... - def setwriteable(self, bool: bool) -> None: ... + def setwriteable(self, bool) -> None: ... # Remaining functions. +def assign(obj: simplewrapper, other: simplewrapper) -> None: ... def cast(obj: simplewrapper, type: wrappertype) -> simplewrapper: ... def delete(obj: simplewrapper) -> None: ... def dump(obj: simplewrapper) -> None: ... def enableautoconversion(type: wrappertype, enable: bool) -> bool: ... +def enableoverflowchecking(enable: bool) -> bool: ... def getapi(name: str) -> int: ... def isdeleted(obj: simplewrapper) -> bool: ... def ispycreated(obj: simplewrapper) -> bool: ... From f4bebef3cdfcb5de839b30ed9a895ad2c3c11a21 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 14 Sep 2020 17:17:11 -0400 Subject: [PATCH 2/4] Update Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0fea890a..6f788cc7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -111,7 +111,6 @@ ARG SIP_VERSION ARG SIP_ABI_VERSION # Install SIP including stubs -# TODO: Find way to build only stubs. This takes way too long WORKDIR /upstream/ RUN pip install --no-deps --target build sip==${SIP_VERSION} From 2907a47a1854038b0a531ef88f8798ad8c12d9cd Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 14 Sep 2020 21:54:35 -0400 Subject: [PATCH 3/4] Download SIP sdist and extract to get sip.pyi --- Dockerfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6f788cc7..8ab95106 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,9 +110,15 @@ FROM build-dep AS sip ARG SIP_VERSION ARG SIP_ABI_VERSION -# Install SIP including stubs -WORKDIR /upstream/ -RUN pip install --no-deps --target build sip==${SIP_VERSION} +# Download source tar +RUN wget --no-verbose \ + --output-document upstream.tar.gz \ + https://pypi.io/packages/source/s/sip/sip-${SIP_VERSION}.tar.gz +RUN mkdir /upstream/ && \ + tar -xf \ + upstream.tar.gz \ + --directory /upstream/ \ + --strip-components 1 # Copy all .pyi files to output dir WORKDIR /output/ From ab7b465330b3ab3d1ee39a1be826e77f084c5430 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 14 Sep 2020 21:56:12 -0400 Subject: [PATCH 4/4] We don't need pip anymore --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8ab95106..f9375047 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,8 +30,6 @@ RUN echo "Server=https://archive.archlinux.org/repos/${BUILD_DATE}/\$repo/os/\$a RUN pacman --noconfirm -S \ # Build stuff base-devel wget \ - # Python stuff - python-pip \ # PyQt stuff pyqt-builder python-sip sip5 \ # Used to build other PyQt modules in later build stages