Opened 4 years ago

Closed 4 years ago

#24105 closed enhancement (fixed)

Deprecate Sage-specific Cython pragmas like #clib

Reported by: jdemeyer Owned by:
Priority: major Milestone: sage-8.1
Component: misc Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: de24e8b (Commits, GitHub, GitLab) Commit: de24e8bcdb2f77c113a3fb37df27b485cb7638bf
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

Deprecate

  1. Cython preprocessor pragmas like #clib flint. Instead, you can use the Cython declarations like # distutils: libraries = flint.
  1. Various functions in sage.misc.cython to implement this. Keep them as private underscored functions.
  1. The module sage.misc.cython_c which currently only contains a wrapper around cython_import_all().

Change History (9)

comment:1 Changed 4 years ago by jdemeyer

  • Description modified (diff)

comment:2 Changed 4 years ago by jdemeyer

  • Branch set to u/jdemeyer/deprecate_sage_specific_cython_pragmas_like__clib

comment:3 Changed 4 years ago by jdemeyer

  • Commit set to de24e8bcdb2f77c113a3fb37df27b485cb7638bf
  • Status changed from new to needs_review

New commits:

de24e8bDeprecate Sage-specific Cython pragmas like #clib

comment:4 Changed 4 years ago by jdemeyer

  • Description modified (diff)

comment:5 Changed 4 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

Makes sense and LGTM.

comment:6 Changed 4 years ago by fbissey

Well my compiler doesn't like it in sage-on-gentoo

sage -t --long --warn-long 73.3 /usr/lib64/python2.7/site-packages/sage/libs/pynac/pynac.pxd
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/libs/pynac/pynac.pxd", line 10, in sage.libs.pynac.pynac
Failed example:
    cython(  # long time; random compiler warnings
    '''
    # distutils: language = c++
    # distutils: libraries = pynac
    # distutils: extra_compile_args = --std=c++11
    cimport sage.libs.pynac.pynac
    ''')
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 518, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 888, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.libs.pynac.pynac[0]>", line 7, in <module>
        ''')
      File "sage/misc/lazy_import.pyx", line 354, in sage.misc.lazy_import.LazyImport.__call__ (/dev/shm/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/build/cythonized/sage/misc/lazy_import.c:3638)
        return self.get_object()(*args, **kwds)
      File "/usr/lib64/python2.7/site-packages/sage/misc/cython.py", line 906, in cython_compile
        create_local_c_file=False)
      File "/usr/lib64/python2.7/site-packages/sage/misc/cython.py", line 816, in cython_import_all
        create_local_c_file=create_local_c_file)
      File "/usr/lib64/python2.7/site-packages/sage/misc/cython.py", line 793, in cython_import
        **kwds)
      File "/usr/lib64/python2.7/site-packages/sage/misc/cython.py", line 590, in cython
        dist.run_command("build")
      File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib64/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib64/python2.7/distutils/command/build_ext.py", line 340, in run
        self.build_extensions()
      File "/usr/lib64/python2.7/distutils/command/build_ext.py", line 449, in build_extensions
        self.build_extension(ext)
      File "/usr/lib64/python2.7/distutils/command/build_ext.py", line 531, in build_extension
        target_lang=language)
      File "/usr/lib64/python2.7/distutils/ccompiler.py", line 691, in link_shared_object
        extra_preargs, extra_postargs, build_temp, target_lang)
      File "/usr/lib64/python2.7/distutils/unixccompiler.py", line 205, in link
        raise LinkError, msg
    LinkError: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1
**********************************************************************

I am on gcc-6.4.0.

comment:7 follow-up: Changed 4 years ago by jdemeyer

Can you run the test manually outside of the doctester? You should see a better error message, which is not shown here because the doctester omits normal output if an exception was raised.

comment:8 in reply to: ↑ 7 Changed 4 years ago by fbissey

Replying to jdemeyer:

Can you run the test manually outside of the doctester? You should see a better error message, which is not shown here because the doctester omits normal output if an exception was raised.

Thanks for that clue! That's caused by my multi-python pynac hack in sage-on-gentoo. The previous doctest was adjusted with a sed command and needs adjusting.

Glad I didn't put this back to "need_work".

comment:9 Changed 4 years ago by vbraun

  • Branch changed from u/jdemeyer/deprecate_sage_specific_cython_pragmas_like__clib to de24e8bcdb2f77c113a3fb37df27b485cb7638bf
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.