0

Currently I have one pyx file contains all classes (parent class and children classes). now I want to break it down into multiple files, one file for the parent class, and each child class has it own file. So two things I want to know

  1. How do I import the parent class in the child class file?
  2. What need to be changed in the setup.py, in order to build the extension?

setup.py look like

from distutils.core import setup

from Cython.Build import cythonize

setup(ext_modules = cythonize("MyLibrary.pyx"))

I have google it, but what I got is how to build multiple extensions at once. Thanks for advance

Eric So
  • 465
  • 2
  • 14

1 Answers1

0

Turn out it is pretty easy. I even don't need to change the setup.py I just moved the children classes' code to their own files and include them from the parent class.

It would became something like this

  • Child1.pyx
  • Child2.pyx
  • Child3.pyx
  • MyLibrary.pyx

and in the MyLibrary.pyx

.
.
.
include Child1.pyx
include Child2.pyx
include Child3.pyx

class parent:
.
.
.
Eric So
  • 465
  • 2
  • 14