get build path for package within

asked 2017-07-12 06:25:20 -0600

LorenzH gravatar image

updated 2017-07-12 06:29:03 -0600


I want to redirect the c-files coming from cython to the build directory during the installation step. I am experimenting with the following, which is ok,

import os.path
from catkin_tools.context import Context
subfolder = 'cython_build'
ctx = Context.load()
build_dir = os.path.join(ctx.build_space_abs, subfolder)

This results for in a cython build_path approx. like "/home/user/catkin_ws/build/cython_build/src/package_name"

but I am wondering if I could (should) just use the following, instead of recreating the same function:

build_dir =  ctx.package_build_space(package)

and hopefully the path ends up to something like: "/home/user/catkin_ws/build/package_name/cython_build/..."

but I don't know what the argument 'package' is. It is definitely not the (String) name_of_package


I created a which "cythonizes" my python modules and installs them. However, the created c-files(1) are placed next to the python files per default. This makes trouble during the travis build with industrial_ci, since the source-folder is read-only.

(1) I don't want to keep the c-files right now, so I don't consider them source files and more intermediate build products.

PS: If someone is interested, I am happy to share the lessons-learned for this catkin-cython procedures as soon as my experiments converge. Please, let me know.

This question is somewhat related to

Full example

#!/usr/bin/env python

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup
from Cython.Build import cythonize
from catkin_tools.context import Context

# fetch values from package.xml
setup_args = generate_distutils_setup(
    package_dir={'': 'scripts'})

ctx = Context.load()
build_path = ctx.build_space_abs + "/cython_build"

setup(ext_modules = cythonize("scripts/my_driver/*.py",
edit retag flag offensive close merge delete