Commit 8901b249 authored by Robert Bradshaw's avatar Robert Bradshaw

Expand bazel example.

parent ee3bd4d9
...@@ -5,14 +5,18 @@ Uses Cython to compile a .pyx files (and .py files with corresponding .pxd ...@@ -5,14 +5,18 @@ Uses Cython to compile a .pyx files (and .py files with corresponding .pxd
files) to Python extension modules. files) to Python extension modules.
Example: Example:
# Assuming Cython is mapped to "cython" in your workspace.
load("@cython//Tools:rules.bzl", "pyx_library")
pyx_library(name = 'mylib', pyx_library(name = 'mylib',
srcs = ['a.pyx', 'a.pxd', 'b.py', 'pkg/c.pyx'], srcs = ['a.pyx', 'a.pxd', 'b.py', 'pkg/__init__.py', 'pkg/c.pyx'],
py_deps = ['//py_library/dep'], py_deps = ['//py_library/dep'],
data = ['//other/data'], data = ['//other/data'],
) )
Make sure to include the __init__.py files in your srcs list so that Cython The __init__.py file must be in your srcs list so that Cython can resolve
can resolve cimports using the package layout. cimports using the package layout.
""" """
def pyx_library( def pyx_library(
...@@ -34,6 +38,7 @@ def pyx_library( ...@@ -34,6 +38,7 @@ def pyx_library(
else: else:
pxd_srcs.append(src) pxd_srcs.append(src)
if src.endswith('__init__.py'): if src.endswith('__init__.py'):
# TODO(robertwb): Infer __init__.py files/package root?
pxd_srcs.append(src) pxd_srcs.append(src)
# Invoke cythonize to produce the shared object libraries. # Invoke cythonize to produce the shared object libraries.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment