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
elif sys.platform == "win32":    # Windows    dbr_lib_name = 'DBRx64'    dbr_lib_dir = r'..\lib'    dbr_dll = r'..\bin'
cd srcpython build

The *.whl file

from .dbr import *
copy ..\bin\*.* ..\wheel\dbr\cd build\*\copy *.* ..\..\..\wheel\dbr\
python 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 "", line 63, in <module>cmdclass={'install': CustomInstall}File "C:\Python27-x64\lib\distutils\", line 151, in setupdist.run_commands()File "C:\Python27-x64\lib\distutils\", line 953, in run_commandsself.run_command(cmd)File "C:\Python27-x64\lib\distutils\", line 972, in "C:\Python27-x64\lib\distutils\command\", line 127, in runself.run_command(cmd_name)File "C:\Python27-x64\lib\distutils\", line 326, in run_commandself.distribution.run_command(command)File "C:\Python27-x64\lib\distutils\", line 972, in "C:\Python27-x64\lib\distutils\command\", line 340, in runself.build_extensions()File "C:\Python27-x64\lib\distutils\command\", line 449, in build_extensionsself.build_extension(ext)File "C:\Python27-x64\lib\distutils\command\", line 499, in build_extensiondepends=ext.depends)File "C:\Python27-x64\lib\distutils\", line 473, in compileself.initialize()File "C:\Python27-x64\lib\distutils\", line 383, in initializevc_env = query_vcvarsall(VERSION, plat_spec)File "C:\Python27-x64\lib\distutils\", line 299, in query_vcvarsallraise ValueError(str(list(result.keys())))ValueError: [u'path']Command exited with code 1
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" build  copy ..\bin\*.* ..\wheel\dbr\  cd build\*\  copy *.* ..\..\..\wheel\dbr\  cd ..\..\..\wheel\  "%PYTHON%/python.exe" 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"  }


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