Hacker News new | ask | show | jobs
by x1798DE 2684 days ago
For C extensions, the most common layout I've seen is to put C code under lib/ (regardless of whether you are using a src/ layout).
1 comments

Checking my local copies of different packages containing both C and Python:

  matplotlib: src/ contains C code while lib/ contains Python
  cffi: c/ contains C code, there is no lib/
  numpy: contains C code in many places, like numpy/core/src/ ; no lib/
  pyzmq: contains C code mostly under zmq/core/ ; no lib/
  python-cdb: contains C code under src/ ; no lib/
Checking a few other packages:

  pycuda: contains C code under src/ ; no lib/
  Pillow: contains C code under src/ ; no lib/
  tornado: the one C file is under tornado/ ; no lib/ or src/
  Caffe: C++ code under src/ ; no lib/
That is, I haven't found any packages which put C extension code under lib/ .

Which packages are you thinking of?

Ah, my mistake. I know that CPython and matplotlib both have a lib/ directory, but you're right that that's where they keep the Python code and they keep the C code in Modules/ and src/, respectively.

Also I may have confused this with the src/ layout in the past and put my own C extensions into lib/. Thanks for the survey, I think I've been harboring this misconception for a while now.