Skip to content

Commit

Permalink
common and base now build
Browse files Browse the repository at this point in the history
- scripts/base/build_pyside.sh

  - patch for PySide 5.15.8 to build against Python 3.10.x
  - patch for Pyside 5.15.8 to build against NumPy 1.23.x

- packages/conan/recipes/python/conanfile.py

  sysconfigdata gets baked at compile time and surfaces the Conan
  build directory, which can confuse older CMake versions looking
  for INCLUDEPY. This replaces build prefix with /usr/local, which
  is not great since we don't know for sure that we'll be installing
  Python there, but it's better than the current situation.

- packages/base3/Dockerfile

  You need to know the NUMPY_VERSION to build PySide

- packages/vfx1/Dockerfile
- packages/vfx2/Dockerfile

  tbb is now a Conan-only package

Signed-off-by: Jean-Francois Panisset <[email protected]>
  • Loading branch information
jfpanisset committed Feb 12, 2023
1 parent 4825eb6 commit f5c2356
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/base3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ FROM ci-baseos-gl-packages as ci-pyside-builder

ARG ASWF_PYTHON_VERSION
ARG ASWF_PYSIDE_VERSION
ARG ASWF_NUMPY_VERSION
ARG ASWF_PKG_ORG
ARG ASWF_CONAN_CHANNEL
ARG ASWF_VFXPLATFORM_VERSION

ENV ASWF_PYTHON_VERSION=${ASWF_PYTHON_VERSION}
ENV ASWF_PYSIDE_VERSION=${ASWF_PYSIDE_VERSION}
ENV ASWF_NUMPY_VERSION=${ASWF_NUMPY_VERSION}
ENV ASWF_PKG_ORG=${ASWF_PKG_ORG}
ENV ASWF_CONAN_CHANNEL=${ASWF_CONAN_CHANNEL}
ENV ASWF_VFXPLATFORM_VERSION=${ASWF_VFXPLATFORM_VERSION}
Expand Down
14 changes: 14 additions & 0 deletions packages/conan/recipes/python/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from contextlib import contextmanager
from conan.tools.files.symlinks import absolute_to_relative_symlinks
import os
import sysconfig


class PythonConan(ConanFile):
Expand Down Expand Up @@ -156,6 +157,19 @@ def _replaceShebang(script_prefix):

absolute_to_relative_symlinks(self, self.package_folder)

# The grossest of hacks: the generated _sysconfigdata__PLATFORM.py embeds our build paths
# This breaks tools that use sysconfig to find Python's INCLUDEDIR such as Qt.
# This will break for multi-architecture builds, as well as when installing in a
# different location than /usr/local
tools.replace_in_file(

This comment has been minimized.

Copy link
@aloysbaillet

aloysbaillet Feb 12, 2023

Contributor

Would be great to move this into a conan install step, so that we don't need to know where it will be installed

This comment has been minimized.

Copy link
@jfpanisset

jfpanisset Feb 12, 2023

Author Contributor

Agreed, would be much happier with this as a post install hook, that way we would know what to use as the actual deployment path. I know very little about Conan, so I wasn't able to find anything, but I imagine such a thing exists?

os.path.join(
self.package_folder,
f"lib/python{self.major_minor}/_sysconfigdata__{sysconfig.get_config_var('MACHDEP')}_{sysconfig.get_config_var('MULTIARCH')}.py",
),
self.package_folder,
"/usr/local",
)

def package_info(self):
self.cpp_info.filenames["pkg_config"] = "python"
self.user_info.python_interp = f"python{self.major_minor}"
Expand Down
3 changes: 1 addition & 2 deletions packages/vfx1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ARG ASWF_OPENEXR_VERSION

