Where do I put my cython files in a python distribution?

I write and maintain a Python library for calculating quantum chemistry called PyQuante . I have a pretty standard Python distribution with the setup.py file in the main directory, a subdirectory called "PyQuante" that contains all the Python modules and one called "Src", which contains the source code for the C extension modules.

I was fortunate that some users donated code that uses Cython, which I had not used before, since I started PyQuante before it or Pyrex existed. At my suggestion, they placed the code in the Src subdirectory, since all the C codes went there.

However, looking at the code that generates extensions, I wonder if I should just put the code in a subdirectory of the Python branch. And so my question is:

What are the best methods for directory structure of python distributions with Python and Cython source files?

  • Do you put .pyx files in the same directory as .py files?
  • Do you put them in a subdirectory of the one that contains the .py files?
  • Do you put them in a child of the parent directory .py?

Is the fact that I even ask this question betrayed my ignorance in distributing .pyx files? I am sure there are many ways to make this work, and I am mostly concerned about what works best for people.

Thanks for any help you can offer.

+4
source share
1 answer

Putting .pyx files in the same directory as .py files makes the most sense to me. This is what scikit-learn authors did and what I did in my py-earth . I think I think of Cython modules as optimized replacements for Python modules. I often start by writing a package in pure Python, and then replace some Cython modules if I need better performance. Since I see Cython modules as replacements for Python modules, it makes sense for me to keep them in one place. It also works well for test builds using the --inplace argument.

+2
source

Source: https://habr.com/ru/post/1484096/


All Articles