# Revision history [back]

### How to run Cython examples in SageMathCell

Hi, this is not a math question, this is a programming question.

I'm trying to run the first example at doc.sagemath.org/html/en/thematic_tutorials/cython_interface by using SageMathCell service (link).

For this, I've created a zip folder that I've stored in the cloud (Google Drive).

When I run the following python script in SageMathCell (I wrote it to test Cython capabilities in SageMath remote server), it seems good, but I can't see the output, that would be "Hello World".

This python script, after execution, ends with "Compiling ./Call_C_code/hello_sage.pyx..." without anyone else output.

Can you help me? Thanks,

import os
import tempfile
import sys
from distutils.dir_util import copy_tree

directory_name = tempfile.mkdtemp()
print(directory_name)
sys.path.append(directory_name)

import urllib
filename = "/Call_C_code.zip"
urllib.urlretrieve(url, directory_name + filename)

# opening the zip file in READ mode
from zipfile import ZipFile
os.chdir(directory_name)
file_name = "Call_C_code.zip"

with ZipFile(file_name, 'r') as zip:
# extracting all the files
print('Extracting all the files now...')
zip.extractall()
print('Done!')

print(sys.path)
print (os.getcwd())

for root, dirs, files in os.walk("."):
for filename in files:
print(filename)

#############
%runfile Call_C_code/hello_sage.pyx
my_bridge_function()


### How to run Cython examples in SageMathCell

Hi, this is not a math question, this is a programming question.

I'm trying to run the first example at doc.sagemath.org/html/en/thematic_tutorials/cython_interface by using SageMathCell service (link).

For this, I've created a zip folder that I've stored in the cloud (Google Drive).

When I run the following python script in SageMathCell (I wrote it to test Cython capabilities in SageMath remote server), it seems good, but I can't see the output, that would be "Hello World".

This python script, after execution, ends with "Compiling ./Call_C_code/hello_sage.pyx..." without anyone else output.

Can you help me? Thanks,

import os
import tempfile
import sys
from distutils.dir_util import copy_tree

directory_name = tempfile.mkdtemp()
print(directory_name)
sys.path.append(directory_name)

import urllib
filename = "/Call_C_code.zip"
urllib.urlretrieve(url, directory_name + filename)

# opening the zip file in READ mode
from zipfile import ZipFile
os.chdir(directory_name)
file_name = "Call_C_code.zip"

with ZipFile(file_name, 'r') as zip:
# extracting all the files
print('Extracting all the files now...')
zip.extractall()
print('Done!')

print(sys.path)
print (os.getcwd())
print(os.getcwd())

for root, dirs, files in os.walk("."):
for filename in files:
print(filename)

#############
%runfile Call_C_code/hello_sage.pyx
my_bridge_function()