desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'a ** b
If b is not an integer, the result will be a float or complex
since roots are generally irrational. If b is an integer, the
result will be rational.'
| def __pow__(a, b):
| if isinstance(b, numbers.Rational):
if (b.denominator == 1):
power = b.numerator
if (power >= 0):
return Fraction((a._numerator ** power), (a._denominator ** power))
else:
return Fraction((a._denominator ** (- power)), (a._numerator ** (- p... |
'a ** b'
| def __rpow__(b, a):
| if ((b._denominator == 1) and (b._numerator >= 0)):
return (a ** b._numerator)
if isinstance(a, numbers.Rational):
return (Fraction(a.numerator, a.denominator) ** b)
if (b._denominator == 1):
return (a ** b._numerator)
return (a ** float(b))
|
'+a: Coerces a subclass instance to Fraction'
| def __pos__(a):
| return Fraction(a._numerator, a._denominator)
|
'-a'
| def __neg__(a):
| return Fraction((- a._numerator), a._denominator)
|
'abs(a)'
| def __abs__(a):
| return Fraction(abs(a._numerator), a._denominator)
|
'trunc(a)'
| def __trunc__(a):
| if (a._numerator < 0):
return (- ((- a._numerator) // a._denominator))
else:
return (a._numerator // a._denominator)
|
'Will be math.floor(a) in 3.0.'
| def __floor__(a):
| return (a.numerator // a.denominator)
|
'Will be math.ceil(a) in 3.0.'
| def __ceil__(a):
| return (- ((- a.numerator) // a.denominator))
|
'Will be round(self, ndigits) in 3.0.
Rounds half toward even.'
| def __round__(self, ndigits=None):
| if (ndigits is None):
(floor, remainder) = divmod(self.numerator, self.denominator)
if ((remainder * 2) < self.denominator):
return floor
elif ((remainder * 2) > self.denominator):
return (floor + 1)
elif ((floor % 2) == 0):
return floor
el... |
'hash(self)'
| def __hash__(self):
| dinv = pow(self._denominator, (_PyHASH_MODULUS - 2), _PyHASH_MODULUS)
if (not dinv):
hash_ = _PyHASH_INF
else:
hash_ = ((abs(self._numerator) * dinv) % _PyHASH_MODULUS)
result = (hash_ if (self >= 0) else (- hash_))
return ((-2) if (result == (-1)) else result)
|
'a == b'
| def __eq__(a, b):
| if isinstance(b, numbers.Rational):
return ((a._numerator == b.numerator) and (a._denominator == b.denominator))
if (isinstance(b, numbers.Complex) and (b.imag == 0)):
b = b.real
if isinstance(b, float):
if (math.isnan(b) or math.isinf(b)):
return (0.0 == b)
else:... |
'Helper for comparison operators, for internal use only.
Implement comparison between a Rational instance `self`, and
either another Rational instance or a float `other`. If
`other` is not a Rational instance or a float, return
NotImplemented. `op` should be one of the six standard
comparison operators.'
| def _richcmp(self, other, op):
| if isinstance(other, numbers.Rational):
return op((self._numerator * other.denominator), (self._denominator * other.numerator))
if isinstance(other, float):
if (math.isnan(other) or math.isinf(other)):
return op(0.0, other)
else:
return op(self, self.from_float(ot... |
'a < b'
| def __lt__(a, b):
| return a._richcmp(b, operator.lt)
|
'a > b'
| def __gt__(a, b):
| return a._richcmp(b, operator.gt)
|
'a <= b'
| def __le__(a, b):
| return a._richcmp(b, operator.le)
|
'a >= b'
| def __ge__(a, b):
| return a._richcmp(b, operator.ge)
|
'a != 0'
| def __bool__(a):
| return (a._numerator != 0)
|
'Initializes options.'
| def initialize_options(self):
| self.prefix = None
self.exec_prefix = None
self.home = None
self.user = 0
self.install_base = None
self.install_platbase = None
self.root = None
self.install_purelib = None
self.install_platlib = None
self.install_headers = None
self.install_lib = None
self.install_script... |
'Finalizes options.'
| def finalize_options(self):
| if ((self.prefix or self.exec_prefix or self.home) and (self.install_base or self.install_platbase)):
raise DistutilsOptionError(('must supply either prefix/exec-prefix/home or ' + 'install-base/install-platbase -- not both'))
if (self.home and (self.prefix or self.exec_prefix)):... |
'Dumps the list of user options.'
| def dump_dirs(self, msg):
| if (not DEBUG):
return
from distutils.fancy_getopt import longopt_xlate
log.debug((msg + ':'))
for opt in self.user_options:
opt_name = opt[0]
if (opt_name[(-1)] == '='):
opt_name = opt_name[0:(-1)]
if (opt_name in self.negative_opt):
opt_name = se... |
'Finalizes options for posix platforms.'
| def finalize_unix(self):
| if ((self.install_base is not None) or (self.install_platbase is not None)):
if (((self.install_lib is None) and (self.install_purelib is None) and (self.install_platlib is None)) or (self.install_headers is None) or (self.install_scripts is None) or (self.install_data is None)):
raise Distutils... |
'Finalizes options for non-posix platforms'
| def finalize_other(self):
| if self.user:
if (self.install_userbase is None):
raise DistutilsPlatformError('User base directory is not specified')
self.install_base = self.install_platbase = self.install_userbase
self.select_scheme((os.name + '_user'))
elif (self.home is not None):
... |
'Sets the install directories by applying the install schemes.'
| def select_scheme(self, name):
| scheme = INSTALL_SCHEMES[name]
for key in SCHEME_KEYS:
attrname = ('install_' + key)
if (getattr(self, attrname) is None):
setattr(self, attrname, scheme[key])
|
'Calls `os.path.expanduser` on install_base, install_platbase and
root.'
| def expand_basedirs(self):
| self._expand_attrs(['install_base', 'install_platbase', 'root'])
|
'Calls `os.path.expanduser` on install dirs.'
| def expand_dirs(self):
| self._expand_attrs(['install_purelib', 'install_platlib', 'install_lib', 'install_headers', 'install_scripts', 'install_data'])
|
'Call `convert_path` over `names`.'
| def convert_paths(self, *names):
| for name in names:
attr = ('install_' + name)
setattr(self, attr, convert_path(getattr(self, attr)))
|
'Set `path_file` and `extra_dirs` using `extra_path`.'
| def handle_extra_path(self):
| if (self.extra_path is None):
self.extra_path = self.distribution.extra_path
if (self.extra_path is not None):
if isinstance(self.extra_path, str):
self.extra_path = self.extra_path.split(',')
if (len(self.extra_path) == 1):
path_file = extra_dirs = self.extra_pat... |
'Change the install directories pointed by name using root.'
| def change_roots(self, *names):
| for name in names:
attr = ('install_' + name)
setattr(self, attr, change_root(self.root, getattr(self, attr)))
|
'Create directories under ~.'
| def create_home_path(self):
| if (not self.user):
return
home = convert_path(os.path.expanduser('~'))
for (name, path) in self.config_vars.items():
if (path.startswith(home) and (not os.path.isdir(path))):
self.debug_print(("os.makedirs('%s', 0o700)" % path))
os.makedirs(path, 448)
|
'Runs the command.'
| def run(self):
| if (not self.skip_build):
self.run_command('build')
build_plat = self.distribution.get_command_obj('build').plat_name
if (self.warn_dir and (build_plat != get_platform())):
raise DistutilsPlatformError("Can't install when cross-compiling")
for cmd_name in self.get_su... |
'Creates the .pth file'
| def create_path_file(self):
| filename = os.path.join(self.install_libbase, (self.path_file + '.pth'))
if self.install_path_file:
self.execute(write_file, (filename, [self.extra_dirs]), ('creating %s' % filename))
else:
self.warn(("path file '%s' not created" % filename))
|
'Assembles the outputs of all the sub-commands.'
| def get_outputs(self):
| outputs = []
for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command(cmd_name)
for filename in cmd.get_outputs():
if (filename not in outputs):
outputs.append(filename)
if (self.path_file and self.install_path_file):
outputs.append(os.pat... |
'Returns the inputs of all the sub-commands'
| def get_inputs(self):
| inputs = []
for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command(cmd_name)
inputs.extend(cmd.get_inputs())
return inputs
|
'Returns true if the current distribution has any Python
modules to install.'
| def has_lib(self):
| return (self.distribution.has_pure_modules() or self.distribution.has_ext_modules())
|
'Returns true if the current distribution has any headers to
install.'
| def has_headers(self):
| return self.distribution.has_headers()
|
'Returns true if the current distribution has any scripts to.
install.'
| def has_scripts(self):
| return self.distribution.has_scripts()
|
'Returns true if the current distribution has any data to.
install.'
| def has_data(self):
| return self.distribution.has_data_files()
|
'Deprecated API.'
| def check_metadata(self):
| warn('distutils.command.register.check_metadata is deprecated, use the check command instead', PendingDeprecationWarning)
check = self.distribution.get_command_obj('check')
check.ensure_finalized()
check.strict = self.strict
... |
'Reads the configuration file and set attributes.'
| def _set_config(self):
| config = self._read_pypirc()
if (config != {}):
self.username = config['username']
self.password = config['password']
self.repository = config['repository']
self.realm = config['realm']
self.has_config = True
else:
if (self.repository not in ('pypi', self.DEFA... |
'Fetch the list of classifiers from the server.'
| def classifiers(self):
| url = (self.repository + '?:action=list_classifiers')
response = urllib.request.urlopen(url)
log.info(self._read_pypi_response(response))
|
'Send the metadata to the package index server to be checked.'
| def verify_metadata(self):
| (code, result) = self.post_to_server(self.build_post_data('verify'))
log.info(('Server response (%s): %s' % (code, result)))
|
'Send the metadata to the package index server.
Well, do the following:
1. figure who the user is, and then
2. send the data as a Basic auth\'ed POST.
First we try to read the username/password from $HOME/.pypirc,
which is a ConfigParser-formatted file with a section
[distutils] containing username and password entries... | def send_metadata(self):
| if self.has_config:
choice = '1'
username = self.username
password = self.password
else:
choice = 'x'
username = password = ''
choices = '1 2 3 4'.split()
while (choice not in choices):
self.announce('We need to know who you are,... |
'Post a query to the server, and return a string response.'
| def post_to_server(self, data, auth=None):
| if ('name' in data):
self.announce(('Registering %s to %s' % (data['name'], self.repository)), log.INFO)
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
sep_boundary = ('\n--' + boundary)
end_boundary = (sep_boundary + '--')
body = io.StringIO()
for (key, value)... |
'Generate list of \'(package,src_dir,build_dir,filenames)\' tuples'
| def get_data_files(self):
| data = []
if (not self.packages):
return data
for package in self.packages:
src_dir = self.get_package_dir(package)
build_dir = os.path.join(*([self.build_lib] + package.split('.')))
plen = 0
if src_dir:
plen = (len(src_dir) + 1)
filenames = [file[... |
'Return filenames for package\'s data files in \'src_dir\''
| def find_data_files(self, package, src_dir):
| globs = (self.package_data.get('', []) + self.package_data.get(package, []))
files = []
for pattern in globs:
filelist = glob(os.path.join(src_dir, convert_path(pattern)))
files.extend([fn for fn in filelist if ((fn not in files) and os.path.isfile(fn))])
return files
|
'Copy data files into build directory'
| def build_package_data(self):
| lastdir = None
for (package, src_dir, build_dir, filenames) in self.data_files:
for filename in filenames:
target = os.path.join(build_dir, filename)
self.mkpath(os.path.dirname(target))
self.copy_file(os.path.join(src_dir, filename), target, preserve_mode=False)
|
'Return the directory, relative to the top of the source
distribution, where package \'package\' should be found
(at least according to the \'package_dir\' option, if any).'
| def get_package_dir(self, package):
| path = package.split('.')
if (not self.package_dir):
if path:
return os.path.join(*path)
else:
return ''
else:
tail = []
while path:
try:
pdir = self.package_dir['.'.join(path)]
except KeyError:
t... |
'Finds individually-specified Python modules, ie. those listed by
module name in \'self.py_modules\'. Returns a list of tuples (package,
module_base, filename): \'package\' is a tuple of the path through
package-space to the module; \'module_base\' is the bare (no
packages, no dots) module name, and \'filename\' is th... | def find_modules(self):
| packages = {}
modules = []
for module in self.py_modules:
path = module.split('.')
package = '.'.join(path[0:(-1)])
module_base = path[(-1)]
try:
(package_dir, checked) = packages[package]
except KeyError:
package_dir = self.get_package_dir(pac... |
'Compute the list of all modules that will be built, whether
they are specified one-module-at-a-time (\'self.py_modules\') or
by whole packages (\'self.packages\'). Return a list of tuples
(package, module, module_file), just like \'find_modules()\' and
\'find_package_modules()\' do.'
| def find_all_modules(self):
| modules = []
if self.py_modules:
modules.extend(self.find_modules())
if self.packages:
for package in self.packages:
package_dir = self.get_package_dir(package)
m = self.find_package_modules(package, package_dir)
modules.extend(m)
return modules
|
'Check that \'self.compiler\' really is a CCompiler object;
if not, make it one.'
| def _check_compiler(self):
| from distutils.ccompiler import CCompiler, new_compiler
if (not isinstance(self.compiler, CCompiler)):
self.compiler = new_compiler(compiler=self.compiler, dry_run=self.dry_run, force=1)
customize_compiler(self.compiler)
if self.include_dirs:
self.compiler.set_include_dirs(se... |
'Construct a source file from \'body\' (a string containing lines
of C/C++ code) and \'headers\' (a list of header files to include)
and run it through the preprocessor. Return true if the
preprocessor succeeded, false if there were any errors.
(\'body\' probably isn\'t of much use, but what the heck.)'
| def try_cpp(self, body=None, headers=None, include_dirs=None, lang='c'):
| from distutils.ccompiler import CompileError
self._check_compiler()
ok = True
try:
self._preprocess(body, headers, include_dirs, lang)
except CompileError:
ok = False
self._clean()
return ok
|
'Construct a source file (just like \'try_cpp()\'), run it through
the preprocessor, and return true if any line of the output matches
\'pattern\'. \'pattern\' should either be a compiled regex object or a
string containing a regex. If both \'body\' and \'headers\' are None,
preprocesses an empty file -- which can be... | def search_cpp(self, pattern, body=None, headers=None, include_dirs=None, lang='c'):
| self._check_compiler()
(src, out) = self._preprocess(body, headers, include_dirs, lang)
if isinstance(pattern, str):
pattern = re.compile(pattern)
file = open(out)
match = False
while True:
line = file.readline()
if (line == ''):
break
if pattern.searc... |
'Try to compile a source file built from \'body\' and \'headers\'.
Return true on success, false otherwise.'
| def try_compile(self, body, headers=None, include_dirs=None, lang='c'):
| from distutils.ccompiler import CompileError
self._check_compiler()
try:
self._compile(body, headers, include_dirs, lang)
ok = True
except CompileError:
ok = False
log.info(((ok and 'success!') or 'failure.'))
self._clean()
return ok
|
'Try to compile and link a source file, built from \'body\' and
\'headers\', to executable form. Return true on success, false
otherwise.'
| def try_link(self, body, headers=None, include_dirs=None, libraries=None, library_dirs=None, lang='c'):
| from distutils.ccompiler import CompileError, LinkError
self._check_compiler()
try:
self._link(body, headers, include_dirs, libraries, library_dirs, lang)
ok = True
except (CompileError, LinkError):
ok = False
log.info(((ok and 'success!') or 'failure.'))
self._clean()
... |
'Try to compile, link to an executable, and run a program
built from \'body\' and \'headers\'. Return true on success, false
otherwise.'
| def try_run(self, body, headers=None, include_dirs=None, libraries=None, library_dirs=None, lang='c'):
| from distutils.ccompiler import CompileError, LinkError
self._check_compiler()
try:
(src, obj, exe) = self._link(body, headers, include_dirs, libraries, library_dirs, lang)
self.spawn([exe])
ok = True
except (CompileError, LinkError, DistutilsExecError):
ok = False
lo... |
'Determine if function \'func\' is available by constructing a
source file that refers to \'func\', and compiles and links it.
If everything succeeds, returns true; otherwise returns false.
The constructed source file starts out by including the header
files listed in \'headers\'. If \'decl\' is true, it then declares... | def check_func(self, func, headers=None, include_dirs=None, libraries=None, library_dirs=None, decl=0, call=0):
| self._check_compiler()
body = []
if decl:
body.append(('int %s ();' % func))
body.append('int main () {')
if call:
body.append((' %s();' % func))
else:
body.append((' %s;' % func))
body.append('}')
body = ('\n'.join(body) + '\n')
r... |
'Determine if \'library\' is available to be linked against,
without actually checking that any particular symbols are provided
by it. \'headers\' will be used in constructing the source file to
be compiled, but the only effect of this is to check if all the
header files listed are available. Any libraries listed in
... | def check_lib(self, library, library_dirs=None, headers=None, include_dirs=None, other_libraries=[]):
| self._check_compiler()
return self.try_link('int main (void) { }', headers, include_dirs, ([library] + other_libraries), library_dirs)
|
'Determine if the system header file named by \'header_file\'
exists and can be found by the preprocessor; return true if so,
false otherwise.'
| def check_header(self, header, include_dirs=None, library_dirs=None, lang='c'):
| return self.try_cpp(body='/* No body */', headers=[header], include_dirs=include_dirs)
|
'Sets default values for options.'
| def initialize_options(self):
| self.restructuredtext = 0
self.metadata = 1
self.strict = 0
self._warnings = 0
|
'Counts the number of warnings that occurs.'
| def warn(self, msg):
| self._warnings += 1
return Command.warn(self, msg)
|
'Runs the command.'
| def run(self):
| if self.metadata:
self.check_metadata()
if self.restructuredtext:
if HAS_DOCUTILS:
self.check_restructuredtext()
elif self.strict:
raise DistutilsSetupError('The docutils package is needed.')
if (self.strict and (self._warnings > 0)):
raise... |
'Ensures that all required elements of meta-data are supplied.
name, version, URL, (author and author_email) or
(maintainer and maintainer_email)).
Warns if any are missing.'
| def check_metadata(self):
| metadata = self.distribution.metadata
missing = []
for attr in ('name', 'version', 'url'):
if (not (hasattr(metadata, attr) and getattr(metadata, attr))):
missing.append(attr)
if missing:
self.warn(('missing required meta-data: %s' % ', '.join(missing)))
if me... |
'Checks if the long string fields are reST-compliant.'
| def check_restructuredtext(self):
| data = self.distribution.get_long_description()
for warning in self._check_rst_data(data):
line = warning[(-1)].get('line')
if (line is None):
warning = warning[1]
else:
warning = ('%s (line %s)' % (warning[1], line))
self.warn(warning)
|
'Returns warnings when the provided data doesn\'t compile.'
| def _check_rst_data(self, data):
| source_path = StringIO()
parser = Parser()
settings = frontend.OptionParser().get_default_values()
settings.tab_width = 4
settings.pep_references = None
settings.rfc_references = None
reporter = SilentReporter(source_path, settings.report_level, settings.halt_level, stream=settings.warning_s... |
'Generate the text of an RPM spec file and return it as a
list of strings (one per line).'
| def _make_spec_file(self):
| spec_file = [('%define name ' + self.distribution.get_name()), ('%define version ' + self.distribution.get_version().replace('-', '_')), ('%define unmangled_version ' + self.distribution.get_version()), ('%define release ' + self.release.replace('-', '_')), '', ('Summary: ' + self.distrib... |
'Format the changelog correctly and convert it to a list of strings'
| def _format_changelog(self, changelog):
| if (not changelog):
return changelog
new_changelog = []
for line in changelog.strip().split('\n'):
line = line.strip()
if (line[0] == '*'):
new_changelog.extend(['', line])
elif (line[0] == '-'):
new_changelog.append(line)
else:
new... |
'Ensure that the list of extensions (presumably provided as a
command option \'extensions\') is valid, i.e. it is a list of
Extension objects. We also support the old-style list of 2-tuples,
where the tuples are (ext_name, build_info), which are converted to
Extension instances here.
Raise DistutilsSetupError if the s... | def check_extensions_list(self, extensions):
| if (not isinstance(extensions, list)):
raise DistutilsSetupError("'ext_modules' option must be a list of Extension instances")
for (i, ext) in enumerate(extensions):
if isinstance(ext, Extension):
continue
if ((not isinstance(ext, tuple)) or (len(ext) ... |
'Walk the list of source files in \'sources\', looking for SWIG
interface (.i) files. Run SWIG on all that are found, and
return a modified \'sources\' list with SWIG source files replaced
by the generated C (or C++) files.'
| def swig_sources(self, sources, extension):
| new_sources = []
swig_sources = []
swig_targets = {}
if self.swig_cpp:
log.warn('--swig-cpp is deprecated - use --swig-opts=-c++')
if (self.swig_cpp or ('-c++' in self.swig_opts) or ('-c++' in extension.swig_opts)):
target_ext = '.cpp'
else:
target_ext = '.... |
'Return the name of the SWIG executable. On Unix, this is
just "swig" -- it should be in the PATH. Tries a bit harder on
Windows.'
| def find_swig(self):
| if (os.name == 'posix'):
return 'swig'
elif (os.name == 'nt'):
for vers in ('1.3', '1.2', '1.1'):
fn = os.path.join(('c:\\swig%s' % vers), 'swig.exe')
if os.path.isfile(fn):
return fn
else:
return 'swig.exe'
else:
raise Dist... |
'Returns the path of the filename for a given extension.
The file is located in `build_lib` or directly in the package
(inplace option).'
| def get_ext_fullpath(self, ext_name):
| fullname = self.get_ext_fullname(ext_name)
modpath = fullname.split('.')
filename = self.get_ext_filename(modpath[(-1)])
if (not self.inplace):
filename = os.path.join(*(modpath[:(-1)] + [filename]))
return os.path.join(self.build_lib, filename)
package = '.'.join(modpath[0:(-1)])
... |
'Returns the fullname of a given extension name.
Adds the `package.` prefix'
| def get_ext_fullname(self, ext_name):
| if (self.package is None):
return ext_name
else:
return ((self.package + '.') + ext_name)
|
'Convert the name of an extension (eg. "foo.bar") into the name
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").'
| def get_ext_filename(self, ext_name):
| from distutils.sysconfig import get_config_var
ext_path = ext_name.split('.')
ext_suffix = get_config_var('EXT_SUFFIX')
if ((os.name == 'nt') and self.debug):
return ((os.path.join(*ext_path) + '_d') + ext_suffix)
return (os.path.join(*ext_path) + ext_suffix)
|
'Return the list of symbols that a shared extension has to
export. This either uses \'ext.export_symbols\' or, if it\'s not
provided, "PyInit_" + module_name. Only relevant on Windows, where
the .pyd file (DLL) must export the module "PyInit_" function.'
| def get_export_symbols(self, ext):
| initfunc_name = ('PyInit_' + ext.name.split('.')[(-1)])
if (initfunc_name not in ext.export_symbols):
ext.export_symbols.append(initfunc_name)
return ext.export_symbols
|
'Return the list of libraries to link against when building a
shared extension. On most platforms, this is just \'ext.libraries\';
on Windows, we add the Python library (eg. python20.dll).'
| def get_libraries(self, ext):
| if (sys.platform == 'win32'):
from distutils.msvccompiler import MSVCCompiler
if (not isinstance(self.compiler, MSVCCompiler)):
template = 'python%d%d'
if self.debug:
template = (template + '_d')
pythonlib = (template % ((sys.hexversion >> 24), ((s... |
'Copy each script listed in \'self.scripts\'; if it\'s marked as a
Python script in the Unix way (first line matches \'first_line_re\',
ie. starts with "\#!" and contains "python"), then adjust the first
line to refer to the current Python interpreter as we copy.'
| def copy_scripts(self):
| self.mkpath(self.build_dir)
outfiles = []
updated_files = []
for script in self.scripts:
adjust = False
script = convert_path(script)
outfile = os.path.join(self.build_dir, os.path.basename(script))
outfiles.append(outfile)
if ((not self.force) and (not newer(scri... |
'Dialog(database, name, x, y, w, h, attributes, title, first,
default, cancel, bitmap=true)'
| def __init__(self, *args, **kw):
| Dialog.__init__(self, *args)
ruler = (self.h - 36)
bmwidth = ((152 * ruler) / 328)
self.line('BottomLine', 0, ruler, self.w, 0)
|
'Set the title text of the dialog at the top.'
| def title(self, title):
| self.text('Title', 15, 10, 320, 60, 196611, ('{\\VerdanaBold10}%s' % title))
|
'Add a back button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated'
| def back(self, title, next, name='Back', active=1):
| if active:
flags = 3
else:
flags = 1
return self.pushbutton(name, 180, (self.h - 27), 56, 17, flags, title, next)
|
'Add a cancel button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated'
| def cancel(self, title, next, name='Cancel', active=1):
| if active:
flags = 3
else:
flags = 1
return self.pushbutton(name, 304, (self.h - 27), 56, 17, flags, title, next)
|
'Add a Next button with a given title, the tab-next button,
its name in the Control table, possibly initially disabled.
Return the button, so that events can be associated'
| def next(self, title, next, name='Next', active=1):
| if active:
flags = 3
else:
flags = 1
return self.pushbutton(name, 236, (self.h - 27), 56, 17, flags, title, next)
|
'Add a button with a given title, the tab-next button,
its name in the Control table, giving its x position; the
y-position is aligned with the other buttons.
Return the button, so that events can be associated'
| def xbutton(self, name, title, next, xpos):
| return self.pushbutton(name, int(((self.w * xpos) - 28)), (self.h - 27), 56, 17, 3, title, next)
|
'Adds code to the installer to compute the location of Python.
Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the
registry for each version of Python.
Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined,
else from PYTHON.MACHINE.X.Y.
Properties PYTHONX.Y will be set to TARGETDIRX.Y\p... | def add_find_python(self):
| start = 402
for ver in self.versions:
install_path = ('SOFTWARE\\Python\\PythonCore\\%s\\InstallPath' % ver)
machine_reg = ('python.machine.' + ver)
user_reg = ('python.user.' + ver)
machine_prop = ('PYTHON.MACHINE.' + ver)
user_prop = ('PYTHON.USER.' + ver)
machi... |
'Callable used for the check sub-command.
Placed here so user_options can view it'
| def checking_metadata(self):
| return self.metadata_check
|
'Deprecated API.'
| def check_metadata(self):
| warn('distutils.command.sdist.check_metadata is deprecated, use the check command instead', PendingDeprecationWarning)
check = self.distribution.get_command_obj('check')
check.ensure_finalized()
check.run()
|
'Figure out the list of files to include in the source
distribution, and put it in \'self.filelist\'. This might involve
reading the manifest template (and writing the manifest), or just
reading the manifest, or just using the default file set -- it all
depends on the user\'s options.'
| def get_file_list(self):
| template_exists = os.path.isfile(self.template)
if ((not template_exists) and self._manifest_is_not_generated()):
self.read_manifest()
self.filelist.sort()
self.filelist.remove_duplicates()
return
if (not template_exists):
self.warn((("manifest template '%s' ... |
'Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as scripts.
- all C sources listed as part of extensions or C libraries... | def add_defaults(self):
| standards = [('README', 'README.txt'), self.distribution.script_name]
for fn in standards:
if isinstance(fn, tuple):
alts = fn
got_it = False
for fn in alts:
if os.path.exists(fn):
got_it = True
self.filelist.app... |
'Read and parse manifest template file named by self.template.
(usually "MANIFEST.in") The parsing and processing is done by
\'self.filelist\', which updates itself accordingly.'
| def read_template(self):
| log.info("reading manifest template '%s'", self.template)
template = TextFile(self.template, strip_comments=1, skip_blanks=1, join_lines=1, lstrip_ws=1, rstrip_ws=1, collapse_join=1)
try:
while True:
line = template.readline()
if (line is None):
break... |
'Prune off branches that might slip into the file list as created
by \'read_template()\', but really don\'t belong there:
* the build tree (typically "build")
* the release tree itself (only an issue if we ran "sdist"
previously with --keep-temp, or it aborted)
* any RCS, CVS, .svn, .hg, .git, .bzr, _darcs directories'... | def prune_file_list(self):
| build = self.get_finalized_command('build')
base_dir = self.distribution.get_fullname()
self.filelist.exclude_pattern(None, prefix=build.build_base)
self.filelist.exclude_pattern(None, prefix=base_dir)
if (sys.platform == 'win32'):
seps = '/|\\\\'
else:
seps = '/'
vcs_dirs = ... |
'Write the file list in \'self.filelist\' (presumably as filled in
by \'add_defaults()\' and \'read_template()\') to the manifest file
named by \'self.manifest\'.'
| def write_manifest(self):
| if self._manifest_is_not_generated():
log.info(("not writing to manually maintained manifest file '%s'" % self.manifest))
return
content = self.filelist.files[:]
content.insert(0, '# file GENERATED by distutils, do NOT edit')
self.execute(file_ut... |
'Read the manifest file (named by \'self.manifest\') and use it to
fill in \'self.filelist\', the list of files to include in the source
distribution.'
| def read_manifest(self):
| log.info("reading manifest file '%s'", self.manifest)
manifest = open(self.manifest)
for line in manifest:
line = line.strip()
if (line.startswith('#') or (not line)):
continue
self.filelist.append(line)
manifest.close()
|
'Create the directory tree that will become the source
distribution archive. All directories implied by the filenames in
\'files\' are created under \'base_dir\', and then we hard link or copy
(if hard linking is unavailable) those files into place.
Essentially, this duplicates the developer\'s source tree, but in a
d... | def make_release_tree(self, base_dir, files):
| self.mkpath(base_dir)
dir_util.create_tree(base_dir, files, dry_run=self.dry_run)
if hasattr(os, 'link'):
link = 'hard'
msg = ('making hard links in %s...' % base_dir)
else:
link = None
msg = ('copying files to %s...' % base_dir)
if (not files):
... |
'Create the source distribution(s). First, we create the release
tree with \'make_release_tree()\'; then, we create all required
archive files (according to \'self.formats\') from the release tree.
Finally, we clean up by blowing away the release tree (unless
\'self.keep_temp\' is true). The list of archive files cre... | def make_distribution(self):
| base_dir = self.distribution.get_fullname()
base_name = os.path.join(self.dist_dir, base_dir)
self.make_release_tree(base_dir, self.filelist.files)
archive_files = []
if ('tar' in self.formats):
self.formats.append(self.formats.pop(self.formats.index('tar')))
for fmt in self.formats:
... |
'Return the list of archive files created when the command
was run, or None if the command hasn\'t run yet.'
| def get_archive_files(self):
| return self.archive_files
|
'Return the list of files that would be installed if this command
were actually run. Not affected by the "dry-run" flag or whether
modules have actually been built yet.'
| def get_outputs(self):
| pure_outputs = self._mutate_outputs(self.distribution.has_pure_modules(), 'build_py', 'build_lib', self.install_dir)
if self.compile:
bytecode_outputs = self._bytecode_filenames(pure_outputs)
else:
bytecode_outputs = []
ext_outputs = self._mutate_outputs(self.distribution.has_ext_modules... |
'Get the list of files that are input to this command, ie. the
files that get installed as they are named in the build tree.
The files in this list correspond one-to-one to the output
filenames returned by \'get_outputs()\'.'
| def get_inputs(self):
| inputs = []
if self.distribution.has_pure_modules():
build_py = self.get_finalized_command('build_py')
inputs.extend(build_py.get_outputs())
if self.distribution.has_ext_modules():
build_ext = self.get_finalized_command('build_ext')
inputs.extend(build_ext.get_outputs())
... |
'Ensure that the list of libraries is valid.
`library` is presumably provided as a command option \'libraries\'.
This method checks that it is a list of 2-tuples, where the tuples
are (library_name, build_info_dict).
Raise DistutilsSetupError if the structure is invalid anywhere;
just returns otherwise.'
| def check_library_list(self, libraries):
| if (not isinstance(libraries, list)):
raise DistutilsSetupError("'libraries' option must be a list of tuples")
for lib in libraries:
if ((not isinstance(lib, tuple)) and (len(lib) != 2)):
raise DistutilsSetupError("each element of 'libraries' must ... |
'Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
class (via the \'executables\' class attribute), but most will have:
compiler the C/C++ compiler
linker_so linker used t... | def set_executables(self, **kwargs):
| for key in kwargs:
if (key not in self.executables):
raise ValueError(("unknown executable '%s' for class %s" % (key, self.__class__.__name__)))
self.set_executable(key, kwargs[key])
|
'Ensures that every element of \'definitions\' is a valid macro
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
nothing if all definitions are OK, raise TypeError otherwise.'
| def _check_macro_definitions(self, definitions):
| for defn in definitions:
if (not (isinstance(defn, tuple) and ((len(defn) in (1, 2)) and (isinstance(defn[1], str) or (defn[1] is None))) and isinstance(defn[0], str))):
raise TypeError(((("invalid macro definition '%s': " % defn) + 'must be tuple (string,), (string, s... |
'Define a preprocessor macro for all compilations driven by this
compiler object. The optional parameter \'value\' should be a
string; if it is not supplied, then the macro will be defined
without an explicit value and the exact outcome depends on the
compiler used (XXX true? does ANSI say anything about this?)'
| def define_macro(self, name, value=None):
| i = self._find_macro(name)
if (i is not None):
del self.macros[i]
self.macros.append((name, value))
|
'Undefine a preprocessor macro for all compilations driven by
this compiler object. If the same macro is defined by
\'define_macro()\' and undefined by \'undefine_macro()\' the last call
takes precedence (including multiple redefinitions or
undefinitions). If the macro is redefined/undefined on a
per-compilation basi... | def undefine_macro(self, name):
| i = self._find_macro(name)
if (i is not None):
del self.macros[i]
undefn = (name,)
self.macros.append(undefn)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.