Skip to content

Make sage run in Julia's python-jl #28754

@mkoeppe

Description

@mkoeppe

I installed Julia 1.0.3 and Sage 8.8 in conda on Mac OS X Mojave
using the following file environment-sage-julia.yml:

name: sage-julia
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3
  - sage=8.9
  - julia
  - pip
  - pip:
    - julia     # python interface to julia, see https://github.com/JuliaPy/pyjulia

and the commands:

  conda env create -f environment-sage-julia.yml
  conda activate sage-julia

This gives a working sage:

$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.9, Release Date: 2019-09-29                     │
│ Using Python 3.7.3. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
sage:                                                                                                                                           

Next, I initialize "PyJulia", following the example here: https://github.com/JuliaPy/pyjulia

  python -c 'import julia; julia.install();'

Now I can usepython-jl, a julia-enabled python:

 python-jl -c 'import julia; from julia import Base; print(julia.Base.VERSION); import sage.env; print(sage.env.SAGE_VERSION)'

So far this works, giving:

<PyCall.jlwrap 1.0.3>
8.8

But then I try this, which just loads a few more millions of lines of code:

python-jl -c 'from sage.all import *'

And it fails:

Traceback (most recent call last):
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 308, in main
    python(**vars(ns))
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/julia/pseudo_python_cli.py", line 52, in python
    exec(command, scope)
  File "<string>", line 1, in <module>
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/sage/all.py", line 84, in <module>
    from sage.misc.all       import *         # takes a while
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/sage/misc/all.py", line 84, in <module>
    from .functional import (additive_order,
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/sage/misc/functional.py", line 27, in <module>
    from sage.rings.complex_double import CDF
  File "sage/rings/integer.pxd", line 7, in init sage.rings.complex_double (build/cythonized/sage/rings/complex_double.c:23709)
    cdef class Integer(EuclideanDomainElement):
  File "sage/rings/rational.pxd", line 8, in init sage.rings.integer (build/cythonized/sage/rings/integer.c:51965)
    cdef class Rational(sage.structure.element.FieldElement):
  File "sage/rings/rational.pyx", line 81, in init sage.rings.rational (build/cythonized/sage/rings/rational.c:39473)
    from .integer_ring import ZZ
  File "sage/rings/integer_ring.pyx", line 58, in init sage.rings.integer_ring (build/cythonized/sage/rings/integer_ring.c:17410)
    import sage.rings.ideal
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/sage/rings/ideal.py", line 36, in <module>
    from sage.interfaces.singular import singular as singular_default
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/sage/interfaces/singular.py", line 332, in <module>
    from .expect import Expect, ExpectElement, FunctionElement, ExpectFunction
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/site-packages/sage/interfaces/expect.py", line 59, in <module>
    from sage.interfaces.sagespawn import SageSpawn
  File "sage/interfaces/process.pxd", line 1, in init sage.interfaces.sagespawn (build/cythonized/sage/interfaces/sagespawn.c:4733)
    cdef class ContainChildren(object):
  File "sage/interfaces/process.pyx", line 25, in init sage.interfaces.process (build/cythonized/sage/interfaces/process.c:5123)
    from cysignals.pysignals import changesignal
  File "src/cysignals/pysignals.pyx", line 488, in init cysignals.pysignals
  File "src/cysignals/pysignals.pyx", line 372, in cysignals.pysignals.changesignal.__exit__
  File "src/cysignals/pysignals.pyx", line 318, in cysignals.pysignals.setsignal
  File "/Users/mkoeppe/miniconda3/envs/sage-cgf-tf2/lib/python3.7/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object

CC: @embray @jdemeyer @dimpase @isuruf @saraedum @slel

Component: porting

Keywords: conda, julia, signals

Issue created by migration from https://trac.sagemath.org/ticket/28754

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions