[Distutils] Byte-compilation revisited

Greg Ward gward@python.net
Tue Oct 3 22:08:02 2000

On 03 October 2000, M.-A. Lemburg said:
> Uhm, I only wanted to prevent the install command from producing
> errors in case it cannot find the .py files to install (it should
> suffice just being able to copy the .pyc/o files). 

OK -- *poof!* -- it works.  Time machine.  It's *always* been like that; 
the "install" command just installs whatever it finds in the various
subdirectories of build/.  If you delete the .py files in build, and
then install *without building* again, then you have a no-source-code

Example, from my distutils development dir:

  rm -rf /usr/lib/python1.5/site-packages/distutils
  python setup.py clean -a
  python setup.py build_py --compile build
  rm `find build/ -name '*.py'`
  python setup.py install --skip-build

That works: I now have a closed source Distutils installation.  If I
provoke a traceback (by setting DISTUTILS_DEBUG=1 and providing a bad
directory), I get:

Traceback (innermost last):
  File "setup.py", line 55, in ?
  File "./distutils/core.py", line 138, in setup
  File "./distutils/dist.py", line 829, in run_commands
  File "./distutils/dist.py", line 849, in run_command
  File "./distutils/command/build.py", line 106, in run
  File "/usr/lib/python1.5/cmd.py", line 328, in run_command
  File "./distutils/dist.py", line 849, in run_command
  File "./distutils/command/build_py.py", line 104, in run
  File "./distutils/command/build_py.py", line 371, in build_packages
  File "./distutils/command/build_py.py", line 333, in build_module
  File "/usr/lib/python1.5/cmd.py", line 358, in mkpath
  File "./distutils/dir_util.py", line 80, in mkpath
distutils.errors.DistutilsFileError: could not create '/foo': Permission denied

The filenames in the .pyc files are less than helpful (they're relative
to build/lib in my development tree), but who cares?  there're no source
files installed here anyways!

Is it obvious?  Not really.  Does it work?  You bet!  Could you sit down
right now and churn out a closed-source RPM?  I don't think so --
bdist_rpm doesn't let you supply arbitrary options to the "install" or
"build" commands, and I don't think it should.  You'd have to extend
bdist_rpm to do this.

Is this the right way to do closed source distributions?  Well, to do it 
cleanly would require a "--remove-source" option to "build_py", and then 
support from bdist_{rpm,wininst,...}.  Not impossible by any stretch.

Who else out there wants this functionality?  Should the ability to
distribute closed-source module distributions be standard?  Or should
people who want it be required to extend bdist_{rpm,wininst,...} if they
need it?

trying-so-hard-not-to-say-"greedy closed source bastards!"-because-

Greg Ward                                      gward@python.net