Skip to content

Commit

Permalink
Add supports for Ubuntu 18.04 and other Linux Distro with GLIBC Versi…
Browse files Browse the repository at this point in the history
…on < 2.29 and cmake version < 3.15

Signed-off-by: ArchieMeng <[email protected]>
  • Loading branch information
ArchieMeng committed May 4, 2021
1 parent 8633eb3 commit 0c2ca42
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 15 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ jobs:
cmake ../src
cmake --build . -j 2
ubuntu-1804: # no needs to install swig for it is already there
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: cache-vulkansdk
id: cache-vulkansdk
uses: actions/cache@v1
with:
path: "1.2.162.0"
key: vulkansdk-linux-x86_64-1.2.162.0
- name: vulkansdk
if: steps.cache-vulkansdk.outputs.cache-hit != 'true'
run: |
wget https://sdk.lunarg.com/sdk/download/1.2.162.0/linux/vulkansdk-linux-x86_64-1.2.162.0.tar.gz?Human=true -O vulkansdk-linux-x86_64-1.2.162.0.tar.gz
tar -xf vulkansdk-linux-x86_64-1.2.162.0.tar.gz
rm -rf 1.2.162.0/source 1.2.162.0/samples
find 1.2.162.0 -type f | grep -v -E 'vulkan|glslang' | xargs rm
- name: build
run: |
export VULKAN_SDK=`pwd`/1.2.162.0/x86_64
mkdir build && cd build
cmake ../src
cmake --build . -j 2
macos:
runs-on: macos-latest
steps:
Expand Down
75 changes: 65 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
env:
DEVELOPER_DIR: /Applications/Xcode_12.2.app/Contents/Developer
APPLICATION_NAME: realsr-ncnn-vulkan-python
APPNAME_SHORT: realsr

jobs:

Expand Down Expand Up @@ -55,9 +56,9 @@ jobs:
run: |
mkdir -p ${{ env.PACKAGENAME }}
cp README.md LICENSE ${{ env.PACKAGENAME }}
cp build/realsr_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build/realsr_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build/_realsr_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build/_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp -r models/ ${{ env.PACKAGENAME }}
zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
- name: upload
Expand All @@ -66,6 +67,49 @@ jobs:
name: ${{ env.PACKAGENAME }}
path: ${{ env.PACKAGENAME }}.zip

ubuntu-1804:
needs: [setup]
runs-on: ubuntu-18.04
env:
PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.VERSION }}-ubuntu-1804
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: cache-vulkansdk
id: cache-vulkansdk
uses: actions/cache@v1
with:
path: "1.2.162.0"
key: vulkansdk-linux-x86_64-1.2.162.0
- name: vulkansdk
if: steps.cache-vulkansdk.outputs.cache-hit != 'true'
run: |
wget https://sdk.lunarg.com/sdk/download/1.2.162.0/linux/vulkansdk-linux-x86_64-1.2.162.0.tar.gz?Human=true -O vulkansdk-linux-x86_64-1.2.162.0.tar.gz
tar -xf vulkansdk-linux-x86_64-1.2.162.0.tar.gz
rm -rf 1.2.162.0/source 1.2.162.0/samples
find 1.2.162.0 -type f | grep -v -E 'vulkan|glslang' | xargs rm
- name: build
run: |
export VULKAN_SDK=`pwd`/1.2.162.0/x86_64
mkdir build && cd build
cmake ../src
cmake --build . -j 2
- name: package
run: |
mkdir -p ${{ env.PACKAGENAME }}
cp README.md LICENSE ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build/${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build/_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp -r models/ ${{ env.PACKAGENAME }}
zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
- name: upload
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGENAME }}
path: ${{ env.PACKAGENAME }}.zip

