diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f892c76 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,132 @@ +# Build openimageio for python + +on: + pull_request: + branches: + - release + release: + types: [published] + + + +jobs: + build: + name: Test on ${{ matrix.os }} with Python ${{ matrix.python }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python_version_major: ['3'] + python_version_minor: ['7'] + os: ['ubuntu-16.04'] + oiio_version: ["2.2.10.0"] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version_major }}.${{ matrix.python_version_minor }} + architecture: x64 + - name: build oiio + run: | + sudo apt-get install libboost-all-dev + sudo apt-get install libjpeg-dev + sudo apt-get install zlib1g-dev + sudo apt-get install libpng-dev + sudo apt-get install libtiff-dev + sudo apt-get install libopenexr-dev + sudo apt-get install libraw-dev + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt-get update -y + sudo apt-get install g++-7 -y + git clone https://github.com/OpenImageIO/oiio.git + pip3 install "pybind11[global]" + pip3 install numpy + cd oiio + git checkout "v${{ matrix.oiio_version }}" + mkdir build + cd build + cmake .. -DCMAKE_CXX_FLAGS="-Wno-error=unused-variable" + make VERBOSE=1 STOP_ON_WARNING=0 LINKSTATIC=1 + sudo make install + shell: bash + env: + OIIO_PYTHON_VERSION: ${{ matrix.python_version_major }}.${{ matrix.python_version_minor }} + + - name: Inject variable values into setup.py + run: | + cd src/python + sed -i'' 's/PACKAGE_VERSION/${{ matrix.oiio_version }}/g' setup.py + sed -i'' 's/PYTHON_VERSION/${{ matrix.python_version_major }}.${{ matrix.python_version_minor }}/g' setup.py + sed -i'' 's/OS_NAME/Microsoft :: POSIX :: Linux/g' setup.py + cat setup.py + mkdir ${GITHUB_WORKSPACE}/artifacts + - name: Copy files into oiio Python package + run: | + cp oiio/build/lib/python/site-packages/*.so src/python/oiio + # - name: Python wheels manylinux build + # uses: RalfG/python-wheels-manylinux-build@v0.3.3 + # with: + # python-versions: 'cp37-cp37m' + # package-path: 'src/python' + # pip-wheel-args: '-w /github/workspace/artifacts' + - name: Copy Files To Zip + run: | + SOURCE="oiio/build" + DEST="${GITHUB_WORKSPACE}/artifacts" + INSTALL_ROOT="/usr/local" + + if [ ! -d $DEST ]; then + mkdir $DEST + fi + + for root in $SOURCE/bin $SOURCE/lib $SOURCE/include; do + for file in $(find $root -type f ); do + echo "$file" + src_file="${file/$SOURCE/}" + if [ -f $INSTALL_ROOT/$src_file ]; then + echo "$INSTALL_ROOT/$src_file -> $DEST" + cp $INSTALL_ROOT/$src_file --parents $DEST + fi + done + done + mkdir -p $DEST/lib/python3.7/site-packages + if [ -f $INSTALL_ROOT/lib/python3.7/site-packages/OpenImageIO.so ]; then + cp $INSTALL_ROOT/lib/python3.7/site-packages/OpenImageIO.so $DEST/lib/python3.7/site-packages/OpenImageIO.so + else + cp oiio/build/lib/python/site-packages/OpenImageIO.so $DEST/lib/python3.7/site-packages/OpenImageIO.so + fi + + - name: Build wheel + id: build-wheel + run: | + export DIST_DIR="${GITHUB_WORKSPACE}/artifacts" + cd src/python + python${{ matrix.python_version_major }}.${{ matrix.python_version_minor }} -m pip install -U pip + pip${{ matrix.python_version_major }}.${{ matrix.python_version_minor }} install -U setuptools wheel auditwheel + python3 setup.py bdist_wheel --python-tag=cp${{ matrix.python_version_major }}${{ matrix.python_version_minor }} --plat-name=linux_x86_64 --dist-dir="$DIST_DIR" + cd $DIST_DIR + echo "Dest Dir" + ls -lah + # echo "auditwheel" + # auditwheel repair "oiio-${{ matrix.oiio_version }}-py${{ matrix.python_version_major }}-none-any.whl" + # auditwheel repair "oiio-${{ matrix.oiio_version }}-cp${{ matrix.python_version_major }}${{ matrix.python_version_minor }}-none-linux_x86_64.whl" + ls -lah + zip -r "oiio-${{ matrix.oiio_version }}-py${{ matrix.python_version_major }}.zip" ./* + echo ::set-output name=asset-name::oiio-${{ matrix.oiio_version }}-py${{ matrix.python_version_major }}.zip + echo ::set-output name=asset-path::${GITHUB_WORKSPACE}/artifacts/oiio-${{ matrix.oiio_version }}-py${{ matrix.python_version_major }}.zip + - name: Generate Upload URL + id: gen-upload-url + run: | + sudo apt-get install jq; + RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH); + echo ::set-output name=upload-url::https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.gen-upload-url.outputs.upload-url }}?name=${{ steps.build-wheel.outputs.asset-name }} + asset_path: ${{ steps.build-wheel.outputs.asset-path }} + asset_name: ${{ steps.build-wheel.outputs.asset-name }} + asset_content_type: application/zip diff --git a/README.md b/README.md index b08b72b..e75487e 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ OpenImageIO Python 3.x package. | Build pipeline | CI Status | | ------------- | ------------- | -| Windows Server 2016 | [![Build Status](https://fredrikaverpil.visualstudio.com/oiio-python/_apis/build/status/oiio-python-win2016?branchName=master)](https://fredrikaverpil.visualstudio.com/oiio-python/_build/latest?definitionId=5?branchName=master) | -| Ubuntu 16.041 | [![Build Status](https://fredrikaverpil.visualstudio.com/oiio-python/_apis/build/status/oiio-python-ubuntu16.04?branchName=master)](https://fredrikaverpil.visualstudio.com/oiio-python/_build/latest?definitionId=6?branchName=master) | -| macOS 10.13 | [![Build Status](https://fredrikaverpil.visualstudio.com/oiio-python/_apis/build/status/oiio-python-macOS-10.13?branchName=master)](https://fredrikaverpil.visualstudio.com/oiio-python/_build/latest?definitionId=7&branchName=master) | +| Windows Server 2016 | [![Build Status](https://Ahuge.visualstudio.com/oiio-python/_apis/build/status/oiio-python-win2016?branchName=master)](https://Ahuge.visualstudio.com/oiio-python/_build/latest?definitionId=5?branchName=master) | +| Ubuntu 16.041 | [![Build Status](https://Ahuge.visualstudio.com/oiio-python/_apis/build/status/oiio-python-ubuntu16.04?branchName=master)](https://Ahuge.visualstudio.com/oiio-python/_build/latest?definitionId=6?branchName=master) | +| macOS 10.13 | [![Build Status](https://Ahuge.visualstudio.com/oiio-python/_apis/build/status/oiio-python-macOS-10.13?branchName=master)](https://Ahuge.visualstudio.com/oiio-python/_build/latest?definitionId=7&branchName=master) | 1 Should also work on CentOS 7 for example. @@ -37,4 +37,4 @@ See the `tests` folder for code examples used to test the built wheels' function - A new release is automatically performed when a commit is performed on the `master` branch. - Updating to a newer OpenImageIO version: 1. Update the `oiio.version` variable in the .yml files - 2. Update the version and SHA512 in the OpenImageIO port files. \ No newline at end of file + 2. Update the version and SHA512 in the OpenImageIO port files. diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..676989a --- /dev/null +++ b/build.sh @@ -0,0 +1,89 @@ +set -ex +OIIO_VERSION="2.2.11.1" +OIIO_VERSION="2.5.6.0" + +sudo dnf install -y libjpeg-turbo-devel zlib-devel libpng-devel libtiff-devel OpenEXR-devel LibRaw-devel cmake3 make gcc patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel libuuid-devel gdbm-libs libnsl2 +sudo dnf groupinstall "Development Tools" -y +if ! command -v pyenv &> /dev/null +then + curl https://pyenv.run | bash + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc + echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(pyenv init -)"' >> ~/.bashrc + export PYENV_ROOT="$HOME/.pyenv" + command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" + eval "$(pyenv init -)" +fi +pyenv install 3.10.13 --skip-existing +pyenv global 3.10.13 + +Python_ROOT="$(pyenv root)/versions/$(pyenv version-name)" + +# -I/usr/local/include/python3.10m -I/usr/local/include/python3.10m +# -lpython3.7m -lcrypt -lpthread -ldl -lutil -lm + +export CPLUS_INCLUDE_PATH="$HOME/.pyenv/versions/3.10.13/include/python3.10:$CPLUS_INCLUDE_PATH" +export CPATH="$HOME/.pyenv/versions/3.10.13/include:$CPATH:/usr/include:/usr/local/include" +export LD_LIBRARY_PATH="$HOME/.pyenv/versions/3.10.13/lib:$LD_LIBRARY_PATH:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64" +if [ ! -f boost_1_67_0.tar.gz ]; then + wget https://boostorg.jfrog.io/artifactory/main/release/1.67.0/source/boost_1_67_0.tar.gz + # wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz +fi +if [ ! -d boost_1_67_0 ]; then + tar -xzf boost_1_* +fi +if [ ! -d /opt/boost ]; then + sudo mkdir /opt/boost + sudo chmod -R 777 /opt/boost +fi +cd boost_1_67_0 +sudo ./bootstrap.sh --prefix=/opt/boost +sudo ./b2 install --prefix=/opt/boost --with=all -j4 +cd ../ + +# if [ -d oiio ]; then +# sudo rm -rf oiio; +# fi +if [ ! -d oiio ]; then + git clone https://github.com/OpenImageIO/oiio.git +fi +pip3.10 install pybind11[global] +pip3.10 install numpy + + +cd oiio +git checkout "v${OIIO_VERSION}" +if [ ! -d build ]; then + mkdir build +fi + +export ASWF_ORG="Fake" +export GITHUB_ENV="$(pwd)/github.env" +bash src/build-scripts/gh-installdeps.bash + +cd ../ +bash oiio/src/build-scripts/build_libjpeg-turbo.bash +export LibJpegTurbo_ROOT="$(pwd)/ext/dist" + +OPENEXR_CMAKE_FLAGS="-DCMAKE_NO_SYSTEM_FROM_IMPORTED:BOOL=TRUE" oiio/src/build-scripts/build_openexr.bash +export OpenEXR_ROOT="$(pwd)/ext/dist" +echo "OpenEXR_ROOT=${OpenEXR_ROOT}" +export IlmBase_ROOT="$(pwd)/ext/dist" +cd oiio + + + +sleep 2 +echo "Executing cmake" +cd build && cmake3 .. -DCMAKE_CXX_FLAGS="-Wno-error=unused-variable" -DVERBOSE=1 -DSTOP_ON_WARNING=0 -DBoost_ROOT="/opt/boost" -DOIIO_BUILD_TESTS=0 -DOpenEXR_ROOT="${OpenEXR_ROOT}" -DCMAKE_NO_SYSTEM_FROM_IMPORTED:BOOL="TRUE" -DCMAKE_INSTALL_PREFIX="${OpenEXR_ROOT}"i -DIlmBase_ROOT="${IlmBase_ROOT}" -Dlibjpeg-turbo_ROOT="${LibJpegTurbo_ROOT}" -DPython_ROOT="${Python_ROOT}" -DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES="${Python_ROOT}/include/python3.10" +sleep 2 +echo "Make install" +sudo make install + + +cd ../ +mkdir -p usr/local +cp -R ext/dist/bin ext/dist/include ext/dist/lib ext/dist/share ext/dist/lib64 /opt/boost/lib /opt/boost/include ext/disti/bin ext/disti/lib64 ext/disti/include ext/disti/share ${Python_ROOT}/bin ${Python_ROOT}/lib ${Python_ROOT}/share ${Python_ROOT}/include usr/local/ + +find usr \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s|${Python_ROOT}|/usr/local|g" +tar -czvf oiio-2.5.6.0-openexr-3.1.9-boost-1.67.0-python3.9.tar.gz usr/ diff --git a/macOS-10.13-azure-pipelines.yml b/macOS-10.13-azure-pipelines.yml index 8527fb6..8528114 100644 --- a/macOS-10.13-azure-pipelines.yml +++ b/macOS-10.13-azure-pipelines.yml @@ -25,7 +25,7 @@ jobs: src.vcpkg: '$(Agent.BuildDirectory)/s/src/vcpkg' tests: '$(Agent.BuildDirectory)/s/tests' install.vcpkg: $(Agent.BuildDirectory)/s/vcpkg - oiio.version: '2.0.5' + oiio.version: '2.2.11.1' pypackage.os_name: 'Microsoft :: MacOS' pool: @@ -153,7 +153,7 @@ jobs: - task: GithubRelease@0 inputs: gitHubConnection: 'oiio-python-releases' - repositoryName: 'fredrikaverpil/oiio-python' + repositoryName: 'ArchPlatform/oiio-python' action: 'edit' # Options: create, edit, discard target: '$(build.sourceVersion)' # Required when action == create || action == edit tagSource: 'Git tag' # Required when action == create. Options: auto, manual diff --git a/src/vcpkg/ports/openimageio-py3.6/portfile.cmake b/src/vcpkg/ports/openimageio-py3.6/portfile.cmake index 8fb5bb5..ff4bd72 100644 --- a/src/vcpkg/ports/openimageio-py3.6/portfile.cmake +++ b/src/vcpkg/ports/openimageio-py3.6/portfile.cmake @@ -3,8 +3,8 @@ include(vcpkg_common_functions) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO OpenImageIO/oiio - REF Release-2.0.5 - SHA512 2bf6b3d998e9b7bda90b9dfd3e30702c3c857f6f90ab8be10fd3dc9617ecccc62464a8198a7804d130bdb39b2475c1ce14af129b8ccc371a21e92c2e637a5413 + REF v2.2.11.1 + SHA512 1 HEAD_REF master PATCHES # fix_libraw: replace 'LibRaw_r_LIBRARIES' occurences by 'LibRaw_LIBRARIES' diff --git a/src/vcpkg/ports/openimageio-py3.7/portfile.cmake b/src/vcpkg/ports/openimageio-py3.7/portfile.cmake index cc5fe76..d7b3be4 100644 --- a/src/vcpkg/ports/openimageio-py3.7/portfile.cmake +++ b/src/vcpkg/ports/openimageio-py3.7/portfile.cmake @@ -3,8 +3,8 @@ include(vcpkg_common_functions) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO OpenImageIO/oiio - REF Release-2.0.5 - SHA512 2bf6b3d998e9b7bda90b9dfd3e30702c3c857f6f90ab8be10fd3dc9617ecccc62464a8198a7804d130bdb39b2475c1ce14af129b8ccc371a21e92c2e637a5413 + REF v2.2.11.1 + SHA512 1 HEAD_REF master PATCHES # fix_libraw: replace 'LibRaw_r_LIBRARIES' occurences by 'LibRaw_LIBRARIES' diff --git a/ubuntu16.04-azure-pipelines.yml b/ubuntu16.04-azure-pipelines.yml index 6a17505..69aa19f 100644 --- a/ubuntu16.04-azure-pipelines.yml +++ b/ubuntu16.04-azure-pipelines.yml @@ -24,7 +24,7 @@ jobs: src.vcpkg: '$(Agent.BuildDirectory)/s/src/vcpkg' tests: '$(Agent.BuildDirectory)/s/tests' install.vcpkg: $(Agent.BuildDirectory)/s/vcpkg - oiio.version: '2.0.5' + oiio.version: '2.2.11.1' pypackage.os_name: 'Microsoft :: POSIX :: Linux' pool: @@ -161,7 +161,7 @@ jobs: - task: GithubRelease@0 inputs: gitHubConnection: 'oiio-python-releases' - repositoryName: 'fredrikaverpil/oiio-python' + repositoryName: 'ArchPlatform/oiio-python' action: 'edit' # Options: create, edit, discard target: '$(build.sourceVersion)' # Required when action == create || action == edit tagSource: 'Git tag' # Required when action == create. Options: auto, manual diff --git a/win2016-azure-pipelines.yml b/win2016-azure-pipelines.yml index 560c427..ea3917e 100644 --- a/win2016-azure-pipelines.yml +++ b/win2016-azure-pipelines.yml @@ -23,7 +23,7 @@ jobs: src.python: '$(Agent.BuildDirectory)/s/src/python' src.vcpkg: '$(Agent.BuildDirectory)/s/src/vcpkg' tests: '$(Agent.BuildDirectory)/s/tests' - oiio.version: '2.0.5' + oiio.version: '2.2.11.1' pypackage.os_name: 'Microsoft :: Windows' pool: @@ -189,7 +189,7 @@ jobs: - task: GithubRelease@0 inputs: gitHubConnection: 'oiio-python-releases' - repositoryName: 'fredrikaverpil/oiio-python' + repositoryName: 'ArchPlatform/oiio-python' action: 'edit' # Options: create, edit, discard target: '$(build.sourceVersion)' # Required when action == create || action == edit tagSource: 'Git tag' # Required when action == create. Options: auto, manual