Adding Windows 32-bit and 64-bit builds
- Basic tests are working - May need some adjustments to get all tests working - Cleaned up bundling to take Python arch into account when building with multiple architectures
This commit is contained in:
4
.github/workflows/pythonpackage.yml
vendored
4
.github/workflows/pythonpackage.yml
vendored
@@ -27,14 +27,12 @@ jobs:
|
||||
pip install -r requirements.txt
|
||||
- name: Build pycapnp and install
|
||||
run: |
|
||||
python setup.py build # Not necessary, but shows output on stdout
|
||||
python setup.py build
|
||||
pip install .
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
pip install flake8
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude benchmark
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
|
||||
@@ -13,7 +13,7 @@ def build_libcapnp(bundle_dir, build_dir):
|
||||
bundle_dir = os.path.abspath(bundle_dir)
|
||||
capnp_dir = os.path.join(bundle_dir, 'capnproto-c++')
|
||||
build_dir = os.path.abspath(build_dir)
|
||||
tmp_dir = os.path.join(capnp_dir, 'build')
|
||||
tmp_dir = os.path.join(capnp_dir, 'build{}'.format(8 * struct.calcsize("P")))
|
||||
|
||||
# Clean the tmp build directory every time
|
||||
if os.path.exists(tmp_dir):
|
||||
@@ -31,6 +31,7 @@ def build_libcapnp(bundle_dir, build_dir):
|
||||
# Determine python shell architecture
|
||||
python_arch = 8 * struct.calcsize("P")
|
||||
build_arch = []
|
||||
build_flags = []
|
||||
if os.name == 'nt':
|
||||
if python_arch == 64:
|
||||
build_arch_flag = "x64"
|
||||
@@ -39,8 +40,12 @@ def build_libcapnp(bundle_dir, build_dir):
|
||||
else:
|
||||
raise RuntimeError('Unknown windows build arch')
|
||||
build_arch = ['-A', build_arch_flag]
|
||||
build_flags = ['--config', 'Release']
|
||||
print('Building module for {}'.format(python_arch))
|
||||
|
||||
if not shutil.which('cmake'):
|
||||
raise RuntimeError('Could not find cmake in your path!')
|
||||
|
||||
args = [
|
||||
'cmake',
|
||||
'-DCMAKE_POSITION_INDEPENDENT_CODE=1',
|
||||
@@ -57,13 +62,15 @@ def build_libcapnp(bundle_dir, build_dir):
|
||||
raise RuntimeError('CMake failed {}'.format(returncode))
|
||||
|
||||
# Run build through cmake
|
||||
build = subprocess.Popen([
|
||||
args = [
|
||||
'cmake',
|
||||
'--build',
|
||||
'.',
|
||||
'--target',
|
||||
'install',
|
||||
], cwd=tmp_dir, stdout=sys.stdout)
|
||||
]
|
||||
args.extend(build_flags)
|
||||
build = subprocess.Popen(args, cwd=tmp_dir, stdout=sys.stdout)
|
||||
returncode = build.wait()
|
||||
if cxxflags is None:
|
||||
del os.environ['CXXFLAGS']
|
||||
|
||||
@@ -58,7 +58,8 @@ def test_compilation(cfile, compiler=None, **compiler_attrs):
|
||||
else:
|
||||
lpreargs = ['-m64']
|
||||
extra_compile_args = compiler_attrs.get('extra_compile_args', [])
|
||||
extra_compile_args += ['--std=c++14']
|
||||
if os.name != 'nt':
|
||||
extra_compile_args += ['--std=c++14']
|
||||
extra_link_args = compiler_attrs.get('extra_link_args', [])
|
||||
if cc.compiler_type == 'msvc':
|
||||
extra_link_args += ['/MANIFEST']
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#ifdef __GNUC__
|
||||
#if __clang__
|
||||
#if __cplusplus >= 201103L && !__has_include(<initializer_list>)
|
||||
#warning "Your compiler supports C++11 but your C++ standard library does not. If your system has libc++ installed (as should be the case on e.g. Mac OSX), try adding -stdlib=libc++ to your CFLAGS (ignore the other warning that says to use CXXFLAGS)."
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
#endif
|
||||
|
||||
#include "capnp/dynamic.h"
|
||||
|
||||
static_assert(CAPNP_VERSION >= 5000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.5 and then re-install this python library");
|
||||
static_assert(CAPNP_VERSION >= 7000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.7 and then re-install this python library");
|
||||
@@ -1,6 +1,5 @@
|
||||
# schema.capnp.cpp.pyx
|
||||
# distutils: language = c++
|
||||
# distutils: extra_compile_args = --std=c++14
|
||||
cdef extern from "capnp/helpers/checkCompiler.h":
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# schema.capnp.cpp.pyx
|
||||
# distutils: language = c++
|
||||
# distutils: extra_compile_args = --std=c++14
|
||||
|
||||
from libc.stdint cimport *
|
||||
from capnp_cpp cimport DynamicOrphan
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# capnp.pyx
|
||||
# distutils: language = c++
|
||||
# distutils: extra_compile_args = --std=c++14
|
||||
# distutils: libraries = capnpc capnp-rpc capnp kj-async kj
|
||||
# distutils: include_dirs = .
|
||||
# cython: c_string_type = str
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# addressbook_fast.pyx
|
||||
# distutils: language = c++
|
||||
# distutils: extra_compile_args = --std=c++14
|
||||
# distutils: include_dirs = {{include_dir}}
|
||||
# distutils: libraries = capnpc capnp capnp-rpc
|
||||
# distutils: sources = {{file.filename}}.cpp
|
||||
|
||||
21
setup.py
21
setup.py
@@ -6,6 +6,7 @@ pycapnp-async distutils setup.py
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from distutils.command.clean import clean as _clean
|
||||
@@ -13,7 +14,7 @@ from distutils.errors import CompileError
|
||||
from distutils.extension import Extension
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
from setuptools import setup
|
||||
from setuptools import setup, find_packages, Extension
|
||||
|
||||
from buildutils import test_build, fetch_libcapnp, build_libcapnp, info
|
||||
|
||||
@@ -138,7 +139,7 @@ class build_libcapnp_ext(build_ext_c):
|
||||
bundle_dir = os.path.join(_this_dir, "bundled")
|
||||
if not os.path.exists(bundle_dir):
|
||||
os.mkdir(bundle_dir)
|
||||
build_dir = os.path.join(_this_dir, "build")
|
||||
build_dir = os.path.join(_this_dir, "build{}".format(8 * struct.calcsize("P")))
|
||||
if not os.path.exists(build_dir):
|
||||
os.mkdir(build_dir)
|
||||
|
||||
@@ -159,10 +160,20 @@ class build_libcapnp_ext(build_ext_c):
|
||||
|
||||
return build_ext_c.run(self)
|
||||
|
||||
extra_compile_args = ['--std=c++14']
|
||||
extra_link_args = []
|
||||
if os.name == 'nt':
|
||||
extra_compile_args = ['/std:c++14', '/MD']
|
||||
extra_link_args = ['/MANIFEST']
|
||||
|
||||
from Cython.Build import cythonize
|
||||
import Cython.Build
|
||||
import Cython # noqa: F401
|
||||
extensions = cythonize('capnp/lib/*.pyx')
|
||||
extensions = [Extension(
|
||||
'*', ['capnp/lib/*.pyx'],
|
||||
extra_compile_args=extra_compile_args,
|
||||
extra_link_args=extra_link_args,
|
||||
language='c++',
|
||||
)]
|
||||
|
||||
setup(
|
||||
name="pycapnp-async",
|
||||
@@ -174,7 +185,7 @@ setup(
|
||||
'includes/*.pxd', 'lib/*.pxd', 'lib/*.py', 'lib/*.pyx', 'templates/*'
|
||||
]
|
||||
},
|
||||
ext_modules=extensions,
|
||||
ext_modules=Cython.Build.cythonize(extensions),
|
||||
cmdclass={
|
||||
'clean': clean,
|
||||
'build_ext': build_libcapnp_ext
|
||||
|
||||
Reference in New Issue
Block a user