Produce .pyc without execution

François Pinard pinard at iro.umontreal.ca
Sun Oct 31 03:01:22 EST 1999


"Adrian Eyre" <a.eyre at optichrome.com> writes:

> > Is there a way to compile a module without executing it? Just check syntax
> > and produce the .pyc file?

> See Lib/compileall.py

For one of my Python projects (I begin to have a few :-), I get this done
through my various `Makefile.am' files, with an `install-data-hook' goal.
Let me share an example with you.  Below, I include `configure.in',
the top-level `Makefile.am', then `src/Makefile.am'.  I do not include
`lib/Makefile.am': it is bigger than the `src/' one and brings nothing new.

Finally, I include `src/GNUmakefile', which I planted in the `src/' directory
of the distribution hierarchy, by opposition of the build hierarchy.
I have a similar `lib/GNUmakefile'.  These special files do not get
distributed, but they are very convenient for me.  My build hierarchy is
`local/' under the top-level, and after I modified a few Python files,
I just do `C-c C' in Emacs, which is my own binding for `M-x compile',
right from any source window, to save, install and recompile in one blow.

However, I could not decently propose this scheme for integration in
Automake, and that makes it a bit unsatisfactory.  It would be nicer, for
example, if `src/*.py' files were recompiled into the `src/' build hierarchy
from the `src/' distribution hierarchy, and then installed from there.
But `compileall' wants to install compiled files next to sources in the
same directory, which is a bit inconvenient.  Any simple solution?

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: configure.in
URL: <http://mail.python.org/pipermail/python-list/attachments/19991031/4b5f5bf2/attachment.ksh>
-------------- next part --------------

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile.am
URL: <http://mail.python.org/pipermail/python-list/attachments/19991031/4b5f5bf2/attachment-0001.ksh>
-------------- next part --------------

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile.am
URL: <http://mail.python.org/pipermail/python-list/attachments/19991031/4b5f5bf2/attachment-0002.ksh>
-------------- next part --------------

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: GNUmakefile
URL: <http://mail.python.org/pipermail/python-list/attachments/19991031/4b5f5bf2/attachment-0003.ksh>
-------------- next part --------------

-- 
Fran?ois Pinard   http://www.iro.umontreal.ca/~pinard


More information about the Python-list mailing list