Skip to content

Compatibility with Python 3.14 #123

@avalentino

Description

@avalentino

Apparently, compyle seems to be incompatible with Python 3.14, in particular with the changes in the ast module.

See also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1123107

The test suite produces the following errors:

python3.14 -m pytest -k "not test_that_multiple_compiles_do_not_occur_for_same_source and not test_const_as_call_arg and not test_const_in_return" --ignore=/<<PKGBUILDDIR>>/compyle/tests/test_cuda.py --ignore=/<<PKGBUILDDIR>>/compyle/tests/test_parallel.py /<<PKGBUILDDIR>>/compyle/tests
============================= test session starts ==============================
platform linux -- Python 3.14.2, pytest-9.0.2, pluggy-1.6.0
rootdir: /<<PKGBUILDDIR>>
configfile: pyproject.toml
plugins: typeguard-4.4.4
collected 338 items / 3 deselected / 335 selected

../../../compyle/tests/test_array.py ..s..s..s..s..s..s..s.Fs..sFFs..s.. [ 10%]
s..sF.sFF.s.sx..s..s..s.Fs.Fs.Fs.Fs..s..s..s..s..s..s..s..s..s..s..s..s. [ 31%]
.s..s..s..s..s..s..ss..s......sss......sss...FFFsss..s                   [ 48%]
../../../compyle/tests/test_ast_utils.py .......                         [ 50%]
../../../compyle/tests/test_capture_stream.py .....                      [ 51%]
../../../compyle/tests/test_change_backend.py ........                   [ 54%]
../../../compyle/tests/test_config.py ............                       [ 57%]
../../../compyle/tests/test_cython_generator.py .......F.F.F.F....       [ 62%]
../../../compyle/tests/test_ext_module.py .........                      [ 65%]
../../../compyle/tests/test_gpu_struct.py s                              [ 65%]
../../../compyle/tests/test_jit.py ........F.F............FF.            [ 73%]
../../../compyle/tests/test_low_level.py sFsFFF..                        [ 76%]
../../../compyle/tests/test_profile.py .....                             [ 77%]
../../../compyle/tests/test_template.py FFFF.                            [ 79%]
../../../compyle/tests/test_translator.py .FFFFFFFF.FFF.F...FFFF..FFFFFF [ 88%]
FFFF...FFFFF...FF...FF...F                                               [ 95%]
../../../compyle/tests/test_transpiler.py ...                            [ 96%]
../../../compyle/tests/test_types.py .......                             [ 98%]
../../../compyle/tests/test_utils.py ....                                [100%]

=================================== FAILURES ===================================

[...]

_________________________ test_align_multiple[opencl] __________________________

args = ([<compyle.array.Array object at 0x7f5884dc2350>, <compyle.array.Array object at 0x7f5884dc25d0>], <compyle.array.Array object at 0x7f5884dc1270>)
kwargs = {'backend': 'opencl'}, key = ('guintp', 'gfloatp', 'opencl', False)

    def wrapper(*args, **kwargs):
        key = key_func(*args, **kwargs)
        try:
>           return func._memoize_dic[key]
                   ^^^^^^^^^^^^^^^^^
E           AttributeError: 'function' object has no attribute '_memoize_dic'

/usr/lib/python3/dist-packages/pytools/__init__.py:684: AttributeError

During handling of the above exception, another exception occurred:

backend = 'opencl'

    @check_all_backends
    def test_align_multiple(backend):
        check_import(backend)
    
        # Given
        dev_array_a = Array(np.uint32, backend=backend)
        dev_array_b = Array(np.float32, backend=backend)
        orig_array_a = array.arange(0, 1024, 1, dtype=np.uint32, backend=backend)
        orig_array_b = array.arange(
            1024, 2048, 1, dtype=np.float32, backend=backend)
        dev_array_a.set_data(orig_array_a)
        dev_array_b.set_data(orig_array_b)
    
        indices = array.arange(1023, -1, -1, dtype=np.int64, backend=backend)
    
        # When
>       dev_array_a, dev_array_b = array.align([dev_array_a, dev_array_b],
                                               indices)

../../../compyle/tests/test_array.py:204: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../compyle/array.py:833: in align
    align_multiple_elwise = get_align_kernel(ary_list, order, backend=backend)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3/dist-packages/pytools/__init__.py:687: in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
