I have a project written mostly in c++ that includes a few helper scripts written in python. For the moment, the scripts contain variables substituted by the autotools:
#!@PYTHON@
# -*- coding: utf-8 -*-
...
try:
datapath = os.environ['DATA_PATH']
except KeyError:
datapath = '@pkgdatadir@'
And here is an extract of Makefile.am:
BUILT_SOURCES = script.py
nodist_python_PYTHON = script.py
CLEANFILES = $(python_PYTHON)
EXTRA_DIST = script.py.in
do_subst = sed -e 's,[@]PYTHON[@],$(PYTHON),g'\
-e 's,[@]pkgdatadir[@],$(pkgdatadir),g'
script.py: script.py.in
$(do_subst) < $< > $@
chmod +x $@
These scripts have also a few module dependencies which would probably be better handled by a setup.py script.
So what is the best way to mix the autotools and the python distutils tools? Should I rely entirely on the autotools? Otherwise how can I integrate the launching of setup.py in the Makefile.am?
I'd use autoconf to setup script.py instead of 'make' as you've shown. Something like:
AC_CONFIG_FILES([script.py], [chmod +x script.py])
before AC_OUTPUT in configure.ac should do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With