Skip to content

Example empty C++/python conda packaging for a project

Notifications You must be signed in to change notification settings

blackbox-tech/acme-skeleton

Repository files navigation

acme-skeleton

This is an example 'hello world' repository, using a fictional company name 'acme' as a placeholder for the root namespace, and the name 'skeleton' an example the project name. I use this repository as a template for starting new C++/python projects which are managed and deployed by conda. This public repository is not supported, it just serves as an example project to help others because the online setuptools and conda documentation/examples are patchy and packaging C++/python hybrid repositories can be tricky.

These examples are currently configured for Linux using g++. The conda recipe uses a Makefile to build the pure C++ components and python's setuptools to build C++ python extensions then package all the built components together. All the C++ components and python extensions are built using conda's compiler and linked against the libraries that are in the conda environment, rather than the system compiler/libraries to avoid any ABI incompatibilities with the host's distribution. There are also some subtle features like setting rpath=$ORIGIN to avoid the need to set LD_LIBRARY_PATH when doing local development.

development

To develop and test applications locally in this repository you first need to build the components and set the PYTHONPATH in your local environment:

$ python setup.py build
$ export PYTHONPATH=${PWD}/packages

* note these conda packages need to be already installed in the environment that you are using for development: make cxx-compiler pybind11 boost pytest

C++ and python test harnesses are automatically run by conda-build, but can be run manually:

$ make test
$ pytest

You can also activate some example git pre-commit hooks by running:

$ pre-commit install

layout

The root folders in the repository contain the following:

  • python/ - source code for the pure python modules
  • tests/ - python pytest harnesses
  • scripts/ - python executable scripts
  • src/ - source code for C++ objects
  • include/ - C++ libraries header files
  • share/ - language agnostic data files such as config
  • bin/ - symlink to built C++ executable binaries
  • lib/ - symlink to built C++ libraries
  • packages/ - symlink to built python packages (both C++ extensions and pure python)