Skip to content
forked from aleaxit/gmpy

Commit

Permalink
Run Cython tests for binary wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Dec 21, 2023
1 parent 8a39f52 commit 6977c03
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ jobs:
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_SKIP: pp*
CIBW_BEFORE_BUILD: bash scripts/before_ci_build.sh
CIBW_BEFORE_BUILD: bash scripts/before_ci_build.sh {package}
CIBW_TEST_EXTRAS: tests
CIBW_TEST_COMMAND: pytest {package}/test/
CIBW_TEST_COMMAND_LINUX: >
pytest {package}/test/ &&
python {package}/test_cython/runtests.py
- uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions scripts/before_ci_build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

set -e -x

GMP_VERSION=6.3.0
MPFR_VERSION=4.2.1
MPC_VERSION=1.3.1
PACKAGE=$1
if [ ! -f finish_before_ci_build ]; then
if [[ "$OSTYPE" == "linux-gnu" || "$OSTYPE" == "linux-musl" || "$OSTYPE" == "darwin"* ]]; then
curl -s -O https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VERSION}.tar.xz
Expand All @@ -19,6 +22,7 @@ if [ ! -f finish_before_ci_build ]; then
curl -s -O https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VERSION}.tar.gz
tar -xf mpc-${MPC_VERSION}.tar.gz
cd mpc-${MPC_VERSION} && ./configure && make -j4 && make install && cd ../
cp /usr/local/include/{gmp,mpfr,mpc}.h $PACKAGE/gmpy2/
fi
touch finish_before_ci_build
else
Expand Down
21 changes: 14 additions & 7 deletions test_cython/setup_cython.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
from setuptools import Extension, setup
from Cython.Build import cythonize
import platform
import sys
import os
import platform
import gmpy2

ON_WINDOWS = platform.system() == 'Windows'
gmpy2_packagedir = os.path.dirname(gmpy2.__file__)
library_dirs = sys.path + [gmpy2_packagedir]
libnames = ['mpc','mpfr','gmp']

if platform.system() == 'Linux':
bundled_libs = gmpy2_packagedir+'/../gmpy2.libs/'
if os.path.isdir(bundled_libs):
library_dirs += [bundled_libs]
libnames = [':' + d for d in os.listdir(bundled_libs)]


extensions = [
Extension("test_cython", ["test_cython.pyx"],
include_dirs=sys.path + ([os.path.dirname(gmpy2.__file__)] if ON_WINDOWS else []),
library_dirs=sys.path + ([os.path.dirname(gmpy2.__file__)] if ON_WINDOWS else []),
libraries=['mpc','mpfr','gmp']
)
]
include_dirs=sys.path + [gmpy2_packagedir],
library_dirs=library_dirs,
libraries=libnames)]

setup(
name="cython_gmpy_test",
Expand Down
1 change: 0 additions & 1 deletion test_cython/test_cython.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# distutils: libraries = gmp mpfr mpc
from gmpy2 cimport *

import_gmpy2()
Expand Down

0 comments on commit 6977c03

Please sign in to comment.