mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-07 18:14:05 +00:00
Fix cython in scipy-notebook
This commit is contained in:
@@ -8,9 +8,15 @@ LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"
|
||||
|
||||
USER root
|
||||
|
||||
# ffmpeg for matplotlib anim & dvipng+cm-super for latex labels
|
||||
RUN apt-get update --yes && \
|
||||
apt-get install --yes --no-install-recommends ffmpeg dvipng cm-super && \
|
||||
apt-get install --yes --no-install-recommends \
|
||||
# for cython: https://cython.readthedocs.io/en/latest/src/quickstart/install.html
|
||||
build-essential \
|
||||
# for latex labels
|
||||
cm-super \
|
||||
dvipng \
|
||||
# for matplotlib anim
|
||||
ffmpeg && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
USER ${NB_UID}
|
||||
|
1
tests/scipy-notebook/data/cython/helloworld.pyx
Normal file
1
tests/scipy-notebook/data/cython/helloworld.pyx
Normal file
@@ -0,0 +1 @@
|
||||
print("Hello World")
|
9
tests/scipy-notebook/data/cython/setup.py
Normal file
9
tests/scipy-notebook/data/cython/setup.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from setuptools import setup
|
||||
from Cython.Build import cythonize
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
THIS_DIR = Path(__file__).parent.resolve()
|
||||
|
||||
|
||||
setup(ext_modules=cythonize(str(THIS_DIR / "helloworld.pyx")))
|
36
tests/scipy-notebook/test_cython.py
Normal file
36
tests/scipy-notebook/test_cython.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = Path(__file__).parent.resolve()
|
||||
|
||||
|
||||
def test_cython(container: TrackedContainer) -> None:
|
||||
data_dir = THIS_DIR / "data/cython"
|
||||
|
||||
with tempfile.TemporaryDirectory() as host_data_dir:
|
||||
"""We create temporary dir with the same content to mount it as a writeable folder
|
||||
This allows to run this test in parallel many times
|
||||
"""
|
||||
shutil.copy(data_dir / "helloworld.pyx", host_data_dir)
|
||||
shutil.copy(data_dir / "setup.py", host_data_dir)
|
||||
|
||||
cont_data_dir = "/home/jovyan/data"
|
||||
command = "sleep infinity"
|
||||
|
||||
running_container = container.run_detached(
|
||||
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "rw"}},
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", command],
|
||||
)
|
||||
command = f"python {cont_data_dir}/setup.py build_ext --inplace"
|
||||
cmd = running_container.exec_run(command)
|
||||
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||
assert cmd.exit_code == 0, f"Command {command} failed"
|
Reference in New Issue
Block a user