Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!transit3.readnews.com!news-out.readnews.com!transit4.readnews.com!panix!roy From: Roy Smith Newsgroups: comp.lang.python Subject: Re: Python Makefiles... are they possible? Date: Tue, 12 Feb 2013 20:06:35 -0500 Organization: PANIX Public Access Internet and UNIX, NYC Lines: 30 Message-ID: References: NNTP-Posting-Host: localhost X-Trace: reader1.panix.com 1360717595 22747 127.0.0.1 (13 Feb 2013 01:06:35 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 13 Feb 2013 01:06:35 +0000 (UTC) User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Xref: csiph.com comp.lang.python:38797 In article , Oscar Benjamin wrote: > On 13 February 2013 00:44, Malcolm White wrote: > > I have written a piece of code that will be part of a larger repository of > > related programs. Within this repository, it is standard to issue a 'make' > > command to compile any desired program. Is it possible to create a Makefile > > to compile a simple Python program? Based on what I have come across so > > far, this is not (at least not typically) the way things are done with > > Python. > > You can use a Makefile for anything you want in a Python project. > However Python code is not (typically) compiled so it is not common > practise to compile it with or without a Makefile. When part of a > Python project is compiled because, for example it bundles some C code > to be used within Python, the compilation needs to performed in way > that will be compatible with Python so the process is normally > controlled by Python, through a setup.py file. In this case > compilation is done with something like 'python setup.py build' (Of > course there's nothing to stop you from adding that command to a > Makefile and invoking it with 'make'). > > I often use Makefiles in Python projects for other purposes, though, > such as running tests with 'make test' or building documentation with > 'make doc'. One thing we do in our Makefiles is "find . -name '*.pyc' | xargs rm". It avoids all sorts of nasty and hard to track down bugs (consider what happens if you move a .py file from one place in your source tree to another and leave the old .pyc behind).