4

I'm refactoring the directory structure of a large Python repo that has a few dozen C and C++ files littered throughout. Is there a suggested architecture for a Python package that contains C/C++ code within it? What I have at the moment for my repo foo is:

foo/
├── LICENSE
├── Makefile
├── README.md
├── docs/
├── examples/
├── foo/
│ ├── __init__.py
│ ├── README.md
│ ├── core/
│ │ ├── __init__.py
│ │ ├── foo_tricks_slow.py
│ │ ├── foo_tricks_fast.cpp
│ │ └── foo_tricks_fast.mk
│ ├── experiments/
│ └── utils/
├── requirements.txt
├── setup.py
└── tests/ # Run with py.test
 ├── __init__.py
 └── test_foo.py

Each subdir core/, experiments/, utils/, and so on contains mostly python files, and some C/C++ files.

Some things I've heard mixed opinions on that I'd like to reach a conclusion on include

  1. Putting tests outside the Python package
  2. Putting source in a src/ dir
  3. Keeping a directory for Python and a directory for C/C++

Some sources of info I've looked at include:

A. Filesystem structure of a Python project by Jean-Paul Calderone

B. cookiecutter

C. Jeff Knupp's blog post

D. This SO question is close, but I don't have a self-contained C++ project, but rather some misc. files, each with their own mk file that gets accumulated when running the main Makefile.

E. Example repositories like Tensorflow, Keras, Nupic, Django

Related: I would like the repo to be installed and built with pip install foo. I'm unsure how this would also build the C/C++ files though. For example, pip install tensorflow accomplishes this. Perhaps that's for a followup SO question though.

Robert Harvey
201k55 gold badges469 silver badges682 bronze badges
asked Jul 25, 2017 at 16:38
4
  • 2
    Your folder structure does not constitute a software architecture. Commented Jul 26, 2017 at 23:44
  • TensorFlow installs precompiled libraries. If you install it from sources, you need more steps than just pip install tensorflow Commented Jul 27, 2017 at 9:35
  • Would you explain more @RobertHarvey? Or if you're just arguing semantics, would you prefer "repo structure"? Commented Jul 27, 2017 at 15:59
  • 1
    "Folder structure" or "directory structure." Commented Jul 27, 2017 at 17:52

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.