From a12ca087d3b2e88402238b0897f21b726f6108f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Sat, 19 Dec 2020 17:44:12 +0100 Subject: [PATCH] more unit tests --- .travis.yml | 43 +++++++++++++++++++++++++++++++++++----- README.md | 10 ++++++++-- snakehouse/multibuild.py | 8 +++++--- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f1c66d..e916385 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,48 @@ python: - "3.7" - "3.8" - "nightly" +jobs: + include: + - stage: test + python: "3.5" + env: + - DEBUG=1 + script: + - cd example + - python setup.py test + - stage: test + python: "3.6" + env: + - DEBUG=1 + script: + - cd example + - python setup.py test + - stage: test + python: "3.7" + env: + - DEBUG=1 + script: + - cd example + - python setup.py test + - stage: test + python: "3.8" + env: + - DEBUG=1 + script: + - cd example + - python setup.py test + - stage: test + python: "nightly" + env: + - DEBUG=1 + script: + - cd example + - python setup.py test cache: pip -script: - - cd example - - python setup.py test install: - pip install -r requirements.txt - python setup.py install after_success: - cd .. - bash build.sh -env: - - DEBUG=true + diff --git a/README.md b/README.md index 60ec442..d8ad23f 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,17 @@ a part of your pull request as well! Note what have you changed in [CHANGELOG.md](/CHANGELOG.md) as well! -Usage ------ +Usage notes +----------- Take a look at [example](example/) on how to multi-build your Cython extensions. Don't place modules compiled that way in root .py file's top level imports. Wrap them in a layer of indirection instead! This applies to unit tests as well! + +When something goes wrong (eg. the application throws an unhandled exception) +the built module has a tendency to dump core. +Try to debug it first by passing `dont_snakehouse=True` to your +modules in the debug mode. + diff --git a/snakehouse/multibuild.py b/snakehouse/multibuild.py index 7a1137a..5ef09af 100644 --- a/snakehouse/multibuild.py +++ b/snakehouse/multibuild.py @@ -56,7 +56,7 @@ class Multibuild: as a separate extension. It is for these cases when you're testing and something segfaults. """ def __init__(self, extension_name: str, files: tp.Iterator[str], - dont_snakehouse: bool = False,**kwargs): + dont_snakehouse: bool = False, **kwargs): # sanitize path separators so that Linux-style paths are supported on Windows files = list(files) self.dont_snakehouse = dont_snakehouse @@ -202,9 +202,11 @@ class Multibuild: def for_cythonize(self, *args, **kwargs): if self.dont_snakehouse: extensions = [] + common_path = os.path.commonpath(self.pyx_files) for pyx_file in self.pyx_files: - ext = Extension(pyx_file.replace(os.pathsep, '.')[:-4], - [pyx_file]) + file_name = pyx_file[len(common_path)+len(os.pathsep):-4] + ext = Extension(file_name.replace(os.pathsep, '.'), + [file_name]) extensions.append(ext) return extensions else: -- GitLab