Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
68cb7fe9
Commit
68cb7fe9
authored
Dec 06, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Whitespace normalization.
parent
1a4ad025
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
210 additions
and
216 deletions
+210
-216
archive_util.py
archive_util.py
+3
-3
bcppcompiler.py
bcppcompiler.py
+16
-16
ccompiler.py
ccompiler.py
+17
-17
cmd.py
cmd.py
+10
-10
core.py
core.py
+2
-2
cygwinccompiler.py
cygwinccompiler.py
+48
-49
dep_util.py
dep_util.py
+4
-4
dir_util.py
dir_util.py
+3
-3
dist.py
dist.py
+14
-14
extension.py
extension.py
+2
-2
fancy_getopt.py
fancy_getopt.py
+6
-6
file_util.py
file_util.py
+8
-8
filelist.py
filelist.py
+14
-14
msvccompiler.py
msvccompiler.py
+9
-9
mwerkscompiler.py
mwerkscompiler.py
+15
-17
spawn.py
spawn.py
+6
-6
sysconfig.py
sysconfig.py
+4
-4
text_file.py
text_file.py
+6
-7
unixccompiler.py
unixccompiler.py
+8
-8
util.py
util.py
+7
-9
version.py
version.py
+8
-8
No files found.
archive_util.py
View file @
68cb7fe9
...
...
@@ -31,7 +31,7 @@ def make_tarball (base_name, base_dir, compress="gzip",
compress_ext
=
{
'gzip'
:
".gz"
,
'bzip2'
:
'.bz2'
,
'compress'
:
".Z"
}
# flags for compression program, each element of list will be an argument
compress_flags
=
{
'gzip'
:
[
"-f9"
],
'compress'
:
[
"-f"
],
...
...
@@ -85,7 +85,7 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
import
zipfile
except
ImportError
:
raise
DistutilsExecError
,
\
(
"unable to create zip file '%s': "
+
(
"unable to create zip file '%s': "
+
"could neither find a standalone zip utility nor "
+
"import the 'zipfile' module"
)
%
zip_filename
...
...
@@ -152,7 +152,7 @@ def make_archive (base_name, format,
kwargs
=
{
'verbose'
:
verbose
,
'dry_run'
:
dry_run
}
try
:
format_info
=
ARCHIVE_FORMATS
[
format
]
except
KeyError
:
...
...
bcppcompiler.py
View file @
68cb7fe9
...
...
@@ -102,7 +102,7 @@ class BCPPCompiler(CCompiler) :
compile_opts
.
extend
(
self
.
compile_options_debug
)
else
:
compile_opts
.
extend
(
self
.
compile_options
)
for
i
in
range
(
len
(
sources
)):
src
=
sources
[
i
]
;
obj
=
objects
[
i
]
ext
=
(
os
.
path
.
splitext
(
src
))[
1
]
...
...
@@ -130,11 +130,11 @@ class BCPPCompiler(CCompiler) :
input_opt
=
""
elif
ext
in
self
.
_cpp_extensions
:
input_opt
=
"-P"
else
:
else
:
# Unknown file type -- no extra options. The compiler
# will probably fail, but let it just in case this is a
# file the compiler recognizes even if we don't.
input_opt
=
""
input_opt
=
""
output_opt
=
"-o"
+
obj
...
...
@@ -174,17 +174,17 @@ class BCPPCompiler(CCompiler) :
if
extra_postargs
:
lib_args
.
extend
(
extra_postargs
)
try
:
self
.
spawn
([
self
.
lib
]
+
lib_args
)
self
.
spawn
([
self
.
lib
]
+
lib_args
)
except
DistutilsExecError
,
msg
:
raise
LibError
,
msg
raise
LibError
,
msg
else
:
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
# create_static_lib ()
def
link
(
self
,
target_desc
,
target_desc
,
objects
,
output_filename
,
output_dir
=
None
,
...
...
@@ -254,14 +254,14 @@ class BCPPCompiler(CCompiler) :
resources
.
append
(
file
)
else
:
objects
.
append
(
file
)
for
l
in
library_dirs
:
ld_args
.
append
(
"/L%s"
%
os
.
path
.
normpath
(
l
))
ld_args
.
append
(
"/L%s"
%
os
.
path
.
normpath
(
l
))
ld_args
.
append
(
"/L."
)
# we sometimes use relative paths
# list of object files
ld_args
.
extend
(
objects
)
# list of object files
ld_args
.
extend
(
objects
)
# XXX the command-line syntax for Borland C++ is a bit wonky;
# certain filenames are jammed together in one big string, but
...
...
@@ -275,11 +275,11 @@ class BCPPCompiler(CCompiler) :
# name of dll/exe file
ld_args
.
extend
([
','
,
output_filename
])
# no map file and start libraries
# no map file and start libraries
ld_args
.
append
(
',,'
)
for
lib
in
libraries
:
# see if we find it and if there is a bcpp specific lib
# see if we find it and if there is a bcpp specific lib
# (xxx_bcpp.lib)
libfile
=
self
.
find_library_file
(
library_dirs
,
lib
,
debug
)
if
libfile
is
None
:
...
...
@@ -300,7 +300,7 @@ class BCPPCompiler(CCompiler) :
ld_args
.
append
(
','
)
ld_args
.
extend
(
resources
)
if
extra_preargs
:
ld_args
[:
0
]
=
extra_preargs
if
extra_postargs
:
...
...
ccompiler.py
View file @
68cb7fe9
...
...
@@ -61,7 +61,7 @@ class CCompiler:
# different versions of libfoo.a in different locations. I
# think this is useless without the ability to null out the
# library search path anyways.
# Subclasses that rely on the standard filename generation methods
# implemented below should override these; see the comment near
...
...
@@ -159,7 +159,7 @@ class CCompiler:
setattr
(
self
,
key
,
split_quoted
(
value
))
else
:
setattr
(
self
,
key
,
value
)
def
_find_macro
(
self
,
name
):
...
...
@@ -352,7 +352,7 @@ class CCompiler:
else
:
raise
TypeError
,
\
"'include_dirs' (if supplied) must be a list of strings"
return
(
output_dir
,
macros
,
include_dirs
)
# _fix_compile_args ()
...
...
@@ -364,7 +364,7 @@ class CCompiler:
list of all object files and a dictionary telling which source
files can be skipped.
"""
# Get the list of expected output (object) files
# Get the list of expected output (object) files
objects
=
self
.
object_filenames
(
sources
,
strip_dir
=
1
,
output_dir
=
output_dir
)
...
...
@@ -401,7 +401,7 @@ class CCompiler:
raise
TypeError
,
\
"'objects' must be a list or tuple of strings"
objects
=
list
(
objects
)
if
output_dir
is
None
:
output_dir
=
self
.
output_dir
elif
type
(
output_dir
)
is
not
StringType
:
...
...
@@ -560,7 +560,7 @@ class CCompiler:
Raises LibError on failure.
"""
pass
# values for target_desc parameter in link()
SHARED_OBJECT
=
"shared_object"
...
...
@@ -621,7 +621,7 @@ class CCompiler:
"""
raise
NotImplementedError
# Old 'link_*()' methods, rewritten to use the new 'link()' method.
def
link_shared_lib
(
self
,
...
...
@@ -636,13 +636,13 @@ class CCompiler:
extra_preargs
=
None
,
extra_postargs
=
None
,
build_temp
=
None
):
self
.
link
(
CCompiler
.
SHARED_LIBRARY
,
objects
,
self
.
link
(
CCompiler
.
SHARED_LIBRARY
,
objects
,
self
.
library_filename
(
output_libname
,
lib_type
=
'shared'
),
output_dir
,
libraries
,
library_dirs
,
runtime_library_dirs
,
export_symbols
,
debug
,
extra_preargs
,
extra_postargs
,
build_temp
)
def
link_shared_object
(
self
,
objects
,
...
...
@@ -673,9 +673,9 @@ class CCompiler:
debug
=
0
,
extra_preargs
=
None
,
extra_postargs
=
None
):
self
.
link
(
CCompiler
.
EXECUTABLE
,
objects
,
self
.
link
(
CCompiler
.
EXECUTABLE
,
objects
,
self
.
executable_filename
(
output_progname
),
output_dir
,
libraries
,
library_dirs
,
runtime_library_dirs
,
None
,
libraries
,
library_dirs
,
runtime_library_dirs
,
None
,
debug
,
extra_preargs
,
extra_postargs
,
None
)
...
...
@@ -846,12 +846,12 @@ _default_compilers = (
# on a cygwin built python we can use gcc like an ordinary UNIXish
# compiler
(
'cygwin.*'
,
'unix'
),
# OS name mappings
(
'posix'
,
'unix'
),
(
'nt'
,
'msvc'
),
(
'mac'
,
'mwerks'
),
)
def
get_default_compiler
(
osname
=
None
,
platform
=
None
):
...
...
@@ -901,7 +901,7 @@ def show_compilers():
# XXX this "knows" that the compiler option it's describing is
# "--compiler", which just happens to be the case for the three
# commands that use it.
from
distutils.fancy_getopt
import
FancyGetopt
from
distutils.fancy_getopt
import
FancyGetopt
compilers
=
[]
for
compiler
in
compiler_class
.
keys
():
compilers
.
append
((
"compiler="
+
compiler
,
None
,
...
...
@@ -909,7 +909,7 @@ def show_compilers():
compilers
.
sort
()
pretty_printer
=
FancyGetopt
(
compilers
)
pretty_printer
.
print_help
(
"List of available compilers:"
)
def
new_compiler
(
plat
=
None
,
compiler
=
None
,
...
...
@@ -932,14 +932,14 @@ def new_compiler (plat=None,
try
:
if
compiler
is
None
:
compiler
=
get_default_compiler
(
plat
)
(
module_name
,
class_name
,
long_description
)
=
compiler_class
[
compiler
]
except
KeyError
:
msg
=
"don't know how to compile C/C++ code on platform '%s'"
%
plat
if
compiler
is
not
None
:
msg
=
msg
+
" with '%s' compiler"
%
compiler
raise
DistutilsPlatformError
,
msg
try
:
module_name
=
"distutils."
+
module_name
__import__
(
module_name
)
...
...
cmd.py
View file @
68cb7fe9
...
...
@@ -41,7 +41,7 @@ class Command:
# current situation. (Eg. we "install_headers" is only applicable if
# we have any C header files to install.) If 'predicate' is None,
# that command is always applicable.
#
#
# 'sub_commands' is usually defined at the *end* of a class, because
# predicates can be unbound methods, so they must already have been
# defined. The canonical example is the "install" command.
...
...
@@ -111,7 +111,7 @@ class Command:
if
not
self
.
finalized
:
self
.
finalize_options
()
self
.
finalized
=
1
# Subclasses must define:
# initialize_options()
...
...
@@ -133,12 +133,12 @@ class Command:
command-line. Thus, this is not the place to code dependencies
between options; generally, 'initialize_options()' implementations
are just a bunch of "self.foo = None" assignments.
This method must be implemented by all command classes.
"""
raise
RuntimeError
,
\
"abstract method -- subclass %s must override"
%
self
.
__class__
def
finalize_options
(
self
):
"""Set final values for all the options that this command supports.
This is always called as late as possible, ie. after any option
...
...
@@ -198,12 +198,12 @@ class Command:
if
DEBUG
:
print
msg
sys
.
stdout
.
flush
()
# -- Option validation methods -------------------------------------
# (these are very handy in writing the 'finalize_options()' method)
#
#
# NB. the general philosophy here is to ensure that a particular option
# value meets certain type and value constraints. If not, we try to
# force it into conformance (eg. if we expect a list but have a string,
...
...
@@ -252,7 +252,7 @@ class Command:
raise
DistutilsOptionError
,
\
"'%s' must be a list of strings (got %s)"
%
\
(
option
,
`val`
)
def
_ensure_tested_string
(
self
,
option
,
tester
,
what
,
error_fmt
,
default
=
None
):
val
=
self
.
_ensure_stringlike
(
option
,
what
,
default
)
...
...
@@ -382,7 +382,7 @@ class Command:
and force flags.
"""
return
dir_util
.
copy_tree
(
infile
,
outfile
,
infile
,
outfile
,
preserve_mode
,
preserve_times
,
preserve_symlinks
,
not
self
.
force
,
self
.
verbose
>=
level
,
...
...
@@ -426,7 +426,7 @@ class Command:
(
outfile
,
string
.
join
(
infiles
,
', '
))
if
skip_msg
is
None
:
skip_msg
=
"skipping %s (inputs unchanged)"
%
outfile
# Allow 'infiles' to be a single string
if
type
(
infiles
)
is
StringType
:
...
...
@@ -459,7 +459,7 @@ class install_misc (Command):
"""Common base class for installing some files in a subdirectory.
Currently used by install_data and install_scripts.
"""
user_options
=
[(
'install-dir='
,
'd'
,
"directory to install the files to"
)]
def
initialize_options
(
self
):
...
...
core.py
View file @
68cb7fe9
...
...
@@ -108,7 +108,7 @@ def setup (**attrs):
# Find and parse the config file(s): they will override options from
# the setup script, but be overridden by the command line.
dist
.
parse_config_files
()
if
DEBUG
:
print
"options (after parsing config files):"
dist
.
dump_option_dicts
()
...
...
@@ -146,7 +146,7 @@ def setup (**attrs):
raise
else
:
raise
SystemExit
,
error
except
(
DistutilsExecError
,
DistutilsFileError
,
DistutilsOptionError
,
...
...
cygwinccompiler.py
View file @
68cb7fe9
This diff is collapsed.
Click to expand it.
dep_util.py
View file @
68cb7fe9
...
...
@@ -70,7 +70,7 @@ def newer_group (sources, target, missing='error'):
# If the target doesn't even exist, then it's definitely out-of-date.
if
not
os
.
path
.
exists
(
target
):
return
1
# Otherwise we have to find out the hard way: if *any* source file
# is more recent than 'target', then 'target' is out-of-date and
# we can immediately return true. If we fall through to the end
...
...
@@ -80,12 +80,12 @@ def newer_group (sources, target, missing='error'):
for
source
in
sources
:
if
not
os
.
path
.
exists
(
source
):
if
missing
==
'error'
:
# blow up when we stat() the file
pass
elif
missing
==
'ignore'
:
# missing source dropped from
pass
elif
missing
==
'ignore'
:
# missing source dropped from
continue
# target's dependency list
elif
missing
==
'newer'
:
# missing source means target is
return
1
# out-of-date
source_mtime
=
os
.
stat
(
source
)[
ST_MTIME
]
if
source_mtime
>
target_mtime
:
return
1
...
...
dir_util.py
View file @
68cb7fe9
...
...
@@ -49,7 +49,7 @@ def mkpath (name, mode=0777, verbose=0, dry_run=0):
(
head
,
tail
)
=
os
.
path
.
split
(
name
)
tails
=
[
tail
]
# stack of lone dirs to create
while
head
and
tail
and
not
os
.
path
.
isdir
(
head
):
#print "splitting '%s': " % head,
(
head
,
tail
)
=
os
.
path
.
split
(
head
)
...
...
@@ -140,7 +140,7 @@ def copy_tree (src, dst,
if
not
dry_run
and
not
os
.
path
.
isdir
(
src
):
raise
DistutilsFileError
,
\
"cannot copy tree '%s': not a directory"
%
src
"cannot copy tree '%s': not a directory"
%
src
try
:
names
=
os
.
listdir
(
src
)
except
os
.
error
,
(
errno
,
errstr
):
...
...
@@ -166,7 +166,7 @@ def copy_tree (src, dst,
if
not
dry_run
:
os
.
symlink
(
link_dest
,
dst_name
)
outputs
.
append
(
dst_name
)
elif
os
.
path
.
isdir
(
src_name
):
outputs
.
extend
(
copy_tree
(
src_name
,
dst_name
,
...
...
dist.py
View file @
68cb7fe9
...
...
@@ -97,7 +97,7 @@ class Distribution:
# -- Creation/initialization methods -------------------------------
def
__init__
(
self
,
attrs
=
None
):
"""Construct a new Distribution instance: initialize all the
attributes of a Distribution, and then use 'attrs' (a dictionary
...
...
@@ -208,7 +208,7 @@ class Distribution:
"invalid distribution option '%s'"
%
key
self
.
finalize_options
()
# __init__ ()
...
...
@@ -251,7 +251,7 @@ class Distribution:
print
indent
+
" "
+
line
# dump_option_dicts ()
# -- Config file finding/parsing methods ---------------------------
...
...
@@ -378,7 +378,7 @@ class Distribution:
cmdlist
=
self
.
get_command_list
()
self
.
script_args
=
EasyDialogs
.
GetArgv
(
self
.
global_options
+
self
.
display_options
,
cmdlist
)
# We have to parse the command line a bit at a time -- global
# options, then the first command, then its options, and so on --
# because each command will be handled by a different class, and
...
...
@@ -396,7 +396,7 @@ class Distribution:
# for display options we return immediately
if
self
.
handle_display_options
(
option_order
):
return
while
args
:
args
=
self
.
_parse_command_opts
(
parser
,
args
)
if
args
is
None
:
# user asked for help (and got it)
...
...
@@ -508,7 +508,7 @@ class Distribution:
"must be a callable object (function, etc.)"
%
(
`func`
,
help_option
))
if
help_option_found
:
if
help_option_found
:
return
# Put the options from the command-line into their official
...
...
@@ -801,7 +801,7 @@ class Distribution:
(from 'self.command_options').
"""
from
distutils.core
import
DEBUG
command_name
=
command_obj
.
get_command_name
()
if
option_dict
is
None
:
option_dict
=
self
.
get_option_dict
(
command_name
)
...
...
@@ -841,7 +841,7 @@ class Distribution:
user-supplied values from the config files and command line.
You'll have to re-finalize the command object (by calling
'finalize_options()' or 'ensure_finalized()') before using it for
real.
real.
'command' should be a command name (string) or command object. If
'reinit_subcommands' is true, also reinitializes the command's
...
...
@@ -868,11 +868,11 @@ class Distribution:
if
reinit_subcommands
:
for
sub
in
command
.
get_sub_commands
():
self
.
reinitialize_command
(
sub
,
reinit_subcommands
)
self
.
reinitialize_command
(
sub
,
reinit_subcommands
)
return
command
# -- Methods that operate on the Distribution ----------------------
def
announce
(
self
,
msg
,
level
=
1
):
...
...
@@ -976,7 +976,7 @@ class DistributionMetadata:
self
.
long_description
=
None
self
.
keywords
=
None
self
.
platforms
=
None
def
write_pkg_info
(
self
,
base_dir
):
"""Write the PKG-INFO file into the release tree.
"""
...
...
@@ -1003,9 +1003,9 @@ class DistributionMetadata:
pkg_info
.
write
(
'Platform: %s
\
n
'
%
platform
)
pkg_info
.
close
()
# write_pkg_info ()
# -- Metadata query methods ----------------------------------------
def
get_name
(
self
):
...
...
@@ -1045,7 +1045,7 @@ class DistributionMetadata:
def
get_license
(
self
):
return
self
.
license
or
"UNKNOWN"
get_licence
=
get_license
def
get_description
(
self
):
return
self
.
description
or
"UNKNOWN"
...
...
extension.py
View file @
68cb7fe9
...
...
@@ -16,7 +16,7 @@ from types import *
# module is already big enough, and I want to make this class a bit more
# complex to simplify some common cases ("foo" module in "foo.c") and do
# better error-checking ("foo.c" actually exists).
#
#
# Also, putting this in build_ext.py means every setup script would have to
# import that large-ish module (indirectly, through distutils.core) in
# order to do anything.
...
...
@@ -211,7 +211,7 @@ def read_setup_file (filename):
#extensions[module] = { 'sources': source_files,
# 'cpp_args': cpp_args,
# 'lib_args': library_args }
return
extensions
# read_setup_file ()
fancy_getopt.py
View file @
68cb7fe9
...
...
@@ -73,7 +73,7 @@ class FancyGetopt:
# 'negative_alias' keeps track of options that are the boolean
# opposite of some other option
self
.
negative_alias
=
{}
# These keep track of the information in the option table. We
# don't actually populate these structures until we're ready to
# parse the command-line, since the 'option_table' passed in here
...
...
@@ -90,7 +90,7 @@ class FancyGetopt:
self
.
option_order
=
[]
# __init__ ()
def
_build_index
(
self
):
self
.
option_index
.
clear
()
...
...
@@ -117,7 +117,7 @@ class FancyGetopt:
return
self
.
option_index
.
has_key
(
long_option
)
def
get_attr_name
(
self
,
long_option
):
"""Translate long option name 'long_option' to the form it
"""Translate long option name 'long_option' to the form it
has as an attribute of some object: ie., translate hyphens
to underscores."""
return
string
.
translate
(
long_option
,
longopt_xlate
)
...
...
@@ -134,7 +134,7 @@ class FancyGetopt:
raise
DistutilsGetoptError
,
\
(
"invalid %s '%s': "
"aliased option '%s' not defined"
)
%
(
what
,
alias
,
opt
)
def
set_aliases
(
self
,
alias
):
"""Set the aliases for this option parser."""
self
.
_check_alias_dict
(
alias
,
"alias"
)
...
...
@@ -476,7 +476,7 @@ def translate_longopt (opt):
changing "-" to "_".
"""
return
string
.
translate
(
opt
,
longopt_xlate
)
class
OptionDummy
:
"""Dummy class just used as a place to hold command-line option
...
...
@@ -489,7 +489,7 @@ class OptionDummy:
setattr
(
self
,
opt
,
None
)
# class OptionDummy
if
__name__
==
"__main__"
:
text
=
"""
\
...
...
file_util.py
View file @
68cb7fe9
...
...
@@ -35,20 +35,20 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
except
os
.
error
,
(
errno
,
errstr
):
raise
DistutilsFileError
,
\
"could not open '%s': %s"
%
(
src
,
errstr
)
try
:
fdst
=
open
(
dst
,
'wb'
)
except
os
.
error
,
(
errno
,
errstr
):
raise
DistutilsFileError
,
\
"could not create '%s': %s"
%
(
dst
,
errstr
)
while
1
:
try
:
buf
=
fsrc
.
read
(
buffer_size
)
except
os
.
error
,
(
errno
,
errstr
):
raise
DistutilsFileError
,
\
"could not read from '%s': %s"
%
(
src
,
errstr
)
if
not
buf
:
break
...
...
@@ -57,7 +57,7 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
except
os
.
error
,
(
errno
,
errstr
):
raise
DistutilsFileError
,
\
"could not write to '%s': %s"
%
(
dst
,
errstr
)
finally
:
if
fdst
:
fdst
.
close
()
...
...
@@ -134,7 +134,7 @@ def copy_file (src, dst,
print
"%s %s -> %s"
%
(
action
,
src
,
dir
)
else
:
print
"%s %s -> %s"
%
(
action
,
src
,
dst
)
if
dry_run
:
return
(
dst
,
1
)
...
...
@@ -146,7 +146,7 @@ def copy_file (src, dst,
except
os
.
error
,
exc
:
raise
DistutilsFileError
,
\
"could not copy '%s' to '%s': %s"
%
(
src
,
dst
,
exc
[
-
1
])
# If linking (hard or symbolic), use the appropriate system call
# (Unix only, of course, but that's the caller's responsibility)
elif
link
==
'hard'
:
...
...
@@ -189,7 +189,7 @@ def move_file (src, dst,
"""
from
os.path
import
exists
,
isfile
,
isdir
,
basename
,
dirname
import
errno
if
verbose
:
print
"moving %s -> %s"
%
(
src
,
dst
)
...
...
@@ -232,7 +232,7 @@ def move_file (src, dst,
except
os
.
error
:
pass
raise
DistutilsFileError
,
\
(
"couldn't move '%s' to '%s' by copy/delete: "
+
(
"couldn't move '%s' to '%s' by copy/delete: "
+
"delete '%s' failed: %s"
)
%
\
(
src
,
dst
,
src
,
msg
)
...
...
filelist.py
View file @
68cb7fe9
...
...
@@ -7,7 +7,7 @@ and building lists of files.
# created 2000/07/17, Rene Liebscher (as template.py)
# most parts taken from commands/sdist.py
# renamed 2000/07/29 (to filelist.py) and officially added to
# the Distutils source, Greg Ward
# the Distutils source, Greg Ward
__revision__
=
"$Id$"
...
...
@@ -34,8 +34,8 @@ class FileList:
filtering applied)
"""
def
__init__
(
self
,
warn
=
None
,
def
__init__
(
self
,
warn
=
None
,
debug_print
=
None
):
# use standard warning and debug functions if no other given
self
.
warn
=
warn
or
self
.
__warn
...
...
@@ -53,10 +53,10 @@ class FileList:
# -- Fallback warning/debug functions ------------------------------
def
__warn
(
self
,
msg
):
sys
.
stderr
.
write
(
"warning: %s
\
n
"
%
msg
)
def
__debug_print
(
self
,
msg
):
"""Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
...
...
@@ -93,7 +93,7 @@ class FileList:
# -- "File template" methods ---------------------------------------
def
_parse_template_line
(
self
,
line
):
words
=
string
.
split
(
line
)
action
=
words
[
0
]
...
...
@@ -129,9 +129,9 @@ class FileList:
return
(
action
,
patterns
,
dir
,
dir_pattern
)
# _parse_template_line ()
def
process_template_line
(
self
,
line
):
def
process_template_line
(
self
,
line
):
# Parse the line: split it up, make sure the right number of words
# is there, and return the relevant words. 'action' is always
...
...
@@ -190,7 +190,7 @@ class FileList:
self
.
warn
((
"no previously-included files matching '%s' "
+
"found under directory '%s'"
)
%
(
pattern
,
dir
))
elif
action
==
'graft'
:
self
.
debug_print
(
"graft "
+
dir_pattern
)
if
not
self
.
include_pattern
(
None
,
prefix
=
dir_pattern
):
...
...
@@ -251,7 +251,7 @@ class FileList:
self
.
debug_print
(
" adding "
+
name
)
self
.
files
.
append
(
name
)
files_found
=
1
return
files_found
# include_pattern ()
...
...
@@ -261,7 +261,7 @@ class FileList:
anchor
=
1
,
prefix
=
None
,
is_regex
=
0
):
"""Remove strings (presumably filenames) from 'files' that match
'pattern'. Other parameters are the same as for
'include_pattern()', above.
'include_pattern()', above.
The list 'self.files' is modified in place.
Return 1 if files are found.
"""
...
...
@@ -274,7 +274,7 @@ class FileList:
self
.
debug_print
(
" removing "
+
self
.
files
[
i
])
del
self
.
files
[
i
]
files_found
=
1
return
files_found
# exclude_pattern ()
...
...
@@ -354,14 +354,14 @@ def translate_pattern (pattern, anchor=1, prefix=None, is_regex=0):
pattern_re = glob_to_re(pattern)
else:
pattern_re = ''
if prefix is not None:
prefix_re = (glob_to_re(prefix))[0:-1] # ditch trailing $
pattern_re = "^" + os.path.join(prefix_re, ".*" + pattern_re)
else: # no prefix -- respect anchor flag
if anchor:
pattern_re = "^" + pattern_re
return re.compile(pattern_re)
# translate_pattern ()
msvccompiler.py
View file @
68cb7fe9
...
...
@@ -50,8 +50,8 @@ if _can_read_reg:
HKEY_LOCAL_MACHINE
=
hkey_mod
.
HKEY_LOCAL_MACHINE
HKEY_CURRENT_USER
=
hkey_mod
.
HKEY_CURRENT_USER
HKEY_USERS
=
hkey_mod
.
HKEY_USERS
def
get_devstudio_versions
():
"""Get list of devstudio versions from the Windows registry. Return a
...
...
@@ -93,7 +93,7 @@ def get_msvc_paths (path, version='6.0', platform='x86'):
"""Get a list of devstudio directories (include, lib or path). Return
a list of strings; will be empty list if unable to access the
registry or appropriate registry keys not found."""
if
not
_can_read_reg
:
return
[]
...
...
@@ -149,7 +149,7 @@ def find_exe (exe, version_number):
if
os
.
path
.
isfile
(
fn
):
return
fn
return
exe
# last desperate hope
return
exe
# last desperate hope
def
set_path_env_var
(
name
,
version_number
):
...
...
@@ -294,7 +294,7 @@ class MSVCCompiler (CCompiler) :
compile_opts
.
extend
(
self
.
compile_options_debug
)
else
:
compile_opts
.
extend
(
self
.
compile_options
)
for
i
in
range
(
len
(
sources
)):
src
=
sources
[
i
]
;
obj
=
objects
[
i
]
ext
=
(
os
.
path
.
splitext
(
src
))[
1
]
...
...
@@ -390,12 +390,12 @@ class MSVCCompiler (CCompiler) :
self
.
spawn
([
self
.
lib
]
+
lib_args
)
except
DistutilsExecError
,
msg
:
raise
LibError
,
msg
else
:
self
.
announce
(
"skipping %s (up-to-date)"
%
output_filename
)
# create_static_lib ()
def
link
(
self
,
target_desc
,
objects
,
...
...
@@ -417,7 +417,7 @@ class MSVCCompiler (CCompiler) :
if
runtime_library_dirs
:
self
.
warn
(
"I don't know what to do with 'runtime_library_dirs': "
+
str
(
runtime_library_dirs
))
lib_opts
=
gen_lib_options
(
self
,
library_dirs
,
runtime_library_dirs
,
libraries
)
...
...
@@ -441,7 +441,7 @@ class MSVCCompiler (CCompiler) :
for
sym
in
(
export_symbols
or
[]):
export_opts
.
append
(
"/EXPORT:"
+
sym
)
ld_args
=
(
ldflags
+
lib_opts
+
export_opts
+
ld_args
=
(
ldflags
+
lib_opts
+
export_opts
+
objects
+
[
'/OUT:'
+
output_filename
])
# The MSVC linker generates .lib and .exp files, which cannot be
...
...
mwerkscompiler.py
View file @
68cb7fe9
...
...
@@ -52,8 +52,8 @@ class MWerksCompiler (CCompiler) :
force
=
0
):
CCompiler
.
__init__
(
self
,
verbose
,
dry_run
,
force
)
def
compile
(
self
,
sources
,
output_dir
=
None
,
...
...
@@ -62,14 +62,14 @@ class MWerksCompiler (CCompiler) :
debug
=
0
,
extra_preargs
=
None
,
extra_postargs
=
None
):
(
output_dir
,
macros
,
include_dirs
)
=
\
self
.
_fix_compile_args
(
output_dir
,
macros
,
include_dirs
)
self
.
__sources
=
sources
self
.
__macros
=
macros
self
.
__include_dirs
=
include_dirs
# Don't need extra_preargs and extra_postargs for CW
return
[]
(
output_dir
,
macros
,
include_dirs
)
=
\
self
.
_fix_compile_args
(
output_dir
,
macros
,
include_dirs
)
self
.
__sources
=
sources
self
.
__macros
=
macros
self
.
__include_dirs
=
include_dirs
# Don't need extra_preargs and extra_postargs for CW
return
[]
def
link
(
self
,
target_desc
,
objects
,
...
...
@@ -198,7 +198,7 @@ class MWerksCompiler (CCompiler) :
if
self
.
verbose
:
print
'
\
t
Build project'
mkcwproject
.
buildproject
(
projectfilename
)
def
_filename_to_abs
(
self
,
filename
):
# Some filenames seem to be unix-like. Convert to Mac names.
## if '/' in filename and ':' in filename:
...
...
@@ -207,13 +207,11 @@ class MWerksCompiler (CCompiler) :
## filename = macurl2path(filename)
filename
=
distutils
.
util
.
convert_path
(
filename
)
if
not
os
.
path
.
isabs
(
filename
):
curdir
=
os
.
getcwd
()
filename
=
os
.
path
.
join
(
curdir
,
filename
)
curdir
=
os
.
getcwd
()
filename
=
os
.
path
.
join
(
curdir
,
filename
)
# Finally remove .. components
components
=
string
.
split
(
filename
,
':'
)
for
i
in
range
(
1
,
len
(
components
)):
if
components
[
i
]
==
'..'
:
components
[
i
]
=
''
if
components
[
i
]
==
'..'
:
components
[
i
]
=
''
return
string
.
join
(
components
,
':'
)
spawn.py
View file @
68cb7fe9
...
...
@@ -71,7 +71,7 @@ def _spawn_nt (cmd,
cmd
=
_nt_quote_args
(
cmd
)
if
search_path
:
# either we find one or it stays the same
executable
=
find_executable
(
executable
)
or
executable
executable
=
find_executable
(
executable
)
or
executable
if
verbose
:
print
string
.
join
([
executable
]
+
cmd
[
1
:],
' '
)
if
not
dry_run
:
...
...
@@ -87,7 +87,7 @@ def _spawn_nt (cmd,
raise
DistutilsExecError
,
\
"command '%s' failed with exit status %d"
%
(
cmd
[
0
],
rc
)
def
_spawn_posix
(
cmd
,
search_path
=
1
,
verbose
=
0
,
...
...
@@ -110,11 +110,11 @@ def _spawn_posix (cmd,
sys
.
stderr
.
write
(
"unable to execute %s: %s
\
n
"
%
(
cmd
[
0
],
e
.
strerror
))
os
.
_exit
(
1
)
sys
.
stderr
.
write
(
"unable to execute %s for unknown reasons"
%
cmd
[
0
])
os
.
_exit
(
1
)
else
:
# in the parent
# Loop until the child either exits or is terminated by a signal
# (ie. keep waiting if it's merely stopped)
...
...
@@ -133,7 +133,7 @@ def _spawn_posix (cmd,
raise
DistutilsExecError
,
\
"command '%s' failed with exit status %d"
%
\
(
cmd
[
0
],
exit_status
)
elif
os
.
WIFSTOPPED
(
status
):
continue
...
...
@@ -166,4 +166,4 @@ def find_executable(executable, path=None):
else
:
return
executable
# find_executable()
# find_executable()
sysconfig.py
View file @
68cb7fe9
...
...
@@ -48,7 +48,7 @@ def get_python_inc(plat_specific=0, prefix=None):
If 'prefix' is supplied, use it instead of sys.prefix or
sys.exec_prefix -- i.e., ignore 'plat_specific'.
"""
"""
if
prefix
is
None
:
prefix
=
plat_specific
and
EXEC_PREFIX
or
PREFIX
if
os
.
name
==
"posix"
:
...
...
@@ -318,7 +318,7 @@ def _init_posix():
# the scripts are in another directory.
if python_build:
g['LDSHARED'] = g['BLDSHARED']
elif sys.version < '2.1':
# The following two branches are for 1.5.2 compatibility.
if sys.platform == 'aix4': # what about AIX 3.x ?
...
...
@@ -337,7 +337,7 @@ def _init_posix():
python_lib = get_python_lib(standard_lib=1)
linkerscript_name = os.path.basename(string.split(g['LDSHARED'])[0])
linkerscript = os.path.join(python_lib, 'config', linkerscript_name)
# XXX this isn't the right place to do this: adding the Python
# library to the link, if needed, should be in the "
build_ext
"
# command. (It's also needed for non-MS compilers on Windows, and
...
...
@@ -345,7 +345,7 @@ def _init_posix():
# method.)
g['LDSHARED'] = ("
%
s
-
L
%
s
/
lib
-
lpython
%
s
" %
(linkerscript, PREFIX, sys.version[0:3]))
global _config_vars
_config_vars = g
...
...
text_file.py
View file @
68cb7fe9
...
...
@@ -86,7 +86,7 @@ class TextFile:
if
filename
is
None
and
file
is
None
:
raise
RuntimeError
,
\
"you must supply either or both of 'filename' and 'file'"
"you must supply either or both of 'filename' and 'file'"
# set values for all options -- either from client option hash
# or fallback to default_options
...
...
@@ -113,7 +113,7 @@ class TextFile:
# actually read from the file; it's only populated by an
# 'unreadline()' operation
self
.
linebuf
=
[]
def
open
(
self
,
filename
):
"""Open a new file named 'filename'. This overrides both the
...
...
@@ -213,7 +213,7 @@ class TextFile:
# EOF; I think that's OK.)
eol
=
(
line
[
-
1
]
==
'
\
n
'
)
and
'
\
n
'
or
''
line
=
line
[
0
:
pos
]
+
eol
# If all that's left is whitespace, then skip line
# *now*, before we try to join it to 'buildup_line' --
# that way constructs like
...
...
@@ -226,7 +226,7 @@ class TextFile:
else
:
# it's an escaped "#"
line
=
string
.
replace
(
line
,
"
\
\
#"
,
"#"
)
# did previous line end with a backslash? then accumulate
if
self
.
join_lines
and
buildup_line
:
...
...
@@ -256,7 +256,7 @@ class TextFile:
self
.
current_line
=
self
.
current_line
[
1
]
+
1
else
:
self
.
current_line
=
self
.
current_line
+
1
# strip whitespace however the client wants (leading and
# trailing, or one or the other, or neither)
...
...
@@ -351,7 +351,7 @@ line 3 \\
print
expected_result
print
"** received:"
print
result
filename
=
"test.txt"
out_file
=
open
(
filename
,
"w"
)
...
...
@@ -382,4 +382,3 @@ line 3 \\
test_input
(
6
,
"join lines with collapsing"
,
in_file
,
result6
)
os
.
remove
(
filename
)
unixccompiler.py
View file @
68cb7fe9
...
...
@@ -103,8 +103,8 @@ class UnixCCompiler (CCompiler):
pp_args
.
extend
(
extra_postargs
)
# We need to preprocess: either we're being forced to, or we're
# generating output to stdout, or there's a target output file and
# the source file is newer than the target (or the target doesn't
# generating output to stdout, or there's a target output file and
# the source file is newer than the target (or the target doesn't
# exist).
if
self
.
force
or
output_file
is
None
or
newer
(
source
,
output_file
):
if
output_file
:
...
...
@@ -139,7 +139,7 @@ class UnixCCompiler (CCompiler):
extra_postargs
=
[]
# Compile all source files that weren't eliminated by
# '_prep_compile()'.
# '_prep_compile()'.
for
i
in
range
(
len
(
sources
)):
src
=
sources
[
i
]
;
obj
=
objects
[
i
]
if
skip_sources
[
src
]:
...
...
@@ -157,7 +157,7 @@ class UnixCCompiler (CCompiler):
return
objects
# compile ()
def
create_static_lib
(
self
,
objects
,
...
...
@@ -193,7 +193,7 @@ class UnixCCompiler (CCompiler):
def
link
(
self
,
target_desc
,
target_desc
,
objects
,
output_filename
,
output_dir
=
None
,
...
...
@@ -219,7 +219,7 @@ class UnixCCompiler (CCompiler):
output_filename
=
os
.
path
.
join
(
output_dir
,
output_filename
)
if
self
.
_need_link
(
objects
,
output_filename
):
ld_args
=
(
objects
+
self
.
objects
+
ld_args
=
(
objects
+
self
.
objects
+
lib_opts
+
[
'-o'
,
output_filename
])
if
debug
:
ld_args
[:
0
]
=
[
'-g'
]
...
...
@@ -229,7 +229,7 @@ class UnixCCompiler (CCompiler):
ld_args
.
extend
(
extra_postargs
)
self
.
mkpath
(
os
.
path
.
dirname
(
output_filename
))
try
:
if
target_desc
==
CCompiler
.
EXECUTABLE
:
if
target_desc
==
CCompiler
.
EXECUTABLE
:
self
.
spawn
(
self
.
linker_exe
+
ld_args
)
else
:
self
.
spawn
(
self
.
linker_so
+
ld_args
)
...
...
@@ -244,7 +244,7 @@ class UnixCCompiler (CCompiler):
# -- Miscellaneous methods -----------------------------------------
# These are all used by the 'gen_lib_options() function, in
# ccompiler.py.
def
library_dir_option
(
self
,
dir
):
return
"-L"
+
dir
...
...
util.py
View file @
68cb7fe9
...
...
@@ -30,7 +30,7 @@ def get_platform ():
solaris-2.6-sun4u
irix-5.3
irix64-6.2
For non-POSIX platforms, currently just returns 'sys.platform'.
"""
if
os
.
name
!=
"posix"
or
not
hasattr
(
os
,
'uname'
):
...
...
@@ -44,9 +44,9 @@ def get_platform ():
# Convert the OS name to lowercase and remove '/' characters
# (to accommodate BSD/OS)
osname
=
string
.
lower
(
osname
)
osname
=
string
.
lower
(
osname
)
osname
=
string
.
replace
(
osname
,
'/'
,
''
)
if
osname
[:
5
]
==
"linux"
:
# At least on Linux/Intel, 'machine' is the processor --
# i386, etc.
...
...
@@ -59,7 +59,7 @@ def get_platform ():
# fall through to standard osname-release-machine representation
elif
osname
[:
4
]
==
"irix"
:
# could be "irix64"!
return
"%s-%s"
%
(
osname
,
release
)
elif
osname
[:
3
]
==
"aix"
:
elif
osname
[:
3
]
==
"aix"
:
return
"%s-%s.%s"
%
(
osname
,
version
,
release
)
elif
osname
[:
6
]
==
"cygwin"
:
osname
=
"cygwin"
...
...
@@ -67,7 +67,7 @@ def get_platform ():
m = rel_re.match(release)
if m:
release = m.group()
return "%s-%s-%s" % (osname, release, machine)
# get_platform ()
...
...
@@ -280,7 +280,7 @@ def execute (func, args, msg=None, verbose=0, dry_run=0):
# Generate a message if we weren't passed one
if msg is None:
msg = "%s%s" % (func.__name__, `args`)
if msg[-2:] == ',)': # correct for singleton tuple
if msg[-2:] == ',)': # correct for singleton tuple
msg = msg[0:-2] + ')'
# Print it if verbosity level is high enough
...
...
@@ -403,7 +403,7 @@ byte_compile(files, optimize=%s, force=%s,
spawn(cmd, verbose=verbose, dry_run=dry_run)
execute(os.remove, (script_name,), "removing %s" % script_name,
verbose=verbose, dry_run=dry_run)
# "Direct" byte-compilation: use the py_compile module to compile
# right here, right now. Note that the script generated in indirect
# mode simply calls 'byte_compile()' in direct mode, a weird sort of
...
...
@@ -453,5 +453,3 @@ def rfc822_escape (header):
lines = map(string.strip, lines)
header = string.join(lines, '
\
n
' + 8*' ')
return header
version.py
View file @
68cb7fe9
...
...
@@ -98,7 +98,7 @@ class StrictVersion (Version):
The rationale for this version numbering system will be explained
in the distutils documentation.
"""
version_re
=
re
.
compile
(
r'^(\
d+)
\. (\
d+) (
\. (\
d+))? ([
ab](\
d+))?$
',
re.VERBOSE)
...
...
@@ -123,7 +123,7 @@ class StrictVersion (Version):
def __str__ (self):
if self.version[2] == 0:
vstring = string.join(map(str, self.version[0:2]), '
.
')
else:
...
...
@@ -133,7 +133,7 @@ class StrictVersion (Version):
vstring = vstring + self.prerelease[0] + str(self.prerelease[1])
return vstring
def __cmp__ (self, other):
if isinstance(other, StringType):
...
...
@@ -170,7 +170,7 @@ class StrictVersion (Version):
# 2) sequences of letters are part of the tuple for comparison and are
# compared lexicographically
# 3) recognize the numeric components may have leading zeroes
#
#
# The LooseVersion class below implements these rules: a version number
# string is split up into a tuple of integer and string components, and
# comparison is a simple tuple comparison. This means that version
...
...
@@ -185,7 +185,7 @@ class StrictVersion (Version):
# - indicating a post-release patch ('p', 'pl', 'patch')
# but of course this can't cover all version number schemes, and there's
# no way to know what a programmer means without asking him.
#
#
# The problem is what to do with letters (and other non-numeric
# characters) in a version number. The current implementation does the
# obvious and predictable thing: keep them as strings and compare
...
...
@@ -208,7 +208,7 @@ class StrictVersion (Version):
# version numbering scheme to its domination. The free-thinking
# anarchists in the lot will never give in, though, and something needs
# to be done to accommodate them.
#
#
# Perhaps a "moderately strict" version class could be implemented that
# lets almost anything slide (syntactically), and makes some heuristic
# assumptions about non-digits in version number strings. This could
...
...
@@ -217,7 +217,7 @@ class StrictVersion (Version):
# somehow knows that "1.2.1" < "1.2.2a2" < "1.2.2" < "1.2.2pl3", and is
# just as happy dealing with things like "2g6" and "1.13++". I don't
# think I'm smart enough to do it right though.
#
#
# In any case, I've coded the test suite for this module (see
# ../test/test_version.py) specifically to fail on things like comparing
# "1.2a2" and "1.2". That's not because the *code* is doing anything
...
...
@@ -296,6 +296,6 @@ class LooseVersion (Version):
other
=
LooseVersion
(
other
)
return
cmp
(
self
.
version
,
other
.
version
)
# end class LooseVersion
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment