sympy / scipy-2017-codegen-tutorial

SymPy code generation tutorial at SciPy 2017
http://www.sympy.org/scipy-2017-codegen-tutorial/
Other
61 stars 26 forks source link

bin/render_notebooks.sh installs sympy master #19

Closed ixjlyons closed 7 years ago

ixjlyons commented 7 years ago

This causes CI to fail on the cythonizing notebook which now makes use of the new autowrap features in 1.1. I think that line can just be removed?

moorepants commented 7 years ago

I think you need to replace the line with the 1.1rc tar ball link, no?

ixjlyons commented 7 years ago

Changed with 09ae029, though shouldn't it work without this since sympy is installed in the conda environment that's sourced right before?

moorepants commented 7 years ago

Oh yeah, I guess so.

bjodah commented 7 years ago

CircleCI caches the conda environment. I rebuilt without cache. This is now failing:

# get a path to the cfib source
import os
import scipy2017codegen
cfib_path = os.path.join(os.path.dirname(scipy2017codegen.__file__), 'cfib')

# generate a "pyxbld" file that specifies how to build everything
from scipy2017codegen.templates import render_pyxbld
render_pyxbld('fib',
              sources=[os.path.join(cfib_path, 'cfib.c')],
              include_dirs=[np.get_include(), cfib_path])
[NbConvertApp] output: status
[NbConvertApp] output: execute_input
[NbConvertApp] output: status
[NbConvertApp] Executing cell:
%%cython_pyximport fib
import numpy as np
cimport numpy as np

# here we just replicate the function signature from the header
cdef extern from "cfib.h":
    void cfib(int n, double *x)

# here is the "wrapper"
def fib(int n):
    # preallocate an array of doubles
    cdef np.ndarray[np.float64_t, ndim=1, mode='c'] x
    x = np.empty(n, dtype=np.float64)

    # call the c function and return the result
    cfib(n, <double *> x.data)
    return x
In file included from /home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1788:0,
                 from /home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from /home/ubuntu/.pyxbld/temp.linux-x86_64-3.6/pyrex/fib.c:435:
/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^
/home/ubuntu/.pyxbld/temp.linux-x86_64-3.6/pyrex/fib.c:437:18: fatal error: cfib.h: No such file or directory
 #include "cfib.h"
                  ^
compilation terminated.
[NbConvertApp] output: status
[NbConvertApp] output: execute_input
[NbConvertApp] output: error
[NbConvertApp] output: status
[NbConvertApp] ERROR | Error while converting 'notebooks/08-cythonizing.ipynb'
Traceback (most recent call last):
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 381, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 172, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 190, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/exporters/html.py", line 84, in from_notebook_node
    return super(HTMLExporter, self).from_notebook_node(nb, resources, **kw)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 268, in from_notebook_node
    nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 132, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 309, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb,resources)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 242, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/preprocessors/base.py", line 70, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/home/ubuntu/miniconda/envs/codegen17/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 275, in preprocess_cell
    raise CellExecutionError(msg)
nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
%%cython_pyximport fib
import numpy as np
cimport numpy as np

# here we just replicate the function signature from the header
cdef extern from "cfib.h":
    void cfib(int n, double *x)

# here is the "wrapper"
def fib(int n):
    # preallocate an array of doubles
    cdef np.ndarray[np.float64_t, ndim=1, mode='c'] x
    x = np.empty(n, dtype=np.float64)

    # call the c function and return the result
    cfib(n, <double *> x.data)
    return x
------------------

ImportError: Building module fib failed: ["distutils.errors.CompileError: command 'gcc' failed with exit status 1\n"]

[NbConvertApp] Exiting application: jupyter-nbconvert

./bin/render_notebooks.sh returned exit code 1

CircleCI builds with environment-gcc.yml, I'm surprised it makes a difference here.

ixjlyons commented 7 years ago

@bjodah Hopefully I just fixed that. I hadn't added the cfib/cfib.{c,h} files to MANIFEST.in so they weren't getting packaged.