openmp-macos:
runs-on: macos-latest
steps:
Expand Down Expand Up @@ -182,9 +226,9 @@ jobs:
run: |
mkdir -p ${{ env.PACKAGENAME }}
cp README.md LICENSE ${{ env.PACKAGENAME }}
cp build-x86_64/realsr_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build-x86_64/realsr_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build-x86_64/_realsr_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp build-x86_64/${{ env.APPNAME_SHORT }}_ncnn_vulkan.py ${{ env.PACKAGENAME }}
cp build-x86_64/${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py ${{ env.PACKAGENAME }}
cp build-x86_64/_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.so ${{ env.PACKAGENAME }}
cp -r models/ ${{ env.PACKAGENAME }}
zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
- name: upload
Expand Down Expand Up @@ -241,9 +285,9 @@ jobs:
ls build
Copy-Item -Verbose -Path "README.md" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "LICENSE" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "src\realsr_ncnn_vulkan.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\realsr_ncnn_vulkan_wrapper.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\Release\_realsr_ncnn_vulkan_wrapper.pyd" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "src\${{ env.APPNAME_SHORT }}_ncnn_vulkan.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.py" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "build\Release\_${{ env.APPNAME_SHORT }}_ncnn_vulkan_wrapper.pyd" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Path "C:\windows\system32\vcomp140.dll" -Destination "${{ env.PACKAGENAME }}"
Copy-Item -Verbose -Recurse -Path "models" -Destination "${{ env.PACKAGENAME }}"
7z a -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
Expand All @@ -254,7 +298,7 @@ jobs:
path: ${{ env.PACKAGENAME }}.zip

release:
needs: [setup, ubuntu, macos, windows]
needs: [setup, ubuntu, ubuntu-1804, macos, windows]
runs-on: ubuntu-latest
steps:
- name: download
Expand Down Expand Up @@ -284,6 +328,17 @@ jobs:
asset_name: ${{ env.PACKAGENAME }}.zip
asset_content_type: application/zip

- name: upload-ubuntu-1804
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.VERSION }}-ubuntu-1804
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/${{ env.PACKAGENAME }}/${{ env.PACKAGENAME }}.zip
asset_name: ${{ env.PACKAGENAME }}.zip
asset_content_type: application/zip

- name: upload-macos
uses: actions/upload-release-asset@v1
env:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ realsr-ncnn-vulkan-python wraps [realsr-ncnn-vulkan project](https://github.com/

## Downloads

Linux/Windos/Mac X86_64 build releases are available now. However, for Linux you may need to compile it yourself if you
are using python version other than 3.8 . (The compiled python C extension library is bound to python version now)
Linux/Windos/Mac X86_64 build releases are available now.

However, for Linux distro with GLIBC < 2.29 (like Ubuntu 18.04), the ubuntu-1804 pre-built should be used.

## Build

Expand Down
17 changes: 14 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

project(realsr-ncnn-vulkan-python)

# Python
if (${CMAKE_VERSION} VERSION_LESS "3.15")
find_package(Python REQUIRED)
else()
find_package(Python REQUIRED COMPONENTS Development)
endif()

# SWIG
find_package(Python REQUIRED COMPONENTS Development)
find_package(SWIG REQUIRED COMPONENTS python)
if(SWIG_FOUND)
message("SWIG found: ${SWIG_EXECUTABLE}")
Expand Down Expand Up @@ -316,4 +322,9 @@ set_property(SOURCE realsr.i PROPERTY CPLUSPLUS ON DEPENDS generate-spirv)
swig_add_library(realsr_ncnn_vulkan_wrapper LANGUAGE python SOURCES realsr.i realsr.cpp realsr_wrapped.cpp)
add_dependencies(realsr_ncnn_vulkan_wrapper generate-spirv)
target_compile_options(realsr_ncnn_vulkan_wrapper PUBLIC -fexceptions)
target_link_libraries(realsr_ncnn_vulkan_wrapper ${REALSR_LINK_LIBRARIES} Python::Module)
if (${CMAKE_VERSION} VERSION_LESS "3.15")
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries(realsr_ncnn_vulkan_wrapper ${REALSR_LINK_LIBRARIES} ${PYTHON_LIBRARIES})
else()
target_link_libraries(realsr_ncnn_vulkan_wrapper ${REALSR_LINK_LIBRARIES} Python::Module)
endif()

0 comments on commit 0c2ca42

Please sign in to comment.