How to Use AppVeyor to Build and Deploy Python Wheels from C/C++ Code

Creating Python Wheels

  1. Build *.pyd extension file from C/C++ code.
  2. Pack *.pyd and dependent *.dll files into a wheel file.

The *.pyd Python module

git clone https://github.com/yushulx/python.git
elif sys.platform == "win32":    # Windows    dbr_lib_name = 'DBRx64'    dbr_lib_dir = r'..\lib'    dbr_dll = r'..\bin'
cd srcpython setup.py build

The *.whl file

from .dbr import *
copy ..\bin\*.* ..\wheel\dbr\cd build\lib.win-*\copy *.* ..\..\..\wheel\dbr\
python setup.py bdist_wheel

Configuring YAML file for AppVeyor Build Service

branches:  only:    - wheel
environment:  matrix:    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019  PYTHON: "C:/Python27-x64"    - PYTHON: "C:/Python35-x64"    - PYTHON: "C:/Python36-x64"    - PYTHON: "C:/Python37-x64"    - PYTHON: "C:/Python38-x64"
Traceback (most recent call last):File "setup.py", line 63, in <module>cmdclass={'install': CustomInstall}File "C:\Python27-x64\lib\distutils\core.py", line 151, in setupdist.run_commands()File "C:\Python27-x64\lib\distutils\dist.py", line 953, in run_commandsself.run_command(cmd)File "C:\Python27-x64\lib\distutils\dist.py", line 972, in run_commandcmd_obj.run()File "C:\Python27-x64\lib\distutils\command\build.py", line 127, in runself.run_command(cmd_name)File "C:\Python27-x64\lib\distutils\cmd.py", line 326, in run_commandself.distribution.run_command(command)File "C:\Python27-x64\lib\distutils\dist.py", line 972, in run_commandcmd_obj.run()File "C:\Python27-x64\lib\distutils\command\build_ext.py", line 340, in runself.build_extensions()File "C:\Python27-x64\lib\distutils\command\build_ext.py", line 449, in build_extensionsself.build_extension(ext)File "C:\Python27-x64\lib\distutils\command\build_ext.py", line 499, in build_extensiondepends=ext.depends)File "C:\Python27-x64\lib\distutils\msvc9compiler.py", line 473, in compileself.initialize()File "C:\Python27-x64\lib\distutils\msvc9compiler.py", line 383, in initializevc_env = query_vcvarsall(VERSION, plat_spec)File "C:\Python27-x64\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsallraise ValueError(str(list(result.keys())))ValueError: [u'path']Command exited with code 1
install:- SET VS90COMNTOOLS=%VS140COMNTOOLS%
build_script:  - cmd: |    "%PYTHON%/python.exe" -m pip install --upgrade pip    "%PYTHON%/python.exe" -m pip install --upgrade setuptools wheel     numpy  cd src  "%PYTHON%/python.exe" setup.py build  copy ..\bin\*.* ..\wheel\dbr\  cd build\lib.win-*\  copy *.* ..\..\..\wheel\dbr\  cd ..\..\..\wheel\  "%PYTHON%/python.exe" setup.py bdist_wheel
artifacts:  - path: wheel\dist\*.whl    name: wheels
deploy_script:  - ps: |  if($env:APPVEYOR_REPO_TAG -eq 'true') {  Write-Output ("Deploying " + $env:APPVEYOR_REPO_TAG_NAME + " to   PyPI...")  &amp;"${Env:PYTHON}/python.exe" -m pip install twine  &amp;"${Env:PYTHON}/python.exe" -m twine upload -u ${Env:USER} -p   ${Env:PASS} --skip-existing dist/*.whl  } else {  Write-Output "No tag for deployment"  }

Reference

Source Code

--

--

--

Manager of Dynamsoft Open Source Projects | Tech Lover

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Setting up custom wallet in your website with Paytm gateway/UPI (Technical Details)

Building MARINER

How AWS Reserved Instance Discounts Are Applied

Alvin’s Dew Drop Daily — Issue #92

Meet Sebastian, Head of Development at Yodel

What happens when a URL is typed, and how does the browser diplay its content ?

HackerRank 30 Days of Code: Day 9 — Recursion

Recommended Development Principles and Approaches

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Xiao Ling

Xiao Ling

Manager of Dynamsoft Open Source Projects | Tech Lover

More from Medium

Delphi VCL & FMX Libraries for Python — Embarcadero

CreateURL — not your typical URL shortener.

OCR is Optical Character Recognition, which defines the process of converting scanned documents or…

Long-term Google Trends in Python with Longtrends