Solved by setting an environment variable during the first pass through the script, which is then read again when building the RPM:
import os
from distutils.core import setup, Extension
src_path = os.path.abspath('../src/common.c')
inc_path = os.path.abspath('../includes')
if 'SRC_PATH' not in os.environ:
os.environ['SRC_PATH'] = src_path
os.environ['INC_PATH'] = inc_path
else:
src_path = os.environ['SRC_PATH']
inc_path = os.environ['INC_PATH']
foo_ext = Extension('foo',
sources=['foo.c', src_path],
include_dirs=[inc_path])
setup(... , ext_modules=[foo_ext])