mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Adding Windows compilation support
- Automatically determining build arch from running Python shell * Should work across all platforms
This commit is contained in:
parent
67d5276936
commit
063522d308
2 changed files with 16 additions and 3 deletions
2
.github/workflows/pythonpackage.yml
vendored
2
.github/workflows/pythonpackage.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
|||
# Some asyncio commands require 3.7+
|
||||
# It may be possible to use 3.6 and maybe 3.5; however, this will take some patching to get examples to work
|
||||
python-version: [3.7]
|
||||
os: [ubuntu-latest, macOS-latest]
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
import subprocess
|
||||
import os
|
||||
import shutil
|
||||
import struct
|
||||
import sys
|
||||
|
||||
def build_libcapnp(bundle_dir, build_dir, verbose=False):
|
||||
def build_libcapnp(bundle_dir, build_dir):
|
||||
'''
|
||||
Build capnproto
|
||||
'''
|
||||
|
@ -27,7 +28,18 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
|
|||
if shutil.which('ninja'):
|
||||
build_type = ['-G', 'Ninja']
|
||||
|
||||
# TODO Determine VS version
|
||||
# Determine python shell architecture
|
||||
python_arch = 8 * struct.calcsize("P")
|
||||
build_arch = []
|
||||
if os.name == 'nt':
|
||||
if python_arch == 64:
|
||||
build_arch_flag = "x64"
|
||||
elif python_arch == 32:
|
||||
build_arch_flag = "Win32"
|
||||
else:
|
||||
raise RuntimeError('Unknown windows build arch')
|
||||
build_arch = ['-A', build_arch_flag]
|
||||
print('Building module for {}'.format(python_arch))
|
||||
|
||||
args = [
|
||||
'cmake',
|
||||
|
@ -38,6 +50,7 @@ def build_libcapnp(bundle_dir, build_dir, verbose=False):
|
|||
capnp_dir,
|
||||
]
|
||||
args.extend(build_type)
|
||||
args.extend(build_arch)
|
||||
conf = subprocess.Popen(args, cwd=tmp_dir, stdout=sys.stdout)
|
||||
returncode = conf.wait()
|
||||
if returncode != 0:
|
||||
|
|
Loading…
Add table
Reference in a new issue