setup script) to be a list of Extension instances, rather than a list of of
(ext_name, build_info) tuples. This is mostly a simplification, but
'check_extension_list()' got a lot more complicated because of the need to
convert the old-style tuples to Extension instances.
Temporarily dropped support for defining/undefining macros in the
'extensions' list -- I want to change the interface, but haven't yet made
the required changes in CCompiler and friends to support this nicely.
Also neatened up the code that merges 'extra_compile_flags' and the CFLAGS
environment variable.
Added 'reinitialize_command()' -- lets us "push" option values in
a controlled, safe way; this is a small change to the code, but
a big change to the Distutils philosophy of passing option values
around. The preferred mode is still definitely to "pull" options
from another command (eg. "install" fetches the base build directory
from "build"), but it is now feasible to "push" options onto another
command, when you know what's best for it. One possible application
will be a "config" command, which pokes around the system and pushes
values (eg. include and library directories) onto the "build" command.
Added 'dump_option_dicts()' method (for debugging output).
* Command method 'find_peer()' -> 'get_finalized_command()'
* Command method 'run_peer()' -> 'run_command()'
Also deleted the 'get_command_option()' method from Command, and
fixed the one place where it was used (in "bdist_dumb").
directories after all is said and done, so we don't accidentally include
those files in the source distribution.
(This is the quick and easy way to fix this; Andrew says: "Changing
findall() looked like it was going to be messy, so I tried this instead.
The only problem is that redundant directory traversals are being done,
walking through build/ only to throw out all the files found at the end.").
* 'headers' entry added to all the install schemes
* '--install-headers' option added
* 'install_headers' added to 'sub_commands'
* added 'dist_name' to configuration variables (along with a few
others that seem handy: 'dist_version', 'dist_fullname', and
'py_version'
* in 'finalize_unix()', make sure 'install_headers' defined if
user specified 'install_base' and/or 'install_platbase'
* added 'has_headers()'
* a few other small changes
dictionaries in 'self.command_options' to 'get_option_dict()'.
Simplified code in 'parse_config_files()' and 'parse_command_line()'
accordingly.
Fixed code in constructor that processes the 'options' dictionary
from the setup script so it actually works: uses the new
'self.command_options' dictionary rather than creating command
objects and calling 'set_option()' on them.
attempt to verify the bold assertions in the documentation):
* entries for the "root package" in 'package_dir' didn't work --
fixed by improving the fall-through code in 'get_package_dir()'
* __init__.py files weren't installed when modules-in-packages
were listed individually (ie. in 'py_modules' in the setup script);
fixed by making 'check_package()' return the name of the __init__
file if it exists, and making 'find_modules()' add an entry to
the module list for __init__ if applicable
* 'first_line_re' loosened up
* command description improved
* replaced '_copy_files()' and '_adjust_files()' with one method
that does everything, 'copy_scripts()' -- this should be more
efficient than Bastian's version, should behave better in
dry-run mode, and does timestamp dependency-checking
necessary to support it.
Details:
- build command additionally calls build_scripts
- build_scripts builds your scripts in 'build/scripts' and adjusts the
first line if it begins with "#!" and ends with "python", optionally
ending with commandline options (like -O, -t ...). Adjusting means we
write the current path to the Python interpreter in the first line.
- install_scripts copies the scripts to the install_scripts dir
- install_data copies your data_files in install_data. You can
supply individual directories for your data_files:
data_files = ['doc/info.txt', # copy this file in install_scripts dir
('testdata', ['a.dat', 'b.dat']), # copy these files in
# install_scripts/testdata
('/etc', ['packagerc']), # copy this in /etc. When --root is
# given, copy this in rootdir/etc
]
So you can use the --root option with absolute data paths.
* 'get_command_obj()' now sets command attributes based on
the 'command_options' dictionary
* some typos fixed
* kludged 'parse_config_files()' to re-initialize the ConfigParser
instance after each file, so we know for sure which config
file each option comes form
* added lots of handy debugging output
command-line parsing code, splitting it up into several methods (new
methods: '_parse_command_opts()', '_show_help()') and making it put options
into the 'command_options' dictionary rather than instantiating command
objects and putting them there.
Lots of other little changes:
* merged 'find_command_class()' and 'create_command_obj()' and
called the result 'get_command_class()'
* renamed 'find_command_obj()' to 'get_command_obj()', and added
command object creation and maintenance of the command object cache to
its responsibilities (taken over from 'create_command_obj()')
* parse config files one-at-a-time, so we can keep track of the
filename for later error reporting
* tweaked some help messages
* fixed up many obsolete comments and docstrings
objects, it now has method names.
Added three methods, 'has_lib()', 'has_scripts()', and 'has_data()'
to determine if we need to run each of the three possible sub-commands.
Added 'get_sub_commands()' to take care of finding the methods named
in 'sub_commands', running them, and interpreting the results to
build a list of sub-commands that actually have to be run.
new flexibility, specifically the 'root' option. Now, we just use
"install" to do a fake installation into a temporary directory
(the 'bdist_dir' option, which derives from the 'bdist_base' option of
"bdist"), and then tar/zip up that directory. This means that dumb
built distributions are now relative to the root directory, rather than
the prefix or exec-prefix; this is probably a feature, but does make
them slightly less flexible.
top-level temporary directory for creating built distributions. (Won't
work yet, since the "build" command doesn't yet have a 'build_bdist'
option, and none of the "bdist" commands support it yet.)
- renamed '_copydata()' to 'copy_files()'
- changed it to record complete output filenames
- dropped '_outputdata()' in favour of much simpler 'get_outputs()'
adds the 'install_data' and 'install_scripts' commands; these two
are trivial thanks to the 'install_misc' base class in cmd.py.
(Minor tweaks and commentary by me; the code is untested so far.)
Also added creation of 'implib_dir', a temporary directory specific to
MSVC++ -- but I checked in two ways of fixing it (Lyle's and mine),
because I'm not sure which is right.
even if it's already absolute. Currently only implemented for Unix; I'm
not entirely sure of the right thing to do for DOS/Windows, and have no
clue what to do for Mac OS.
in command-line options, and in two phases at that: first, we expand
'install_base' and 'install_platbase', and then the other 'install_*'
options. This lets us do tricky stuff like
install --prefix='/tmp$sys_prefix'
...oooh, neat.
Simplified 'select_scheme()' -- it's no longer responsible for expanding
config vars, tildes, etc.
Define installation-specific config vars in 'self.config_vars', rather than
in a local dictionary of one method. Also factored '_expand_attrs()' out
of 'expand_dirs()' and added 'expand_basedirs()'.
Added a bunch of debugging output so I (and others) can judge the
success of this crazy scheme through direct feedback.
Adds bztar format to generate .tar.bz2 tarballs
Uses the -f argument to overright old tarballs automatically, I am
assuming that if the old tarball was wanted it would have been moved or
else the version number would have been changed.
Uses the -9 argument to bzip2 and gzip to use maximum
compression. Compress uses the maximum compression by default.
Tests for correct value for the 'compress' argument of make_tarball. This
is one less place for someone adding new compression programs to forget to
change.
to add the "display metadata" options: --name, --version, --author,
and so forth. Main changes:
* added 'display_options' class attribute to list all the "display only"
options (--help-commands plus the metadata options)
* added DistributionMetadata class as a place to put the actual
metadata information from the setup script (not to be confused with
the metadata display options); the logic dealing with metadata
(eg. return self.name or "UNKNOWN") is now in this class
* changed 'parse_command_line()' to use the new OO interface provided
by fancy_getopt, mainly so we can get at the original order of
options on the command line, so we can print multiple lines of
distribution meta-data in the order specified by the user
* added 'handle_display_options()' to handle display-only options
Also fixed some crufty old comments/docstrings.
class. (Mainly this was to support the ability to go back after the
getopt operation is done and get extra information about the parse,
in particular the original order of options seen on the command line.
But it's a big improvement and should make it a lot easier to add
functionality in the future.)
- DistutilsOptionError is now documented as it's actually used, ie.
to indicate bogus option values (usually user options, eg. from
the command-line)
- added DistutilsSetupError to indicate errors that definitely arise
in the setup script
- got rid of DistutilsValueError, and changed all usage of it to
either DistutilsSetupError or ValueError as appropriate
- simplified a bunch of option get/set methods in Command and
Distribution classes -- just pass on AttributeError most of
the time, rather than turning it into something else
than we actually use, and do actually use AR and SO.
Run ranlib on static libraries. (Should probably have a platform-check
so we don't run ranlib when it's not necessary, ie. on most modern
Unices.)
crashing when self.force not defined.
Revise 'copy_file()' and 'copy_tree()' docstrings accordingly.
Remove 'hasattr()' check for 'self.force' from 'make_file()'.
to all commands in the same way. Several Command methods now either expect
'self.force' to be defined, or check if it is defined and assume it's
false if not.
Added code to include source files from 'build_clib' command to default file
list -- currently this won't work, since 'build_clib' doesn't have a
'get_source_files()' method!
- file_util.py: operations on single files
- dir_util.py: operations on whole directories or directory trees
- dep_util.py: simple timestamp-based dependency analysis
- archive_util.py: creation of archive (tar, zip, ...) files
The functions left in util.py are miscellany that don't fit in any of the
new files.
the Command class from core.py to cmd.py. No other code needs changing
though; distutils.core still provides the Command and Distribution classes,
although indirectly now.
HKEY_* and Reg* names once, rather than having near-duplicate code
in the two import attempts.
Also dropped the leading underscore on all the imported symbols,
as it's not appropriate (they're not local to this module).
* build to "Debug" or "Release" temp directory
* put linker turds (.lib and .exp files) in the build temp directory
* tack on "_d" to extensions built with debugging
* added 'get_ext_libname()' help in putting linker turds to temp dir
Also, moved the code that simplifies None to empty list for a bunch
of options to 'finalize_options()' instead of 'run()'.
Simplified 'Command.get_peer_option()' a tad -- just call 'find_peer()'
to get the peer command object.
Updated 'Command.copy_file()' to take a 'link' parameter, just like
'util.copy_file()' does now.
Added 'Command.make_archive()' to wrap 'util.make_archive()'.
Changes to 'copy_file()':
* added support for making hard links and symlinks
* noted that it silently clobbers existing files when copying, but
blows up if destination exists when linking -- hmmm...
* error message tweak
Added 'base_name' parameter to 'make_tarball()' and 'make_zipfile()'.
Added 'make_archive()' -- wrapper around 'make_tarball()' or
'make_zipfile()' to take care of the archive "root directory".
the command that actually creates "dumb" binary distributions, ie.
tarballs and zip files that you just unpack under <prefix> or <exec-prefix>.
Very limited, but it's a start.
Initial revision is pretty limited; it only knows how to generate "dumb"
binary distributions, i.e. a tarball on Unix and a zip file on Windows.
Also, due to limitations in the installation code, it only knows how to
distribute Python library code. But hey, it's a start.
provided by Distribution.
Cosmetic and error message tweaks.
Simplified 'make_release_tree()':
* extracted 'distutils.util.create_tree()'
* don't have to do hard-linking ourselves -- it's now handled by
'distutils.util.copy_file()' (although the detection of
whether hard linking is available still needs to be factored out)
Removed 'make_tarball()' and 'make_zipfile()' entirely -- their role
is now amply filled by 'distutils.util.make_archive()'.
Simplified 'make_distribution()':
* use Distribution's new 'get_full_name()' method
* use 'make_archive()' instead of if/elif/.../else on the archive format
is responsible for installing all Python modules (pure and extensions).
Added 'get_outputs()' in preparation for the 'bdist' command, and
'_mutate_outputs()' to support 'get_outputs()'.
in a class attribute 'sub_commands', rather than hard-coded in 'run()'.
This should make it easier to subclass 'install', and also makes it
easier to keep 'run()' and the new 'get_outputs()' consistent.
Added 'get_outputs()' in preparation for the 'bdist' command.
Changed signature of 'build_extensions()': no longer takes the extension
list, but uses 'self.extensions' (just like 'get_outputs()' has to)
Moved call to 'check_extensions_list()' from 'run()' to 'build_extensions()',
again for consistency with 'get_outputs()'.
A host of improvements in preparation for the 'bdist' command:
- added 'get_outputs()' method (all the other improvements were to support
this addition)
- made 'find_package_modules()' and 'find_modules()' return similar
values (list of (package, module, module_filename) tuples)
- factored 'find_all_modules()' out of 'get_source_files()' (needed
by 'get_outputs()')
- factored 'get_module_outfile()' out of 'build_module()' (also needed
by 'get_outputs()')
- various little tweaks, improvements, comment/doc updates
we don't know what to do with it when we see it.
Call '_fix_object_args()' and/or '_fix_lib_args()' as appropriate, rather
than just '_fix_link_args()'.
Split '_fix_link_args()' up into '_fix_object_args()' (for use of
'create_static_lib() and link methods) and '_fix_lib_args()' (for the
link methods only).
these must come from the 'build' command. This means we no longer need
the misconceived 'set_peer_option()' method in Command and, more importantly,
sweeps away a bunch of potential future complexity to handle this tricky
case.
Fix 'Command.set_undefined_option()' to call 'ensure_ready()' rather
than 'finalize_options()' (which is only supposed to be called once,
which is the whole point of 'ensure_ready()').
Added comment to 'set_peer_option()' to remind myself that this method
cannot work and is fundamentally wrong-headed.
this command for a while; this implements roughly the plan cooked up by
Guido, Fred, and me. Seems to strike a nice balance between usability in
the common cases (just set one option), expandability for more types of
files to install in future, and customizability of installation
directories.
This revision isn't completely working: standard and alternate
installations work fine, but there are still some kinks to work out of
customized installations.
* improve help strings
* warn if user supplies non-existing directories
* don't try to 'remove_tree()' non-existing directories
* try to remove the build_base after cleanup (but don't do or say
anything if it fails -- this is just in case we made it empty)
option in the 'build_ext' command):
* in ccompiler.py: 'gen_lib_options()' now takes 'runtime_library_dirs'
parameter
* in unixccompiler.py and msvccompiler.py: now pass
'self.runtime_library_dirs' to 'gen_lib_options()', and define
'runtime_library_dir_option()' (although in msvccompiler.py it
blows up with a DistutilsPlatformError right now!)
sure it's imported! ;)
Re-wrap the docstrings on get_python_inc() and get_python_lib() to be
closer to the "normal" Python style. See GvR's "style guide" on the
essays page (http://www.python.org/doc/essays/).
There should never be a space between a function name and the '(' that
opens the argument list (see the style guide again).
the platform-neutral include dir by default and with Mac support.
Added 'get_python_lib()', inspired by 'get_python_inc()'.
Rewrote 'get_config_h_filename()' and 'get_makefile_filename()'
in terms of 'get_python_inc()' and 'get_python_lib()'.
Changed '_init_nt()' and '_init_mac()' to use 'get_python_inc()' and
'get_python_lib()' for directory names.
implement it (so far):
* moved filename generation methods into CCompiler base class,
driven by data supplied by implementation classes
* moved a bunch of common code from UnixCCompiler to convenience
methods in CCompiler
* overhauled MSVCCompiler's compile/link methods to look and act
as much as possible like UnixCCompiler's, in order to regularize
both interface and behaviour (especially by using those new
convenience methods)
* replaced build_lib.py with build_clib.py
* renamed the class in build_clib.py
* changed all references to 'build_lib' command in other command classes
when building extensions (uses build_lib's 'get_library_names()' method).
Ensure that the relative structure of source filenames is preserved in
the temporary build tree, eg. foo/bar.c compiles to
build/temp.<plat>/foo/bar.o.
Added 'build_clib' and 'build_temp' options (where to put C libraries
and where to put temporary compiler by-products, ie. object files).
Moved the call to 'check_library_list()' from 'run()' to 'finalize_options()'
-- that way, if we're going to crash we do so earlier, and we guarantee
that the library list is valid before we do anything (not just run).
Disallow directory separators in library names -- the compiled library
always goes right in 'build_clib'.
Added 'get_library_names()', so the "build_ext" command knows what
libraries to link every extension with.
filenames when constructing object filenames, even if output_dir given --
eg. "foo/bar.c" will compile to "foo/bar.o" without an output_dir, and to
"temp/foo/bar.o" if output_dir is "temp".
* 'build_dir' -> 'build_lib', which by default takes its value
straight from 'build_lib' in the 'build' command
* added 'build_temp' and 'inplace' options
* change 'build_extensions()' to put object files (compiler turds) in
'build_temp' dir
* complicated the name-of-extension-file shenanigans in
'build_extensions()' to support "in-place" extension building, i.e.
put the extension right into the source tree (handy for developers)
* added 'get_ext_fullname()', renamed 'extension_filename()' to
'get_ext_filename()', and tweaked the latter a bit -- all to support
the new filename shenanigans
old 'dist' command, but the code for dealing with manifests is completely
redone -- and renaming the command to 'sdist' is more symmetric with the
soon-to-exist 'bdist' command.
'get_msvc_paths()'.
Renamed '_do_SET()' to 'set_path_env_var()', tweaked docstring, and
cosmetically tweaked code.
Stylistic changes to MSVCCompiler constructor (variable renaming
and type consistency).
* tweak my docstrings
* fix None returns to empty list
* reshuffle responsibilities between '_find_exe()', '_find_SET()', and
the MSVCCompiler constructor -- now the constructor worries about
fetching the version list and determining the most recent one
* added "/W3" compile option
Also, I added/tweaked some docstrings.