../../../compyle/array.py:814: in get_align_kernel
    align_multiple_elwise = parallel.Elementwise(align_multiple_knl.function,
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../compyle/template.py:20: in function
    self._function = self._make_function()
                     ^^^^^^^^^^^^^^^^^^^^^
../../../compyle/template.py:24: in _make_function
    src, annotations = self._get_code()
                       ^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <compyle.array.AlignMultiple object at 0x7f5884561450>

    def _get_code(self):
        m = ast.parse(dedent(inspect.getsource(self.template)))
        argspec = getfullargspec(self.template)
        args = argspec.args
        if args[0] == 'self':
            args = args[1:]
        extra_args, extra_annotations = self.extra_args()
        args += extra_args
        arg_string = ', '.join(args)
        body = m.body[0].body
>       template = body[-1].value.s
                   ^^^^^^^^^^^^^^^^
E       AttributeError: 'Constant' object has no attribute 's'

../../../compyle/template.py:48: AttributeError
__________________________ test_sort_by_keys[cython] ___________________________

args = ([<compyle.array.Array object at 0x7f58842e58b0>, <compyle.array.Array object at 0x7f58842e5630>], <compyle.array.Array object at 0x7f58842e5590>)
kwargs = {'backend': 'cython'}, key = ('gintp', 'gintp', 'cython', False)

    def wrapper(*args, **kwargs):
        key = key_func(*args, **kwargs)
        try:
>           return func._memoize_dic[key]
                   ^^^^^^^^^^^^^^^^^
E           AttributeError: 'function' object has no attribute '_memoize_dic'

/usr/lib/python3/dist-packages/pytools/__init__.py:684: AttributeError

During handling of the above exception, another exception occurred:

backend = 'cython'

    @check_all_backends
    def test_sort_by_keys(backend):
        check_import(backend)
    
        # Given
        pre_nparr1 = np.random.randint(0, 100, 16, dtype=np.int32)
        pre_nparr2 = np.random.randint(0, 100, 16, dtype=np.int32)
    
        ## drop non unique values
        nparr1, indices = np.unique(pre_nparr1, return_index=True)
        nparr2 = pre_nparr2[indices]
    
        dev_array1, dev_array2 = array.wrap(nparr1, nparr2, backend=backend)
    
        # When
>       out_array1, out_array2 = array.sort_by_keys([dev_array1, dev_array2])
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

../../../compyle/tests/test_array.py:279: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../compyle/profile.py:72: in wrapper
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
../../../compyle/array.py:634: in sort_by_keys
    out_list = align(ary_list, order, out_list=out_list,
../../../compyle/array.py:833: in align
    align_multiple_elwise = get_align_kernel(ary_list, order, backend=backend)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3/dist-packages/pytools/__init__.py:687: in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
../../../compyle/array.py:814: in get_align_kernel
    align_multiple_elwise = parallel.Elementwise(align_multiple_knl.function,
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../compyle/template.py:20: in function
    self._function = self._make_function()
                     ^^^^^^^^^^^^^^^^^^^^^
../../../compyle/template.py:24: in _make_function
    src, annotations = self._get_code()
                       ^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <compyle.array.AlignMultiple object at 0x7f587fece490>

    def _get_code(self):
        m = ast.parse(dedent(inspect.getsource(self.template)))
        argspec = getfullargspec(self.template)
        args = argspec.args
        if args[0] == 'self':
            args = args[1:]
        extra_args, extra_annotations = self.extra_args()
        args += extra_args
        arg_string = ', '.join(args)
        body = m.body[0].body
>       template = body[-1].value.s
                   ^^^^^^^^^^^^^^^^
E       AttributeError: 'Constant' object has no attribute 's'

../../../compyle/template.py:48: AttributeError

[...]

=========================== short test summary info ============================
FAILED ../../../compyle/tests/test_array.py::test_remove[opencl] - pyopencl._...
FAILED ../../../compyle/tests/test_array.py::test_align_multiple[cython] - At...
FAILED ../../../compyle/tests/test_array.py::test_align_multiple[opencl] - At...
FAILED ../../../compyle/tests/test_array.py::test_sort_by_keys[cython] - Attr...
FAILED ../../../compyle/tests/test_array.py::test_radix_sort_by_keys - Attrib...
FAILED ../../../compyle/tests/test_array.py::test_sort_by_keys_with_output[cython]
FAILED ../../../compyle/tests/test_array.py::test_diff[int32-opencl] - Attrib...
FAILED ../../../compyle/tests/test_array.py::test_diff[float32-opencl] - Attr...
FAILED ../../../compyle/tests/test_array.py::test_diff[float64-opencl] - Attr...
FAILED ../../../compyle/tests/test_array.py::test_trapz[opencl] - AttributeEr...
FAILED ../../../compyle/tests/test_array.py::test_take_bool[opencl-int32] - p...
FAILED ../../../compyle/tests/test_array.py::test_take_bool[opencl-float32]
FAILED ../../../compyle/tests/test_array.py::test_take_bool[opencl-float64]
FAILED ../../../compyle/tests/test_cython_generator.py::TestCythonCodeGenerator::test_function_with_annotation
FAILED ../../../compyle/tests/test_cython_generator.py::TestCythonCodeGenerator::test_method_with_declare
FAILED ../../../compyle/tests/test_cython_generator.py::TestCythonCodeGenerator::test_method_with_matrix
FAILED ../../../compyle/tests/test_cython_generator.py::TestCythonCodeGenerator::test_python3_annotation
FAILED ../../../compyle/tests/test_jit.py::TestAnnotationHelper::test_cast_return_type
FAILED ../../../compyle/tests/test_jit.py::TestAnnotationHelper::test_declare_multiple_variables
FAILED ../../../compyle/tests/test_jit.py::TestAnnotationHelper::test_variable_as_call_arg
FAILED ../../../compyle/tests/test_jit.py::TestAnnotationHelper::test_variable_as_call_arg_nonjit
FAILED ../../../compyle/tests/test_low_level.py::TestKernel::test_kernel_with_local_memory_opencl
FAILED ../../../compyle/tests/test_low_level.py::TestKernel::test_simple_kernel_opencl
FAILED ../../../compyle/tests/test_low_level.py::TestCython::test_cython_code_with_return_and_nested_call
FAILED ../../../compyle/tests/test_low_level.py::TestCython::test_cython_with_externs
FAILED ../../../compyle/tests/test_template.py::test_simple_template - Attrib...
FAILED ../../../compyle/tests/test_template.py::test_that_source_code_is_available
FAILED ../../../compyle/tests/test_template.py::test_template_usable_in_code_generation
FAILED ../../../compyle/tests/test_template.py::test_template_with_extra_args
FAILED ../../../compyle/tests/test_translator.py::test_simple_assignment_expression
FAILED ../../../compyle/tests/test_translator.py::test_multiple_assignment_expressions
FAILED ../../../compyle/tests/test_translator.py::test_if_block - AssertionEr...
FAILED ../../../compyle/tests/test_translator.py::test_conditionals - Asserti...
FAILED ../../../compyle/tests/test_translator.py::test_ternary_operator - Ass...
FAILED ../../../compyle/tests/test_translator.py::test_multiple_boolops - Ass...
FAILED ../../../compyle/tests/test_translator.py::test_multiple_bitwise_ops
FAILED ../../../compyle/tests/test_translator.py::test_power - AssertionError...
FAILED ../../../compyle/tests/test_translator.py::test_calling_function - Ass...
FAILED ../../../compyle/tests/test_translator.py::test_calling_printf_with_string
FAILED ../../../compyle/tests/test_translator.py::test_subscript - AssertionE...
FAILED ../../../compyle/tests/test_translator.py::test_simple_function_with_return
FAILED ../../../compyle/tests/test_translator.py::test_annotated_function - A...
FAILED ../../../compyle/tests/test_translator.py::test_py3_annotations - Attr...
FAILED ../../../compyle/tests/test_translator.py::test_calling_method_of_known_type
FAILED ../../../compyle/tests/test_translator.py::test_calling_method_of_known_type_in_method
FAILED ../../../compyle/tests/test_translator.py::test_while - AssertionError...
FAILED ../../../compyle/tests/test_translator.py::test_bool_true_false_and_none
FAILED ../../../compyle/tests/test_translator.py::test_for - AssertionError: ...
FAILED ../../../compyle/tests/test_translator.py::test_for_with_decreasing_range
FAILED ../../../compyle/tests/test_translator.py::test_for_with_declare - Att...
FAILED ../../../compyle/tests/test_translator.py::test_two_fors - AssertionEr...
FAILED ../../../compyle/tests/test_translator.py::test_for_with_symbols - Att...
FAILED ../../../compyle/tests/test_translator.py::test_nested_for_with_symbols
FAILED ../../../compyle/tests/test_translator.py::test_with_two_functions - A...
FAILED ../../../compyle/tests/test_translator.py::test_for_with_break_continue
FAILED ../../../compyle/tests/test_translator.py::test_attribute_access - Ass...
FAILED ../../../compyle/tests/test_translator.py::test_declare_call_declares_variable
FAILED ../../../compyle/tests/test_translator.py::test_declare_matrix - Attri...
FAILED ../../../compyle/tests/test_translator.py::test_declare_call_declares_multiple_variables
FAILED ../../../compyle/tests/test_translator.py::test_class - AssertionError...
FAILED ../../../compyle/tests/test_translator.py::test_wrapping_class - Attri...
FAILED ../../../compyle/tests/test_translator.py::test_wrapping_class_with_ignore_methods
FAILED ../../../compyle/tests/test_translator.py::test_cuda_local_conversion
FAILED ../../../compyle/tests/test_translator.py::test_handles_parsing_functions
FAILED ../../../compyle/tests/test_translator.py::test_cast_works - Attribute...
= 65 failed, 212 passed, 57 skipped, 3 deselected, 1 xfailed, 32 warnings in 144.28s (0:02:24) =

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions