Skip to content

Commit

Permalink
Fixes for Cython support. 'python test_cython\runtests.py' succeeds.
Browse files Browse the repository at this point in the history
  • Loading branch information
casevh committed Dec 18, 2023
1 parent 5b3d66f commit 8a39f52
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
14 changes: 5 additions & 9 deletions mingw64/msys2_build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,22 @@ Visual Studio Steps

7. Compile Windows binary wheels

py -3.12 -m pip install --upgrade pip setuptools wheel pytest hypothesis build
py -3.12 -m pip install --upgrade pip setuptools wheel pytest hypothesis build cython mpmath
py -3.12 -m build --wheel
py -3.12 -m pip install dist\gmpy2-2.2.0a2-cp312-cp312-win_amd64.whl --force-reinstall

py -3.11 -m pip install --upgrade pip setuptools wheel pytest hypothesis build
py -3.11 -m pip install --upgrade pip setuptools wheel pytest hypothesis build cython mpmath
py -3.11 -m build --wheel
py -3.11 -m pip install dist\gmpy2-2.2.0a2-cp311-cp311-win_amd64.whl --force-reinstall

py -3.10 -m pip install --upgrade pip setuptools wheel pytest hypothesis build
py -3.10 -m pip install --upgrade pip setuptools wheel pytest hypothesis build cython mpmath
py -3.10 -m build --wheel
py -3.10 -m pip install dist\gmpy2-2.2.0a2-cp310-cp310-win_amd64.whl --force-reinstall

py -3.9 -m pip install --upgrade pip setuptools wheel pytest hypothesis build
py -3.9 -m pip install --upgrade pip setuptools wheel pytest hypothesis build cython mpmath
py -3.9 -m build --wheel
py -3.9 -m pip install dist\gmpy2-2.2.0a2-cp39-cp39-win_amd64.whl --force-reinstall

py -3.8 -m pip install --upgrade pip setuptools wheel pytest hypothesis build
py -3.8 -m pip install --upgrade pip setuptools wheel pytest hypothesis build cython mpmath
py -3.8 -m build --wheel
py -3.8 -m pip install dist\gmpy2-2.2.0a2-cp38-cp38-win_amd64.whl --force-reinstall

py -3.7 -m pip install --upgrade pip setuptools wheel pytest hypothesis build
py -3.7 -m build --wheel
py -3.7 -m pip install dist\gmpy2-2.2.0a2-cp37-cp37m-win_amd64.whl --force-reinstall
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def build_extensions(self):
extensions = [
Extension('gmpy2.gmpy2',
sources=sources,
include_dirs=['./src'] + (['gmpy2'] if ON_WINDOWS else []),
libraries=['mpc','mpfr','gmp'] + ([] if ON_WINDOWS else ['m']),
library_dirs=(['gmpy2'] if ON_WINDOWS else []),
include_dirs=['./src'] + (['./gmpy2'] if ON_WINDOWS else []),
libraries=['mpc','mpfr','gmp'] if ON_WINDOWS else ['mpc','mpfr','gmp','m'],
library_dirs=(['./gmpy2'] if ON_WINDOWS else []),
extra_compile_args=_comp_args,
)
]
Expand Down
2 changes: 1 addition & 1 deletion test_cython/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
raise SystemExit('compilation failed')


if subprocess.call([sys.executable, '-c', 'import test_cython; test_cython.run()']):
if subprocess.call([sys.executable, '-c', 'import gmpy2; import test_cython; test_cython.run()']):
raise SystemExit('cython test failed')

finally:
Expand Down
11 changes: 9 additions & 2 deletions test_cython/setup_cython.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from setuptools import Extension, setup
from Cython.Build import cythonize
import platform
import sys
import os
import gmpy2

ON_WINDOWS = platform.system() == 'Windows'

extensions = [
Extension("test_cython", ["test_cython.pyx"],
include_dirs=sys.path,
)
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']
)
]

setup(
Expand Down

0 comments on commit 8a39f52

Please sign in to comment.