Skip to content

Commit

Permalink
Win wheels (#139)
Browse files Browse the repository at this point in the history
Add building of tgcalls wheels for Windows
  • Loading branch information
MarshalX authored Aug 21, 2021
1 parent f4703f2 commit 14fd12b
Show file tree
Hide file tree
Showing 15 changed files with 541 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ jobs:
- name: Upload artifacts.
uses: actions/upload-artifact@v2
with:
name: Wheels for macOS
name: "tgcalls for macOS (Intel)"
path: dist/

- name: Upload wheels to PyPi.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
name: Build and publish wheels for Windows x32 and many Python versions
on:
push:
branches:
- main
- pypi-dev
paths:
- '.github/workflows/build_and_publish_win_x32_wheels_for_many_python_versions.yaml'
- 'tgcalls/third_party/webrtc/**'
- 'tgcalls/**'
- 'CMakeLists.txt'
- 'setup.py'
jobs:

build_wheels_for_win:
name: Build and publish wheels for Windows x32
runs-on: windows-latest

env:
BUILD_WHEELS: "true"
UPLOAD_WHEELS: "true"
GLOBAL_CACHE_KEY: "4"
WEBRTC_CACHE_KEY: "5"

defaults:
run:
shell: cmd
working-directory: Libraries

steps:
- name: Get repository name.
shell: bash
working-directory: ${{ github.workspace }}
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

- uses: ilammy/msvc-dev-cmd@v1.9.0
name: x86 Native Tools Command Prompt.
with:
arch: win32

- name: Set up environment paths.
shell: bash
working-directory: ${{ github.workspace }}
run: |
echo "C:\\Strawberry\\perl\\bin\\" >> $GITHUB_PATH
echo "C:\\Program Files\\NASM\\" >> $GITHUB_PATH
echo "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\" >> $GITHUB_PATH
mkdir Libraries && cd Libraries
echo "Convert unix path to win path."
p=`pwd | sed 's#^/[d]#d:#g' |sed 's#/#\\\\#g'`
echo "LibrariesPath=$p" >> $GITHUB_ENV
- name: Save msbuild version.
run: |
call vcvars32.bat
msbuild -version > CACHE_KEY.txt
- name: Clone.
uses: actions/checkout@v2
with:
submodules: recursive
path: ${{ env.REPO_NAME }}

- name: Generate cache key.
shell: bash
run: |
echo $GLOBAL_CACHE_KEY >> CACHE_KEY.txt
echo "$GITHUB_WORKSPACE" >> CACHE_KEY.txt
echo "CACHE_KEY=`md5sum CACHE_KEY.txt | awk '{ print $1 }'`" >> $GITHUB_ENV
- name: Choco installs.
run: |
choco install --allow-empty-checksums --no-progress -y yasm
choco install --no-progress -y nasm jom ninja
- name: NuGet sources.
run: |
nuget sources Disable -Name "Microsoft Visual Studio Offline Packages"
nuget sources Add -Source https://api.nuget.org/v3/index.json & exit 0
- name: Patches.
shell: bash
run: |
cd $LibrariesPath
git clone https://github.com/desktop-app/patches.git
cd patches
git checkout 87a2e9ee07
- name: MozJPEG.
shell: cmd
run: |
git clone -b v4.0.1-rc2 https://github.com/mozilla/mozjpeg.git
cd mozjpeg
cmake . ^
-G "Visual Studio 16 2019" ^
-A Win32 ^
-DWITH_JPEG8=ON ^
-DPNG_SUPPORTED=OFF
cmake --build . --config Release
- name: OpenSSL cache.
id: cache-openssl
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/openssl_1_1_1
key: ${{ runner.OS }}-${{ env.CACHE_KEY }}-openssl_1_1_1
- name: OpenSSL.
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: |
git clone https://github.com/openssl/openssl.git openssl_1_1_1
cd openssl_1_1_1
git checkout OpenSSL_1_1_1-stable
perl Configure no-shared no-tests debug-VC-WIN32
nmake
mkdir out32.dbg
move libcrypto.lib out32.dbg
move libssl.lib out32.dbg
move ossl_static.pdb out32.dbg\ossl_static
nmake clean
move out32.dbg\ossl_static out32.dbg\ossl_static.pdb
perl Configure no-shared no-tests VC-WIN32
nmake
mkdir out32
move libcrypto.lib out32
move libssl.lib out32
move ossl_static.pdb out32
rmdir /S /Q test
rmdir /S /Q .git
- name: Opus cache.
id: cache-opus
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/opus
key: ${{ runner.OS }}-opus-${{ env.CACHE_KEY }}
- name: Opus.
if: steps.cache-opus.outputs.cache-hit != 'true'
run: |
git clone https://github.com/telegramdesktop/opus.git
cd opus
git checkout tdesktop
cd win32\VS2015
msbuild -m opus.sln /property:Configuration=Debug /property:Platform="Win32"
msbuild -m opus.sln /property:Configuration=Release /property:Platform="Win32"
- name: FFmpeg cache.
id: cache-ffmpeg
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/ffmpeg
key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}-${{ hashFiles('**/build_ffmpeg_win.sh') }}
- name: FFmpeg.
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
choco install --no-progress -y msys2
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
git checkout release/4.4
set CHERE_INVOKING=enabled_from_arguments
set MSYS2_PATH_TYPE=inherit
call c:\tools\msys64\usr\bin\bash --login ../patches/build_ffmpeg_win.sh
rmdir /S /Q .git
- name: WebRTC cache.
id: cache-webrtc
uses: actions/cache@v2
with:
path: ${{ env.LibrariesPath }}/tg_owt
key: ${{ runner.OS }}-webrtc-${{ env.CACHE_KEY }}-${{ env.WEBRTC_CACHE_KEY }}
- name: WebRTC.
if: steps.cache-webrtc.outputs.cache-hit != 'true'
run: |
xcopy ..\tgcalls\tgcalls\third_party\webrtc tg_owt\ /E/H
mkdir tg_owt\out\Release
cd tg_owt\out\Release
cmake -G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
-DTG_OWT_SPECIAL_TARGET=win ^
-DBUILD_SHARED_LIBS=OFF ^
-DCMAKE_POSITION_INDEPENDENT_CODE=ON ^
-DTG_OWT_USE_PIPEWIRE=OFF ^
-DTG_OWT_LIBJPEG_INCLUDE_PATH=%cd%/../../../mozjpeg ^
-DTG_OWT_OPENSSL_INCLUDE_PATH=%cd%/../../../openssl_1_1_1/include ^
-DTG_OWT_OPUS_INCLUDE_PATH=%cd%/../../../opus/include ^
-DTG_OWT_FFMPEG_INCLUDE_PATH=%cd%/../../../ffmpeg ^
../..
ninja
:: Cleanup.
cd %LibrariesPath%\tg_owt
move out\Release\tg_owt.lib tg_owt.lib
rmdir /S /Q out
mkdir out\Release
move tg_owt.lib out\Release\tg_owt.lib
- name: Build wheels.
if: env.BUILD_WHEELS == 'true'
working-directory: ${{ github.workspace }}
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.6"
CIBW_ARCHS: "auto32"
CIBW_BUILD: cp3*-*
CIBW_SKIP: cp35-*
CIBW_ENVIRONMENT: 'ROOT_PATH="$GITHUB_WORKSPACE"'
CIBW_TEST_COMMAND: 'python -c "import tgcalls;tgcalls.ping()"'
CIBW_BEFORE_BUILD: 'call vcvars32.bat'
run: |
pip install cibuildwheel
cibuildwheel --output-dir dist %REPO_NAME%
- uses: actions/upload-artifact@master
name: Upload artifact.
with:
name: "tgcalls for Windows x32"
path: dist\

- name: Upload wheels to PyPi.
if: env.UPLOAD_WHEELS == 'true'
working-directory: ${{ github.workspace }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
pip install twine
twine upload dist/*
Loading

0 comments on commit 14fd12b

Please sign in to comment.