I had urgent need for link_executable for msvccompiler. So I took
link_shared_object, copied to link_executable and made it work for
executables. See the attached result of my hacking:
(insert the following to msvccompiler.py)
def link_executable (self,
output_filename = output_execname + self.exe_extension
(objects, output_dir) = self._fix_object_args (objects,
(libraries, library_dirs, runtime_library_dirs) = \
self._fix_lib_args (libraries, library_dirs,
self.warn ("I don't know what to do with
+ str (runtime_library_dirs))
lib_opts = gen_lib_options (self,
if type (output_dir) not in (StringType, NoneType):
raise TypeError, "'output_dir' must be a string or None"
if output_dir is not None:
output_filename = os.path.join (output_dir, output_filename)
if self._need_link (objects, output_filename):
ldflags = self.ldflags_shared_debug[1:]
ldflags = self.ldflags_shared[1:]
ld_args = ldflags + lib_opts + \
objects + ['/OUT:' + output_filename]
ld_args[:0] = extra_preargs
self.mkpath (os.path.dirname (output_filename))
self.spawn ([self.link] + ld_args)
self.announce ("skipping %s (up-to-date)" % output_filename)
C[_] These opinions might be mine, but never those of my employer.
> Also, what are the requirements on Windows? AFAIK all you need to
> install the Distutils proper is Python 1.5.2 or later (keep in mind that
> I have only made 1.5.1 compat. changes to the 0.1.x code -- I still need
> to port those changes to the current code). But to build extensions, I
> *think* it goes like this:
> * Visual C++ 5.x or 6.x (what can x equal?)
> * Python 1.5.x only: win32api and win32con modules recommended
> (for registry access, which is provided by the standard
> winreg module in Python 1.6)
Visual C++ versions 5 and 6 only had ".0" releases (no intermediate releases
like VC++ 4.2), so for your first requirement x = '0'. There are a few
service packs available for VC++ 6 but I don't believe any of them were
*required* for building Python extensions.
A little off-topic, maybe, but hopefully the Distutils will also be able to
support building Python extensions on Windows using the Mingw32 compiler
system (i.e. the Win32 "ports" of gcc and friends). I know that I've seen a
HOWTO about building Python extensions on Win32 using Mingw32 somewhere...
Python Distribution Utilities
April 11, 2000
The Python Distribution Utilities, or Distutils for short, are a
collection of modules that aid in the development, distribution, and
installation of Python modules. (It is intended that ultimately the
Distutils will grow up into a system for distributing and installing
whole Python applications, but for now their scope is limited to module
The Distutils are a standard part of Python 1.6; if you are running 1.6,
you don't need to install the Distutils separately. This release is
primarily so that you can add the Distutils to a Python 1.5.2
installation -- you will then be able to install modules that require
the Distutils, or use the Distutils to distribute your own modules.
More information is available at the Distutils web page:
and in the README.txt included in the Distutils source distribution.
You can download the Distutils from
Trivial patches can be sent to me (Greg Ward) at gward(a)python.net.
Larger patches should be discussed on the Distutils mailing list:
Here are the changes in release 0.8, if you're curious:
* some incompatible naming changes in the command classes -- both the
classes themselves and some key class attributes were renamed (this
will break some old setup scripts -- see README.txt)
* half-hearted, unfinished moves towards backwards compatibility with
Python 1.5.1 (the 0.1.4 and 0.1.5 releases were done independently,
and I still have to fold those code changes in to the current code)
* added ability to search the Windows registry to find MSVC++
(thanks to Robin Becker and Thomas Heller)
* renamed the "dist" command to "sdist" and introduced the "manifest
template" file (MANIFEST.in), used to generate the actual manifest
* added "build_clib" command to build static C libraries needed by
* fixed the "install" command -- we now have a sane, usable, flexible,
intelligent scheme for doing standard, alternate, and custom
installations (and it's even documented!) (thanks to Fred Drake and
Guido van Rossum for design help)
* straightened out the incompatibilities between the UnixCCompiler and
MSVCCompiler classes, and cleaned up the whole mechanism for
compiling C code in the process
* reorganized the build directories: now build to either "build/lib"
or "build/lib.<plat>", with temporary files (eg. compiler turds) in
* merged the "install_py" and "install_ext" commands into "install_lib"
-- no longer any sense in keeping them apart, since pure Python
modules and extension modules build to the same place
* added --debug (-g) flag to "build_*" commands, and make that carry
through to compiler switches, names of extensions on Windows, etc.
* fixed many portability bugs on Windows (thanks to many people)
* beginnings of support for Mac OS (I'm told that it's enough for the
Distutils to install itself) (thanks to Corran Webster)
* actually pay attention to the "--rpath" option to "build_ext"
(thanks to Joe Van Andel for spotting this lapse)
* added "clean" command (thanks to Bastien Kleineidam)
* beginnings of support for creating built distributions: changes to
the various build and install commands to support it, and added the
"bdist" and "bdist_dumb" commands
* code reorganization: split core.py up into dist.py and cmd.py,
util.py into *_util.py
* removed global "--force" option -- it's now up to individual
commands to define this if it makes sense for them
* better error-handling (fewer extravagant tracebacks for errors that
really aren't the Distutils' fault
Greg Ward - just another Python hacker gward(a)python.net
All the world's a stage and most of us are desperately unrehearsed.
Hi all --
I've just added a "requirements" section to the Distutils README to
explain the need for Python 1.5.2 (for now), and the problem with
certain Linux distributions that break Python into several packages.
Here's what I have so far:
Distutils 0.8 require Python 1.5.2 or later.
Under Unix, you must have a *complete* Python installation, including
the Makefile and config.h used to build Python. These should be in
<exec-prefix>/lib/python1.X/config (where <exec-prefix> is the value of
the --exec-prefix option to Python's configure script, by default
Certain Linux distributions break Python up into multiple packages; you
should make sure you have all required packages installed:
Red Hat python, python-devel
Can anyone help me fill in the blanks here? Are there other
distributions I should be listing? Do any of the *BSD's include Python,
and if so, do they break it up in this way?
Also, what are the requirements on Windows? AFAIK all you need to
install the Distutils proper is Python 1.5.2 or later (keep in mind that
I have only made 1.5.1 compat. changes to the 0.1.x code -- I still need
to port those changes to the current code). But to build extensions, I
*think* it goes like this:
* Visual C++ 5.x or 6.x (what can x equal?)
* Python 1.5.x only: win32api and win32con modules recommended
(for registry access, which is provided by the standard
winreg module in Python 1.6)
Greg Ward - Unix nerd gward(a)python.net
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.
I'd like to extract some information stored in setup.py, namely
the package version.
A way to provide this is an "info" command. So you can have:
./setup.py info [--version,--name,--url,--author,...]
Heres a patch. It prints the infos in a specific order (as specified
in user_options), each on its own line.
It even prints if you specify -q. You should specify -q because then you
get rid of the "running info" line.
So as a result "python setup.py -q info --version" prints exactly the
package version, nothing more, nothing less.
diff -c -r --ignore-all-space --exclude=*.pyc -N distutils.orig/distutils/command/__init__.py distutils.patched/distutils/command/__init__.py
*** distutils.orig/distutils/command/__init__.py Fri Mar 31 12:16:06 2000
--- distutils.patched/distutils/command/__init__.py Fri Apr 7 02:40:42 2000
*** 12,17 ****
--- 12,18 ----
diff -c -r --ignore-all-space --exclude=*.pyc -N distutils.orig/distutils/command/info.py distutils.patched/distutils/command/info.py
*** distutils.orig/distutils/command/info.py Thu Jan 1 01:00:00 1970
--- distutils.patched/distutils/command/info.py Fri Apr 7 03:02:39 2000
*** 0 ****
--- 1,30 ----
+ Implements the Distutils 'info' command."""
+ from distutils.core import Command
+ class info (Command):
+ description = "print infos stored in setup.py"
+ user_options = [
+ ('version', 'V', "print version"),
+ ('author', None, "print author"),
+ ('author-email', None, "print the authors email"),
+ ('description', None, "print description"),
+ ('url', None, "print url"),
+ # more if needed...
+ def initialize_options(self):
+ for arg in map(lambda x: x, self.user_options):
+ # do not set to None: see Command.__getattr__
+ setattr(self, arg, 0)
+ def finalize_options(self):
+ def run(self):
+ for arg in map(lambda x: x, self.user_options):
+ if getattr(self, arg):
+ print getattr(self.distribution, arg)
Hi there -
The distutils readme says this:
Obviously, in order to use the Distutils you must first install them.
Luckily, since the goal of the whole project is to make distributing and
installing Python module distributions painless, this is quite easy:
python setup.py install
For some of us I guess things just can't be too simple. I untarred the tar
file so that there is distutils dir under the python dir. From a command
prompt, when in the main distutils dir that contains setup.py, I type
"python setup.py install" and get the following:
E:\Python\Distutils-0.1.3>python setup.py install
'python' is not recognized as an internal or external command, operable
program or batch file.
I added python.exe to my path and it didn't help. Thanks for any help!
Now that there is a distutils directory under .../Lib in the Python
distribution and Guido is deprecating the soundex extension module, I figure
it's time to try wrapping up my soundex-in-Python replacement using
Distutils. Only problem is, I see nothing that looks like any documentation
for it in the Python source tree. core.py mentions a setup script, but I
see no example of such a beast. Perhaps .../Lib/distutils needs a README
file, especially if the contents of that directory alone are not sufficient
to create a distribution (I sort of suspect they aren't).
Skip Montanaro | http://www.mojam.com/
skip(a)mojam.com | http://www.musi-cal.com/
Hi all --
I forgot two little fixes in Distutils 0.1.4: handling spaces in
filenames under Windows, and suppressing tracebacks for crashes that are
not the Distutils' fault. These are now fixed, Distutils 0.1.5 is
released, and hopefully I can now lay the 0.1.x codebase to rest and
concentrate on 0.8/0.9/1.0.
(For the record: 0.8 will be basically the current code; 0.9 will
include config files; 1.0 will be what's included with Python 1.6 final.
At least that's my plan for now.)
Here is a patch:
*** distutils.orig/distutils/dist.py Thu Apr 6 01:50:27 2000
--- distutils.patched/distutils/dist.py Thu Apr 6 01:50:09 2000
*** 185,190 ****
--- 185,191 ----
# late import because of mutual dependence between these classes
from distutils.cmd import Command
+ from distutils.core import usage
# We have to parse the command line a bit at a time -- global