[Distutils] Skipping compilation of some .py files on "install"?
Mon May 27 04:51:01 2002
Barry A. Warsaw wrote:
> The email package has two files to help it maintain compatibility with
> Python 2.1 and Python 2.2+. There's a _compat21.py and a _compat22.py
> that contains tricky bits that are different between the two Python
> versions. Other code that needs something out of these modules, first
> tries to import _compat22.py, wrapping this import so that if errors
> occur, it backs down to _compat21.py.
> The problem comes when I do "python2.1 setup.py install", which tries
> to bytecompile all the .py files. Naturally Python 2.1 won't be able
> to compile _compat22.py and indeed you get a SyntaxError.
> Is there a way -- in my setup.py -- that I can first detected which
> Python version I'm using (should be easy), and then skip byte
> compilation of _compat22.py when I find I'm using Python 2.1?
Not builtin, but it should be easy to write your own subclass
which implements this.
Note that the installers sometimes use their own code to
byte-compile files late during the install. You can only either
choose to disable the compile completely or live with the
SyntaxError (if the installers let you ;-).
CEO eGenix.com Software GmbH
Company & Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/