# Required base packages built in previous stages
FROM ${ASWF_ORG}/ci-package-glew:${ASWF_VFXPLATFORM_VERSION}-${ASWF_GLEW_VERSION} as ci-package-glew-external
FROM ${ASWF_ORG}/ci-package-tbb:${ASWF_VFXPLATFORM_VERSION}-${ASWF_TBB_VERSION} as ci-package-tbb-external
FROM ${ASWF_ORG}/ci-package-cppunit:${ASWF_VFXPLATFORM_VERSION}-${ASWF_CPPUNIT_VERSION} as ci-package-cppunit-external
FROM ${ASWF_ORG}/ci-package-glfw:${ASWF_VFXPLATFORM_VERSION}-${ASWF_GLFW_VERSION} as ci-package-glfw-external
FROM ${ASWF_ORG}/ci-package-pybind11:${ASWF_VFXPLATFORM_VERSION}-${ASWF_PYBIND11_VERSION} as ci-package-pybind11-external
Expand Down Expand Up @@ -62,6 +61,7 @@ COPY <<EOF /usr/local/conanfile.txt
cmake/${ASWF_CMAKE_VERSION}@${ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
python/${ASWF_PYTHON_VERSION}@${ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
boost/${ASWF_BOOST_VERSION}@${ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
tbb/${ASWF_TBB_VERSEION}@${ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
EOF

RUN <<EOF
Expand Down Expand Up @@ -271,7 +271,6 @@ COPY ../scripts/vfx/build_openvdb.sh \
/tmp/

COPY --from=ci-package-glew-external /. /usr/local/
COPY --from=ci-package-tbb-external /. /usr/local/
COPY --from=ci-package-cppunit-external /. /usr/local/
COPY --from=ci-package-glfw-external /. /usr/local/

Expand Down
40 changes: 37 additions & 3 deletions packages/vfx2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ FROM ${ASWF_ORG}/ci-package-cmake:${ASWF_VFXPLATFORM_VERSION}-${ASWF_CMAKE_VERSI
FROM ${ASWF_ORG}/ci-package-cppunit:${ASWF_VFXPLATFORM_VERSION}-${ASWF_CPPUNIT_VERSION} as ci-package-cppunit-external
FROM ${ASWF_ORG}/ci-package-python:${ASWF_VFXPLATFORM_VERSION}-${ASWF_PYTHON_VERSION} as ci-package-python-external
FROM ${ASWF_ORG}/ci-package-boost:${ASWF_VFXPLATFORM_VERSION}-${ASWF_BOOST_VERSION} as ci-package-boost-external
FROM ${ASWF_ORG}/ci-package-tbb:${ASWF_VFXPLATFORM_VERSION}-${ASWF_TBB_VERSION} as ci-package-tbb-external
FROM ${ASWF_ORG}/ci-package-qt:${ASWF_VFXPLATFORM_VERSION}-${ASWF_QT_VERSION} as ci-package-qt-external
FROM ${ASWF_ORG}/ci-package-pybind11:${ASWF_VFXPLATFORM_VERSION}-${ASWF_PYBIND11_VERSION} as ci-package-pybind11-external
FROM ${ASWF_ORG}/ci-package-pyside:${ASWF_VFXPLATFORM_VERSION}-${ASWF_PYSIDE_VERSION} as ci-package-pyside-external
Expand Down Expand Up @@ -84,6 +83,7 @@ COPY <<EOF /usr/local/conanfile.txt
cmake/${ASWF_CMAKE_VERSION}@${ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
python/${ASWF_PYTHON_VERSION}@${ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
boost/${ASWF_BOOST_VERSION}@${ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
tbb/${ASWF_TBB_VERSION}@{$ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
EOF

RUN <<EOF
Expand Down Expand Up @@ -150,18 +150,37 @@ FROM ci-partio-builder as ci-osl-builder

ARG ASWF_OSL_VERSION
ENV ASWF_OSL_VERSION=${ASWF_OSL_VERSION}
ARG ASWF_PKG_ORG
ARG ASWF_CONAN_CHANNEL

COPY --from=ci-package-imath-external /. /usr/local/
COPY --from=ci-package-openexr-external /. /usr/local/
COPY --from=ci-package-oiio-external /. /usr/local/
COPY --from=ci-package-pybind11-external /. /usr/local/
COPY --from=ci-package-openvdb-external /. /usr/local/
COPY --from=ci-package-tbb-external /. /usr/local/
COPY --from=ci-package-blosc-external /. /usr/local/

COPY ../scripts/vfx/build_osl.sh \
/tmp/

# Copy local conan packages if any
COPY packages/conan/data/ /opt/conan_home/d/
COPY packages/conan/settings/ /opt/conan_home/.conan/

# Use conan to install some packages
COPY <<EOF /usr/local/conanfile.txt
[generators]
[imports]
., * -> .
[requires]
tbb/${ASWF_TBB_VERSION}@{$ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
EOF

RUN <<EOF
cd /usr/local/
conan install .
EOF

RUN --mount=type=cache,target=/tmp/ccache \
--mount=type=cache,sharing=private,target=/tmp/downloads \
/tmp/before_build.sh && \
Expand Down Expand Up @@ -246,14 +265,29 @@ FROM ci-ptex-builder as ci-opensubdiv-builder

ARG ASWF_OPENSUBDIV_VERSION
ENV ASWF_OPENSUBDIV_VERSION=${ASWF_OPENSUBDIV_VERSION}
ARG ASWF_PKG_ORG
ARG ASWF_CONAN_CHANNEL

COPY ../scripts/vfx/build_opensubdiv.sh \
/tmp/

COPY --from=ci-package-glew-external /. /usr/local/
COPY --from=ci-package-tbb-external /. /usr/local/
COPY --from=ci-package-glfw-external /. /usr/local/

# Use conan to install some packages
COPY <<EOF /usr/local/conanfile.txt
[generators]
[imports]
., * -> .
[requires]
tbb/${ASWF_TBB_VERSION}@{$ASWF_PKG_ORG}/${ASWF_CONAN_CHANNEL}
EOF

RUN <<EOF
cd /usr/local/
conan install .
EOF

RUN --mount=type=cache,target=/tmp/ccache \
--mount=type=cache,sharing=private,target=/tmp/downloads \
/tmp/before_build.sh && \
Expand Down
48 changes: 48 additions & 0 deletions scripts/base/build_pyside.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,54 @@ else
unzip clang10-patch.zip
patch -p1 < 9ae6382.diff
fi
if [[ $ASWF_PYSIDE_VERSION == 5.15.8 ]]; then
# Apply _Py_Mangle patch from comments in https://bugreports.qt.io/browse/PYSIDE-1775
# Unfortunately no easily downloadable patch
cat << EOF > py_mangle.diff
--- a/sources/shiboken2/libshiboken/pep384impl.cpp 2023-02-12 05:07:52.467175804 +0000
+++ b/sources/shiboken2/libshiboken/pep384impl.cpp 2023-02-12 05:08:39.867065833 +0000
@@ -751,9 +751,7 @@
#endif // IS_PY2
Shiboken::AutoDecRef privateobj(PyObject_GetAttr(
reinterpret_cast<PyObject *>(Py_TYPE(self)), Shiboken::PyMagicName::name()));
-#ifndef Py_LIMITED_API
- return _Py_Mangle(privateobj, name);
-#else
+
// PYSIDE-1436: _Py_Mangle is no longer exposed; implement it always.
// The rest of this function is our own implementation of _Py_Mangle.
// Please compare the original function in compile.c .
@@ -789,7 +787,6 @@
if (amount > big_stack)
free(resbuf);
return result;
-#endif // else Py_LIMITED_API
}
/*****************************************************************************
EOF
patch -p1 < py_mangle.diff
fi
if [[ $ASWF_PYSIDE_VERSION == 5.15.8 ]]; then
# Fix for compiling against Numpy 1.23.x from
# https://git.alpinelinux.org/aports/commit/?id=8936d82ae568ce7521427075be5599fcc3a409f0
cat << EOF > shiboken_numpy_1_23.diff
--- a/sources/shiboken2/libshiboken/sbknumpyarrayconverter.cpp
+++ b/sources/shiboken2/libshiboken/sbknumpyarrayconverter.cpp
@@ -116,8 +116,8 @@ std::ostream &operator<<(std::ostream &str, PyArrayObject *o)
str << " NPY_ARRAY_NOTSWAPPED";
if ((flags & NPY_ARRAY_WRITEABLE) != 0)
str << " NPY_ARRAY_WRITEABLE";
- if ((flags & NPY_ARRAY_UPDATEIFCOPY) != 0)
- str << " NPY_ARRAY_UPDATEIFCOPY";
+ if ((flags & NPY_ARRAY_WRITEBACKIFCOPY) != 0)
+ str << " NPY_ARRAY_WRITEBACKIFCOPY";
} else {
str << '0';
}
EOF
patch -p1 < shiboken_numpy_1_23.diff
fi

"${ASWF_INSTALL_PREFIX}/bin/python" setup.py build --parallel=$(nproc)
"${ASWF_INSTALL_PREFIX}/bin/python" setup.py install --prefix "${ASWF_INSTALL_PREFIX}"
Expand Down

0 comments on commit f5c2356

Please sign in to comment.