[Distutils] py_modules AND packages?

Thomas Heller thomas.heller@ion-tof.com
Wed May 8 14:50:02 2002


Why is it not allowed to install py_modules AND packages
in the same setup-script?

I have a distribution where an extensions is installed
in c:\python22\lib\site-packages\<ext.pyd>, and a package is installed
in c:\python22\lib\site-packages\<packagename>.
No problem so far.

I want to hide the extension in a Python module, so that
I can implement additional functionality in this module in
Python, and convert it to C and move it into the extension
later.

Currently, this is not possible: 
  error: build_py: supplying both 'packages' and 'py_modules' options is not allowed

A tiny patch to build_py makes it possible (at the end of this mail),
also it would be easy to write a custom build_py command which allows this.

Would there be any harm, or is it simply that Greg did not think
of this?

Thomas
*** \sf\python\dist\src\lib\distutils\command\build_py.py       Thu Apr 04 23:17:31 2002
--- \python22\lib\distutils\command\build_py.py Wed May 08 18:44:39 2002
***************
*** 4,10 ****

  # created 1999/03/08, Greg Ward

! __revision__ = "$Id: build_py.py,v 1.37 2002/04/04 23:17:31 tim_one Exp $"

  import sys, string, os
  from types import *
--- 4,10 ----

  # created 1999/03/08, Greg Ward

! __revision__ = "$Id: build_py.py,v 1.34.6.1 2002/02/19 14:15:40 mwh Exp $"

  import sys, string, os
  from types import *
***************
*** 96,110 ****

          if not self.py_modules and not self.packages:
              return
-         if self.py_modules and self.packages:
-             raise DistutilsOptionError, \
-                   "build_py: supplying both 'packages' and 'py_modules' " + \
-                   "options is not allowed"

-         # Now we're down to two cases: 'py_modules' only and 'packages' only.
          if self.py_modules:
              self.build_modules()
!         else:
              self.build_packages()

          self.byte_compile(self.get_outputs(include_bytecode=0))
--- 96,105 ----

          if not self.py_modules and not self.packages:
              return

          if self.py_modules:
              self.build_modules()
!         if self.packages:
              self.build_packages()

          self.byte_compile(self.get_outputs(include_bytecode=0))