I want to create a bytecode-only distribution from distutils (no really, I do; I know what I'm doing). Using setuptools and the bdist_egg command, you can simply provide the --exclude-source parameter. Unfortunately the standard commands don't have such an option.
- Is there an easy way to strip the source files just before the tar.gz, zip, rpm or deb is created.
- Is there a relatively clean per-command way to do this (eg just for tar.gz or zip).
Maybe a full working code here :)
"the standard commands don't have such an option"?
Do you have the latest version of
setuptools
installed? And did you write asetup.py
file?If so, this should work:
python setup.py bdist_egg --exclude-source-files
.The distutils "build_py" command is the one that matters, as it's (indirectly) reused by all the commands that create distributions. If you override the byte_compile(files) method, something like:
You should be able to make it so that the source files are deleted from the build tree before they're copied to the "install" directory (which is a temporary directory when bdist commands invoke them).
Note: I have not tested this code; YMMV.
Try this: