Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autotools and python setup.py

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?

like image 723
hpixel Avatar asked Nov 14 '11 23:11

hpixel


1 Answers

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.

like image 184
ldav1s Avatar answered Sep 20 '22 02:09

ldav1s