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
|
pip install -r requirements.txt
|
||||||
- name: Build pycapnp and install
|
- name: Build pycapnp and install
|
||||||
run: |
|
run: |
|
||||||
python setup.py build # Not necessary, but shows output on stdout
|
python setup.py build
|
||||||
pip install .
|
pip install .
|
||||||
- name: Lint with flake8
|
- name: Lint with flake8
|
||||||
run: |
|
run: |
|
||||||
pip install flake8
|
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
|
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
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ def build_libcapnp(bundle_dir, build_dir):
|
|||||||
bundle_dir = os.path.abspath(bundle_dir)
|
bundle_dir = os.path.abspath(bundle_dir)
|
||||||
capnp_dir = os.path.join(bundle_dir, 'capnproto-c++')
|
capnp_dir = os.path.join(bundle_dir, 'capnproto-c++')
|
||||||
build_dir = os.path.abspath(build_dir)
|
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
|
# Clean the tmp build directory every time
|
||||||
if os.path.exists(tmp_dir):
|
if os.path.exists(tmp_dir):
|
||||||
@@ -31,6 +31,7 @@ def build_libcapnp(bundle_dir, build_dir):
|
|||||||
# Determine python shell architecture
|
# Determine python shell architecture
|
||||||
python_arch = 8 * struct.calcsize("P")
|
python_arch = 8 * struct.calcsize("P")
|
||||||
build_arch = []
|
build_arch = []
|
||||||
|
build_flags = []
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
if python_arch == 64:
|
if python_arch == 64:
|
||||||
build_arch_flag = "x64"
|
build_arch_flag = "x64"
|
||||||
@@ -39,8 +40,12 @@ def build_libcapnp(bundle_dir, build_dir):
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError('Unknown windows build arch')
|
raise RuntimeError('Unknown windows build arch')
|
||||||
build_arch = ['-A', build_arch_flag]
|
build_arch = ['-A', build_arch_flag]
|
||||||
|
build_flags = ['--config', 'Release']
|
||||||
print('Building module for {}'.format(python_arch))
|
print('Building module for {}'.format(python_arch))
|
||||||
|
|
||||||
|
if not shutil.which('cmake'):
|
||||||
|
raise RuntimeError('Could not find cmake in your path!')
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
'cmake',
|
'cmake',
|
||||||
'-DCMAKE_POSITION_INDEPENDENT_CODE=1',
|
'-DCMAKE_POSITION_INDEPENDENT_CODE=1',
|
||||||
@@ -57,13 +62,15 @@ def build_libcapnp(bundle_dir, build_dir):
|
|||||||
raise RuntimeError('CMake failed {}'.format(returncode))
|
raise RuntimeError('CMake failed {}'.format(returncode))
|
||||||
|
|
||||||
# Run build through cmake
|
# Run build through cmake
|
||||||
build = subprocess.Popen([
|
args = [
|
||||||
'cmake',
|
'cmake',
|
||||||
'--build',
|
'--build',
|
||||||
'.',
|
'.',
|
||||||
'--target',
|
'--target',
|
||||||
'install',
|
'install',
|
||||||
], cwd=tmp_dir, stdout=sys.stdout)
|
]
|
||||||
|
args.extend(build_flags)
|
||||||
|
build = subprocess.Popen(args, cwd=tmp_dir, stdout=sys.stdout)
|
||||||
returncode = build.wait()
|
returncode = build.wait()
|
||||||
if cxxflags is None:
|
if cxxflags is None:
|
||||||
del os.environ['CXXFLAGS']
|
del os.environ['CXXFLAGS']
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ def test_compilation(cfile, compiler=None, **compiler_attrs):
|
|||||||
else:
|
else:
|
||||||
lpreargs = ['-m64']
|
lpreargs = ['-m64']
|
||||||
extra_compile_args = compiler_attrs.get('extra_compile_args', [])
|
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', [])
|
extra_link_args = compiler_attrs.get('extra_link_args', [])
|
||||||
if cc.compiler_type == 'msvc':
|
if cc.compiler_type == 'msvc':
|
||||||
extra_link_args += ['/MANIFEST']
|
extra_link_args += ['/MANIFEST']
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
#ifdef __GNUC__
|
#ifdef _MSC_VER
|
||||||
#if __clang__
|
#pragma comment(lib, "Ws2_32.lib")
|
||||||
#if __cplusplus >= 201103L && !__has_include(<initializer_list>)
|
#pragma comment(lib, "advapi32.lib")
|
||||||
#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
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "capnp/dynamic.h"
|
#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
|
# schema.capnp.cpp.pyx
|
||||||
# distutils: language = c++
|
# distutils: language = c++
|
||||||
# distutils: extra_compile_args = --std=c++14
|
|
||||||
cdef extern from "capnp/helpers/checkCompiler.h":
|
cdef extern from "capnp/helpers/checkCompiler.h":
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# schema.capnp.cpp.pyx
|
# schema.capnp.cpp.pyx
|
||||||
# distutils: language = c++
|
# distutils: language = c++
|
||||||
# distutils: extra_compile_args = --std=c++14
|
|
||||||
|
|
||||||
from libc.stdint cimport *
|
from libc.stdint cimport *
|
||||||
from capnp_cpp cimport DynamicOrphan
|
from capnp_cpp cimport DynamicOrphan
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# capnp.pyx
|
# capnp.pyx
|
||||||
# distutils: language = c++
|
# distutils: language = c++
|
||||||
# distutils: extra_compile_args = --std=c++14
|
|
||||||
# distutils: libraries = capnpc capnp-rpc capnp kj-async kj
|
# distutils: libraries = capnpc capnp-rpc capnp kj-async kj
|
||||||
# distutils: include_dirs = .
|
# distutils: include_dirs = .
|
||||||
# cython: c_string_type = str
|
# cython: c_string_type = str
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# addressbook_fast.pyx
|
# addressbook_fast.pyx
|
||||||
# distutils: language = c++
|
# distutils: language = c++
|
||||||
# distutils: extra_compile_args = --std=c++14
|
|
||||||
# distutils: include_dirs = {{include_dir}}
|
# distutils: include_dirs = {{include_dir}}
|
||||||
# distutils: libraries = capnpc capnp capnp-rpc
|
# distutils: libraries = capnpc capnp capnp-rpc
|
||||||
# distutils: sources = {{file.filename}}.cpp
|
# 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
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from distutils.command.clean import clean as _clean
|
from distutils.command.clean import clean as _clean
|
||||||
@@ -13,7 +14,7 @@ from distutils.errors import CompileError
|
|||||||
from distutils.extension import Extension
|
from distutils.extension import Extension
|
||||||
from distutils.spawn import find_executable
|
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
|
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")
|
bundle_dir = os.path.join(_this_dir, "bundled")
|
||||||
if not os.path.exists(bundle_dir):
|
if not os.path.exists(bundle_dir):
|
||||||
os.mkdir(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):
|
if not os.path.exists(build_dir):
|
||||||
os.mkdir(build_dir)
|
os.mkdir(build_dir)
|
||||||
|
|
||||||
@@ -159,10 +160,20 @@ class build_libcapnp_ext(build_ext_c):
|
|||||||
|
|
||||||
return build_ext_c.run(self)
|
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
|
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(
|
setup(
|
||||||
name="pycapnp-async",
|
name="pycapnp-async",
|
||||||
@@ -174,7 +185,7 @@ setup(
|
|||||||
'includes/*.pxd', 'lib/*.pxd', 'lib/*.py', 'lib/*.pyx', 'templates/*'
|
'includes/*.pxd', 'lib/*.pxd', 'lib/*.py', 'lib/*.pyx', 'templates/*'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ext_modules=extensions,
|
ext_modules=Cython.Build.cythonize(extensions),
|
||||||
cmdclass={
|
cmdclass={
|
||||||
'clean': clean,
|
'clean': clean,
|
||||||
'build_ext': build_libcapnp_ext
|
'build_ext': build_libcapnp_ext
|
||||||
|
|||||||
Reference in New Issue
Block a user