From 30603904a9b043f2b1fd53bb3b585649173e4b61 Mon Sep 17 00:00:00 2001 From: mattip Date: Fri, 11 Oct 2024 10:36:19 +0300 Subject: [PATCH 01/14] rename possibly identical modules to prevent test collisions --- testing/cffi0/test_verify.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index 4942bba6..9f3b6055 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -1,6 +1,6 @@ import re import pytest -import sys, os, math, weakref +import sys, os, math, weakref, random from cffi import FFI, VerificationError, VerificationMissing, model, FFIError from testing.support import * from testing.support import extra_compile_args, is_musl @@ -18,9 +18,19 @@ if distutils.ccompiler.get_default_compiler() == 'msvc': lib_m = ['msvcrt'] pass # no obvious -Werror equivalent on MSVC + class FFI(FFI): + def verify(self, *args, **kwds): + modulename = kwds.get("modulename", "_cffi_test%d_%d" % ( + random.randint(0,32000), random.randint(0,32000))) + kwds["modulename"] = modulename + return super(FFI, self).verify(*args, **kwds) + else: class FFI(FFI): def verify(self, *args, **kwds): + modulename = kwds.get("modulename", "_cffi_test%d_%d" % ( + random.randint(0,32000), random.randint(0,32000))) + kwds["modulename"] = modulename return super(FFI, self).verify( *args, extra_compile_args=extra_compile_args, **kwds) From 14c4b9ed10c336f51b815498b5a7b3831de89a5b Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Fri, 11 Oct 2024 11:35:54 +0300 Subject: [PATCH 02/14] changes from review, fix test --- testing/cffi0/test_verify.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index 9f3b6055..2a39eeba 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -21,7 +21,7 @@ class FFI(FFI): def verify(self, *args, **kwds): modulename = kwds.get("modulename", "_cffi_test%d_%d" % ( - random.randint(0,32000), random.randint(0,32000))) + random.randint(0,1000000000), random.randint(0,1000000000))) kwds["modulename"] = modulename return super(FFI, self).verify(*args, **kwds) @@ -29,7 +29,7 @@ def verify(self, *args, **kwds): class FFI(FFI): def verify(self, *args, **kwds): modulename = kwds.get("modulename", "_cffi_test%d_%d" % ( - random.randint(0,32000), random.randint(0,32000))) + random.randint(0,1000000000), random.randint(0,1000000000))) kwds["modulename"] = modulename return super(FFI, self).verify( *args, extra_compile_args=extra_compile_args, **kwds) @@ -2175,7 +2175,8 @@ def test_verify_dlopen_flags(): ffi1.cdef("extern int foo_verify_dlopen_flags;") lib1 = ffi1.verify("int foo_verify_dlopen_flags;", - flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY) + flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY, + modulename="test_verify_dlopen_flags") lib2 = get_second_lib() lib1.foo_verify_dlopen_flags = 42 @@ -2188,7 +2189,8 @@ def get_second_lib(): ffi2 = FFI() ffi2.cdef("extern int foo_verify_dlopen_flags;") lib2 = ffi2.verify("int foo_verify_dlopen_flags;", - flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY) + flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY, + modulename="test_verify_dlopen_flags") return lib2 def test_consider_not_implemented_function_type(): From da6380039b9d7965aa0ecf30bc8630d2a835649a Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Fri, 11 Oct 2024 11:36:57 +0300 Subject: [PATCH 03/14] remove comment --- testing/cffi0/test_verify.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index 2a39eeba..86fa4484 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -2185,7 +2185,6 @@ def test_verify_dlopen_flags(): assert lib1.foo_verify_dlopen_flags == 43 def get_second_lib(): - # Hack, using modulename makes the test fail ffi2 = FFI() ffi2.cdef("extern int foo_verify_dlopen_flags;") lib2 = ffi2.verify("int foo_verify_dlopen_flags;", From 933fd2ca4fa0fce9051de4f330306c90a16c63cd Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Fri, 11 Oct 2024 12:04:11 +0300 Subject: [PATCH 04/14] ensure files are removed by 'cffi.verifier.cleanup_tmpdir()' --- testing/cffi0/test_verify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index 86fa4484..b7710932 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -2176,7 +2176,7 @@ def test_verify_dlopen_flags(): lib1 = ffi1.verify("int foo_verify_dlopen_flags;", flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY, - modulename="test_verify_dlopen_flags") + modulename="_cffi_test_verify_dlopen_flags") lib2 = get_second_lib() lib1.foo_verify_dlopen_flags = 42 @@ -2189,7 +2189,7 @@ def get_second_lib(): ffi2.cdef("extern int foo_verify_dlopen_flags;") lib2 = ffi2.verify("int foo_verify_dlopen_flags;", flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY, - modulename="test_verify_dlopen_flags") + modulename="_cffi_test_verify_dlopen_flags") return lib2 def test_consider_not_implemented_function_type(): From f2f0913a0710f68c646a41b9611ad59f1280c119 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Fri, 11 Oct 2024 12:30:25 +0300 Subject: [PATCH 05/14] randomize modulename --- testing/cffi0/test_verify.py | 11 ++++++----- testing/cffi0/test_vgen2.py | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index b7710932..a6ca23cd 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -2174,22 +2174,23 @@ def test_verify_dlopen_flags(): ffi1 = FFI() ffi1.cdef("extern int foo_verify_dlopen_flags;") + modulename = "_cffi_test_verify_dlopen_flags_%d" % random.randint(0, 1000000000) lib1 = ffi1.verify("int foo_verify_dlopen_flags;", flags=ffi1.RTLD_GLOBAL | ffi1.RTLD_LAZY, - modulename="_cffi_test_verify_dlopen_flags") - lib2 = get_second_lib() + modulename=modulename) + lib2 = get_second_lib(modulename) lib1.foo_verify_dlopen_flags = 42 assert lib2.foo_verify_dlopen_flags == 42 lib2.foo_verify_dlopen_flags += 1 assert lib1.foo_verify_dlopen_flags == 43 -def get_second_lib(): +def get_second_lib(modulename): ffi2 = FFI() ffi2.cdef("extern int foo_verify_dlopen_flags;") lib2 = ffi2.verify("int foo_verify_dlopen_flags;", flags=ffi2.RTLD_GLOBAL | ffi2.RTLD_LAZY, - modulename="_cffi_test_verify_dlopen_flags") + modulename=modulename) return lib2 def test_consider_not_implemented_function_type(): @@ -2257,7 +2258,7 @@ def test_implicit_unicode_on_windows(): def test_use_local_dir(): ffi = FFI() - lib = ffi.verify("", modulename="test_use_local_dir") + lib = ffi.verify("", modulename="_cffi_test_use_local_dir") this_dir = os.path.dirname(__file__) pycache_files = os.listdir(os.path.join(this_dir, '__pycache__')) assert any('test_use_local_dir' in s for s in pycache_files) diff --git a/testing/cffi0/test_vgen2.py b/testing/cffi0/test_vgen2.py index 34147c87..2cd1634c 100644 --- a/testing/cffi0/test_vgen2.py +++ b/testing/cffi0/test_vgen2.py @@ -3,7 +3,8 @@ # This test file runs normally after test_vgen. We only clean up the .c # sources, to check that it also works when we have only the .so. The -# tests should run much faster than test_vgen. +# tests used to run much faster than test_vgen, but since we randomize +# the module names, it needs to recompile everything. def setup_module(): cffi.verifier.cleanup_tmpdir(keep_so=True) From ed30b464a9443b79587a2cd7408c2041b41e1da9 Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 13 Oct 2024 15:51:53 +0300 Subject: [PATCH 06/14] make verifier more thread-safe, refactor verifier tests --- src/cffi/verifier.py | 28 ++++++++++++++++++--------- testing/cffi0/test_verify.py | 36 ++++++++++++++++++++++------------- testing/cffi0/test_verify2.py | 13 ------------- testing/cffi0/test_vgen.py | 5 ++--- testing/cffi0/test_vgen2.py | 14 -------------- 5 files changed, 44 insertions(+), 52 deletions(-) delete mode 100644 testing/cffi0/test_verify2.py delete mode 100644 testing/cffi0/test_vgen2.py diff --git a/src/cffi/verifier.py b/src/cffi/verifier.py index e392a2b7..9b41deca 100644 --- a/src/cffi/verifier.py +++ b/src/cffi/verifier.py @@ -1,7 +1,7 @@ # # DEPRECATED: implementation for ffi.verify() # -import sys, os, binascii, shutil, io +import sys, os, binascii, shutil, io, threading from . import __version_verifier_modules__ from . import ffiplatform from .error import VerificationError @@ -197,8 +197,18 @@ def _write_source(self, file=None): def _compile_module(self): # compile this C source + # Note: compilation will create artifacts in tmpdir + sourcefilename + # This can exceed the windows MAXPATH quite easily. To make it shorter, + # cd into tmpdir and make the sourcefilename relative to tmdir tmpdir = os.path.dirname(self.sourcefilename) - outputfilename = ffiplatform.compile(tmpdir, self.get_extension()) + olddir = os.getcwd() + os.chdir(tmpdir) + try: + self.sourcefilename = os.path.relpath(self.sourcefilename) + output_rel_filename = ffiplatform.compile(tmpdir, self.get_extension()) + outputfilename = os.path.join(tmpdir, output_rel_filename) + finally: + os.chdir(olddir) try: same = ffiplatform.samefile(outputfilename, self.modulefilename) except OSError: @@ -215,12 +225,13 @@ def _load_library(self): else: return self._vengine.load_library() +local = threading.local() # ____________________________________________________________ -_FORCE_GENERIC_ENGINE = False # for tests +local._FORCE_GENERIC_ENGINE = False # for tests def _locate_engine_class(ffi, force_generic_engine): - if _FORCE_GENERIC_ENGINE: + if local._FORCE_GENERIC_ENGINE: force_generic_engine = True if not force_generic_engine: if '__pypy__' in sys.builtin_module_names: @@ -241,11 +252,11 @@ def _locate_engine_class(ffi, force_generic_engine): # ____________________________________________________________ -_TMPDIR = None +local._TMPDIR = None def _caller_dir_pycache(): - if _TMPDIR: - return _TMPDIR + if local._TMPDIR: + return local._TMPDIR result = os.environ.get('CFFI_TMPDIR') if result: return result @@ -255,8 +266,7 @@ def _caller_dir_pycache(): def set_tmpdir(dirname): """Set the temporary directory to use instead of __pycache__.""" - global _TMPDIR - _TMPDIR = dirname + local._TMPDIR = dirname def cleanup_tmpdir(tmpdir=None, keep_so=False): """Clean up the temporary directory by removing all files in it diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index a6ca23cd..20b20cbe 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -36,7 +36,6 @@ def verify(self, *args, **kwds): def setup_module(): import cffi.verifier - cffi.verifier.cleanup_tmpdir() # # check that no $ sign is produced in the C file; it used to be the # case that anonymous enums would produce '$enum_$1', which was @@ -62,10 +61,12 @@ def test_module_type(): ffi = FFI() lib = ffi.verify() if hasattr(lib, '_cffi_python_module'): - print('verify got a PYTHON module') + pass + # print('verify got a PYTHON module') if hasattr(lib, '_cffi_generic_module'): - print('verify got a GENERIC module') - expected_generic = (cffi.verifier._FORCE_GENERIC_ENGINE or + pass + # print('verify got a GENERIC module') + expected_generic = (cffi.verifier.local._FORCE_GENERIC_ENGINE or '__pypy__' in sys.builtin_module_names) assert hasattr(lib, '_cffi_python_module') == (not expected_generic) assert hasattr(lib, '_cffi_generic_module') == expected_generic @@ -136,7 +137,7 @@ def test_Wconversion_double2int(): _Wconversion("int sin(double);", "#include ", libraries=lib_m) -def test_rounding_1(): +def test_rounding(): ffi = FFI() ffi.cdef("double sinf(float x);") lib = ffi.verify('#include ', libraries=lib_m) @@ -144,14 +145,6 @@ def test_rounding_1(): assert res != math.sin(1.23) # not exact, because of double->float assert abs(res - math.sin(1.23)) < 1E-5 -def test_rounding_2(): - ffi = FFI() - ffi.cdef("double sin(float x);") - lib = ffi.verify('#include ', libraries=lib_m) - res = lib.sin(1.23) - assert res != math.sin(1.23) # not exact, because of double->float - assert abs(res - math.sin(1.23)) < 1E-5 - def test_strlen_exact(): ffi = FFI() ffi.cdef("size_t strlen(const char *s);") @@ -2597,3 +2590,20 @@ def test_passing_large_list(): arg = list(range(20000000)) lib.passing_large_list(arg) # assert did not segfault + +def test_no_regen(): + from cffi.verifier import Verifier, _caller_dir_pycache + import os + ffi = FFI() + modulename = "_cffi_test_no_regen" + ffi.cdef("double sin(double x);") + lib = ffi.verify('#include ', libraries=lib_m, modulename=modulename) + assert lib.sin(1.23) == math.sin(1.23) + # Make sure that recompiling the same code does not rebuild the C file + cfile = os.path.join(ffi.verifier.tmpdir, f"{modulename}.c") + assert os.path.exists(cfile) + os.unlink(cfile) + assert not os.path.exists(cfile) + lib = ffi.verify('#include ', libraries=lib_m, modulename=modulename) + assert lib.sin(1.23) == math.sin(1.23) + assert not os.path.exists(cfile) diff --git a/testing/cffi0/test_verify2.py b/testing/cffi0/test_verify2.py deleted file mode 100644 index 25f1e3f5..00000000 --- a/testing/cffi0/test_verify2.py +++ /dev/null @@ -1,13 +0,0 @@ -import pytest -from .test_verify import * - -# eliminate warning noise from common test modules that are repeatedly re-imported -pytestmark = pytest.mark.filterwarnings("ignore:reimporting:UserWarning") - -# This test file runs normally after test_verify. We only clean up the .c -# sources, to check that it also works when we have only the .so. The -# tests should run much faster than test_verify. - -def setup_module(): - import cffi.verifier - cffi.verifier.cleanup_tmpdir(keep_so=True) diff --git a/testing/cffi0/test_vgen.py b/testing/cffi0/test_vgen.py index 1a7e05db..5f3104bb 100644 --- a/testing/cffi0/test_vgen.py +++ b/testing/cffi0/test_vgen.py @@ -3,10 +3,9 @@ def setup_module(): - cffi.verifier.cleanup_tmpdir() - cffi.verifier._FORCE_GENERIC_ENGINE = True + cffi.verifier.local._FORCE_GENERIC_ENGINE = True # Runs all tests with _FORCE_GENERIC_ENGINE = True, to make sure we # also test vengine_gen.py. def teardown_module(): - cffi.verifier._FORCE_GENERIC_ENGINE = False + cffi.verifier.local._FORCE_GENERIC_ENGINE = False diff --git a/testing/cffi0/test_vgen2.py b/testing/cffi0/test_vgen2.py deleted file mode 100644 index 2cd1634c..00000000 --- a/testing/cffi0/test_vgen2.py +++ /dev/null @@ -1,14 +0,0 @@ -import cffi.verifier -from .test_vgen import * - -# This test file runs normally after test_vgen. We only clean up the .c -# sources, to check that it also works when we have only the .so. The -# tests used to run much faster than test_vgen, but since we randomize -# the module names, it needs to recompile everything. - -def setup_module(): - cffi.verifier.cleanup_tmpdir(keep_so=True) - cffi.verifier._FORCE_GENERIC_ENGINE = True - -def teardown_module(): - cffi.verifier._FORCE_GENERIC_ENGINE = False From 1b89cefbbaa1adba8ebf4483ccae2a809d41864e Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 13 Oct 2024 18:40:06 +0300 Subject: [PATCH 07/14] restore veririfer.sourcefilename, make test_parse_c_tpye tests work with xdist, touch up documentation --- .github/workflows/ci.yaml | 15 ++++++++------- doc/source/installation.rst | 6 +++--- src/cffi/verifier.py | 2 ++ testing/cffi0/test_verify.py | 2 +- testing/cffi1/test_parse_c_type.py | 24 ++++++++++++++++-------- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6dca8cb9..28da8af0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -298,8 +298,10 @@ jobs: CIBW_MUSLLINUX_AARCH64_IMAGE: ${{ matrix.musllinux_img || 'musllinux_1_1' }} CIBW_PRERELEASE_PYTHONS: 'True' CIBW_FREE_THREADED_SUPPORT: 'True' - CIBW_TEST_REQUIRES: pytest setuptools # 3.12+ no longer includes distutils, just always ensure setuptools is present - CIBW_TEST_COMMAND: PYTHONUNBUFFERED=1 python -m pytest ${{ matrix.test_args || '{project}' }} # default to test all + # 3.12+ no longer includes distutils, just always ensure setuptools is present + CIBW_TEST_REQUIRES: pytest setuptools pytest-xdist filelock + # default to test all + CIBW_TEST_COMMAND: PYTHONUNBUFFERED=1 python -m pytest ${{ matrix.test_args || '{project}' }} -n 4 run: | set -eux @@ -417,8 +419,8 @@ jobs: env: CIBW_BUILD: ${{ matrix.spec }} CIBW_PRERELEASE_PYTHONS: 'True' - CIBW_TEST_REQUIRES: pytest setuptools - CIBW_TEST_COMMAND: pip install pip --upgrade; cd {project}; PYTHONUNBUFFERED=1 pytest + CIBW_TEST_REQUIRES: pytest setuptools pytest-xdist filelock + CIBW_TEST_COMMAND: pip install pip --upgrade; cd {project}; PYTHONUNBUFFERED=1 pytest -n 4 MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target || '10.9' }} SDKROOT: ${{ matrix.sdkroot || 'macosx' }} run: | @@ -508,10 +510,9 @@ jobs: env: CIBW_BUILD: ${{ matrix.spec }} CIBW_PRERELEASE_PYTHONS: 'True' - CIBW_TEST_REQUIRES: pytest setuptools + CIBW_TEST_REQUIRES: pytest setuptools pytest-xdist filelock CIBW_TEST_COMMAND: 'python -m pytest {package}/src/c' - # FIXME: /testing takes ~45min on Windows and has some failures... - # CIBW_TEST_COMMAND='python -m pytest {package}/src/c {project}/testing' + CIBW_TEST_COMMAND='python -m pytest {package}/src/c {project}/testing -n 4' run: | set -eux diff --git a/doc/source/installation.rst b/doc/source/installation.rst index 8e69b827..647a9049 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -42,9 +42,10 @@ Requirements: * pycparser >= 2.06: https://github.com/eliben/pycparser (automatically tracked by ``pip install cffi``). -* `pytest`_ is needed to run the tests of CFFI itself. +* `pytest`_ and `filelock` are needed to run the tests of CFFI itself. .. _`pytest`: http://pypi.python.org/pypi/pytest +.. _`filelock`: http://pypi.python.org/pypi/filelock Download and Installation: @@ -54,8 +55,7 @@ Download and Installation: ``git clone https://github.com/python-cffi/cffi`` * running the tests: ``pytest c/ testing/`` (if you didn't - install cffi yet, you need first ``python setup_base.py build_ext -f - -i``) + install cffi yet, you need first ``python -m pip install -e .``) .. _`GitHub`: https://github.com/python-cffi/cffi diff --git a/src/cffi/verifier.py b/src/cffi/verifier.py index 9b41deca..cffbe052 100644 --- a/src/cffi/verifier.py +++ b/src/cffi/verifier.py @@ -203,12 +203,14 @@ def _compile_module(self): tmpdir = os.path.dirname(self.sourcefilename) olddir = os.getcwd() os.chdir(tmpdir) + self.sourcefilename_orig = self.sourcefilename try: self.sourcefilename = os.path.relpath(self.sourcefilename) output_rel_filename = ffiplatform.compile(tmpdir, self.get_extension()) outputfilename = os.path.join(tmpdir, output_rel_filename) finally: os.chdir(olddir) + self.sourcefilename = self.sourcefilename_orig try: same = ffiplatform.samefile(outputfilename, self.modulefilename) except OSError: diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index 20b20cbe..570d8668 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -2595,7 +2595,7 @@ def test_no_regen(): from cffi.verifier import Verifier, _caller_dir_pycache import os ffi = FFI() - modulename = "_cffi_test_no_regen" + modulename = "_cffi_test_no_regen_%d" % random.randint(0, 1000000000) ffi.cdef("double sin(double x);") lib = ffi.verify('#include ', libraries=lib_m, modulename=modulename) assert lib.sin(1.23) == math.sin(1.23) diff --git a/testing/cffi1/test_parse_c_type.py b/testing/cffi1/test_parse_c_type.py index 49a31d54..f20ae352 100644 --- a/testing/cffi1/test_parse_c_type.py +++ b/testing/cffi1/test_parse_c_type.py @@ -2,6 +2,7 @@ import pytest import cffi from cffi import cffi_opcode +from filelock import FileLock from pathlib import Path if '__pypy__' in sys.builtin_module_names: @@ -26,14 +27,21 @@ ffi = cffi.FFI() ffi.cdef(header) -with open(os.path.join(cffi_dir, '..', 'c', 'parse_c_type.c')) as _body: - body = _body.read() -lib = ffi.verify( - body + """ -static const char *get_common_type(const char *search, size_t search_len) { - return NULL; -} -""", include_dirs=[cffi_dir]) + +def build_lib(): + sourcename = os.path.join(cffi_dir, '..', 'c', 'parse_c_type.c') + with FileLock(sourcename + ".lock"): + with open(sourcename) as _body: + body = _body.read() + lib = ffi.verify( + body + """ + static const char *get_common_type(const char *search, size_t search_len) { + return NULL; + } + """, include_dirs=[cffi_dir]) + return lib + +lib = build_lib() class ParseError(Exception): pass From 3a8960525a6e0abb726a12460c56da267f2dcaf5 Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 13 Oct 2024 20:49:12 +0300 Subject: [PATCH 08/14] typo --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 28da8af0..969ae481 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -512,7 +512,7 @@ jobs: CIBW_PRERELEASE_PYTHONS: 'True' CIBW_TEST_REQUIRES: pytest setuptools pytest-xdist filelock CIBW_TEST_COMMAND: 'python -m pytest {package}/src/c' - CIBW_TEST_COMMAND='python -m pytest {package}/src/c {project}/testing -n 4' + CIBW_TEST_COMMAND: 'python -m pytest {package}/src/c {project}/testing -n 4' run: | set -eux From 9c2260e87ec52de804357c9b9a6da3fead659904 Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 13 Oct 2024 20:49:57 +0300 Subject: [PATCH 09/14] typo --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 969ae481..9dbef5d9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -511,7 +511,6 @@ jobs: CIBW_BUILD: ${{ matrix.spec }} CIBW_PRERELEASE_PYTHONS: 'True' CIBW_TEST_REQUIRES: pytest setuptools pytest-xdist filelock - CIBW_TEST_COMMAND: 'python -m pytest {package}/src/c' CIBW_TEST_COMMAND: 'python -m pytest {package}/src/c {project}/testing -n 4' run: | set -eux From a41dadc25b2ac910e90231b5d7f8339ca7e1047c Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 13 Oct 2024 21:54:46 +0300 Subject: [PATCH 10/14] fix CIBW_TEST_COMMAND --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9dbef5d9..37f4e1e0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -511,7 +511,7 @@ jobs: CIBW_BUILD: ${{ matrix.spec }} CIBW_PRERELEASE_PYTHONS: 'True' CIBW_TEST_REQUIRES: pytest setuptools pytest-xdist filelock - CIBW_TEST_COMMAND: 'python -m pytest {package}/src/c {project}/testing -n 4' + CIBW_TEST_COMMAND: 'python -m pytest {package} -n 4' run: | set -eux From 17f1457c4b2736d5e80a9b044f1f84afc2c74f2f Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 13 Oct 2024 22:52:00 +0300 Subject: [PATCH 11/14] follow up for PR #119: remove more msvccompiler --- testing/cffi0/test_ownlib.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/testing/cffi0/test_ownlib.py b/testing/cffi0/test_ownlib.py index e1a61d67..b414510e 100644 --- a/testing/cffi0/test_ownlib.py +++ b/testing/cffi0/test_ownlib.py @@ -141,10 +141,15 @@ def setup_class(cls): return # try (not too hard) to find the version used to compile this python # no mingw - from distutils.msvc9compiler import get_build_version - version = get_build_version() - toolskey = "VS%0.f0COMNTOOLS" % version - toolsdir = os.environ.get(toolskey, None) + toolsdir = None + try: + # This will always fail on setuptools>73 which removes msvc9compiler + from distutils.msvc9compiler import get_build_version + version = get_build_version() + toolskey = "VS%0.f0COMNTOOLS" % version + toolsdir = os.environ.get(toolskey, None) + except Exception: + pass if toolsdir is None: return productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC") From 79ae6556d774c376bc998e613aaf7e6b7c50c6f3 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Sun, 13 Oct 2024 23:29:45 +0300 Subject: [PATCH 12/14] skip embedded tests on windows --- testing/embedding/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testing/embedding/__init__.py b/testing/embedding/__init__.py index e69de29b..39ac8cc4 100644 --- a/testing/embedding/__init__.py +++ b/testing/embedding/__init__.py @@ -0,0 +1,5 @@ +import sys +import pytest + +if sys.platform == "win32": + pytest.skip("XXX fixme", allow_module_level=True) From dc47ef077c4bffdfbf8a7dabfeaada9128b96505 Mon Sep 17 00:00:00 2001 From: mattip Date: Sun, 13 Oct 2024 23:54:27 +0300 Subject: [PATCH 13/14] disambiguate modulename --- testing/cffi0/test_zdistutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/cffi0/test_zdistutils.py b/testing/cffi0/test_zdistutils.py index 08c432c7..75edcda8 100644 --- a/testing/cffi0/test_zdistutils.py +++ b/testing/cffi0/test_zdistutils.py @@ -90,7 +90,7 @@ def test_compile_module_explicit_filename(self): csrc = '/*hi there %s!2*/\n#include \n' % self v = Verifier(ffi, csrc, force_generic_engine=self.generic, libraries=[self.lib_m]) - basename = self.__class__.__name__[:10] + '_test_compile_module' + basename = self.__class__.__name__[:20] + '_test_compile_module' v.modulefilename = filename = str(udir.join(basename + '.so')) v.compile_module() assert filename == v.modulefilename From 88f56f4a9580ce8f8f725f8db3c8b3a6e839722f Mon Sep 17 00:00:00 2001 From: mattip Date: Mon, 14 Oct 2024 10:00:14 +0300 Subject: [PATCH 14/14] restore test --- testing/cffi0/test_verify.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/testing/cffi0/test_verify.py b/testing/cffi0/test_verify.py index 570d8668..9ddeac5c 100644 --- a/testing/cffi0/test_verify.py +++ b/testing/cffi0/test_verify.py @@ -137,7 +137,7 @@ def test_Wconversion_double2int(): _Wconversion("int sin(double);", "#include ", libraries=lib_m) -def test_rounding(): +def test_rounding_1(): ffi = FFI() ffi.cdef("double sinf(float x);") lib = ffi.verify('#include ', libraries=lib_m) @@ -145,6 +145,14 @@ def test_rounding(): assert res != math.sin(1.23) # not exact, because of double->float assert abs(res - math.sin(1.23)) < 1E-5 +def test_rounding_2(): + ffi = FFI() + ffi.cdef("double sin(float x);") + lib = ffi.verify('#include ', libraries=lib_m) + res = lib.sin(1.23) + assert res != math.sin(1.23) # not exact, because of double->float + assert abs(res - math.sin(1.23)) < 1E-5 + def test_strlen_exact(): ffi = FFI() ffi.cdef("size_t strlen(const char *s);")