Blob Blame History Raw
#!/bin/sh -eux

# TODO set this from outside depending on the package

# clean from possible older runs
rm -rf venv .tox __pycache__ .pytest* test_*.py *.pyx *.c *.so || :

# check the we can create the venv
$PYTHON -m venv venv

# and activate it
source venv/bin/activate

# run python in it
python -c 'import sys; print(sys.version)' | head -n1 | grep $VERSION

# install packages with pip
python -m pip install pytest

# run tests
cat > << EOF
def test_foo():
    assert True

python -m pytest -v

# check that we can do extension modules
cat > module.pyx << EOF
cdef int add(int a, int b):
    return a + b

def two():
    cdef int a = 1
    cdef int b = 1
    return add(a, b)

cat > << EOF
from setuptools import setup
from Cython.Build import cythonize

setup(ext_modules = cythonize('module.pyx'))

python -m pip install Cython
python build_ext --inplace

python -c 'import module; print(module.two())' | grep '^2$'

# deactivate has unset variable, it's known
set +u
set -u

# use it with tox
cat > tox.ini << EOF
skipsdist = True
deps = pytest
commands = python -m pytest -v

tox -e py${VERSION/./}