install packages & modules simultaneously?
Docutils relies on a few 3rd-party modules, and includes them as a convenience. They are only to be installed if they're not already present in a Python installation, so I have code in setup.py check for them. Distutils doesn't seem to be able to handle packages and individual modules simultaneously. Distutils complains if I specify both "packages" and "py_modules" in a single call. I got the script to work by calling distutils.core.setup twice: first for the third-party modules, then for the "docutils" packages (http://docutils.sf.net/setup.py). Installation isn't so bad, but doing "python setup.py sdist" creates 2 tarballs and feels very kludgey. Does anyone know of a better way? -- David Goodger http://starship.python.net/~goodger Programmer/sysadmin for hire: http://starship.python.net/~goodger/cv
David Goodger <goodger@python.org> writes:
Docutils relies on a few 3rd-party modules, and includes them as a convenience. They are only to be installed if they're not already present in a Python installation, so I have code in setup.py check for them.
Distutils doesn't seem to be able to handle packages and individual modules simultaneously. Distutils complains if I specify both "packages" and "py_modules" in a single call. I got the script to work by calling distutils.core.setup twice: first for the third-party modules, then for the "docutils" packages (http://docutils.sf.net/setup.py). Installation isn't so bad, but doing "python setup.py sdist" creates 2 tarballs and feels very kludgey. Does anyone know of a better way?
I found the following code (commented out) in one of my setup scripts. It might do what you want, but it is untested: from distutils.command import build_py # a class which will allow to distribute packages *and* # modules with one setup script, currently unused. class my_build_py(build_py.build_py): def run (self): 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)) # run () Thomas
[David Goodger]
Distutils doesn't seem to be able to handle packages and individual modules simultaneously. Distutils complains if I specify both "packages" and "py_modules" in a single call.
[Thomas Heller]
I found the following code (commented out) in one of my setup scripts. It might do what you want, but it is untested:
It does exactly what I want; thanks! New setup.py: <http://docutils.sf.net/setup.py>. With this pointer, I looked up the Distutils source and found this comment in distutils.command.build_py.build_py.run: Two options control which modules will be installed: 'packages' and 'py_modules'. The former lets us work with whole packages, not specifying individual modules at all; the latter is for specifying modules one-at-a-time. Currently they are mutually exclusive: you can define one or the other (or neither), but not both. It remains to be seen how limiting this is. It seems (to me at least) that this is an arbitrary limitation. Is there any good reason not to allow both 'packages' and 'py_modules' in one call? If not, why not remove the limitation for everyone's benefit? -- David Goodger
participants (4)
-
A.M. Kuchling
-
David Goodger
-
Fred L. Drake, Jr.
-
Thomas Heller